(js) Respect SOGoCalendarDefaultReminder in editor

This commit is contained in:
Francis Lachapelle
2015-07-30 12:05:33 -04:00
parent b61eb00b99
commit 1f8edbdd1f
3 changed files with 19 additions and 2 deletions

View File

@@ -105,6 +105,9 @@
case 'M': /* min */
unit = @"MINUTES";
break;
case 'W': /* week */
unit = @"WEEKS";
break;
default:
NSLog(@"Cannot process duration unit: '%c'", c);
break;

View File

@@ -33,7 +33,7 @@
if (!unitsList)
{
unitsList = [NSArray arrayWithObjects: @"MINUTES", @"HOURS", @"DAYS", nil];
unitsList = [NSArray arrayWithObjects: @"MINUTES", @"HOURS", @"DAYS", @"WEEKS", nil];
[unitsList retain];
}

View File

@@ -347,7 +347,21 @@
this.repeat.end = 'never';
this.$hasCustomRepeat = this.hasCustomRepeat();
this.$hasAlarm = angular.isDefined(data.alarm);
if (this.isNew) {
// Set default alarm
Component.$Preferences.ready().then(function() {
var units = { M: 'MINUTES', H: 'HOURS', D: 'DAYS', W: 'WEEKS' };
var match = /-PT?([0-9]+)([MHDW])/.exec(Component.$Preferences.defaults.SOGoCalendarDefaultReminder);
if (match) {
_this.$hasAlarm = true;
_this.alarm.quantity = parseInt(match[1]);
_this.alarm.unit = units[match[2]];
}
});
}
else {
this.$hasAlarm = angular.isDefined(data.alarm);
}
// Allow the component to be moved to a different calendar
this.destinationCalendar = this.pid;