Skip to content

Commit

Permalink
(js) Improve event editor
Browse files Browse the repository at this point in the history
- fixed form validity check;
- fixed alarm restoration after a reset;
- fixed recurrence rules check.
  • Loading branch information
cgx committed Feb 28, 2017
1 parent 2a820bd commit 23ff62a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox
Expand Up @@ -303,7 +303,7 @@
<var:string label:value="Reset"/>
</md-button>
<md-button class="md-primary" type="submit"
ng-disabled="eventForm.$pristine || eventForm.$invalid || eventForm.$submitted">
ng-disabled="eventForm.$invalid || eventForm.$submitted">
<var:string label:value="Save"/>
</md-button>
</md-dialog-actions>
Expand Down
20 changes: 12 additions & 8 deletions UI/WebServerResources/js/Scheduler/Component.service.js
Expand Up @@ -565,11 +565,15 @@
this.repeat.frequency = 'never';
if (angular.isUndefined(this.repeat.interval))
this.repeat.interval = 1;
if (angular.isUndefined(this.repeat.month))
this.repeat.month = { occurrence: '1', day: 'SU', type: 'bymonthday' };
if (angular.isUndefined(this.repeat.monthdays))
// TODO: initialize this.repeat.monthdays with month day of start date
this.repeat.monthdays = [];
else if (this.repeat.monthdays.length > 0)
this.repeat.month = { type: 'bymonthday' };
if (angular.isUndefined(this.repeat.month))
this.repeat.month = {};
if (angular.isUndefined(this.repeat.month.occurrence))
angular.extend(this.repeat.month, { occurrence: '1', day: 'SU' });
if (angular.isUndefined(this.repeat.months))
// TODO: initialize this.repeat.months with month of start date
this.repeat.months = [];
Expand Down Expand Up @@ -607,7 +611,7 @@
_this.sendAppointmentNotifications = Component.$Preferences.defaults.SOGoAppointmentSendEMailNotifications;
});
}
else {
else if (angular.isUndefined(data.$hasAlarm)) {
this.$hasAlarm = angular.isDefined(data.alarm);
}

Expand Down Expand Up @@ -639,10 +643,10 @@
Component.prototype.hasCustomRepeat = function() {
var b = angular.isDefined(this.repeat) &&
(this.repeat.interval > 1 ||
this.repeat.days && this.repeat.days.length > 0 ||
this.repeat.monthdays && this.repeat.monthdays.length > 0 ||
this.repeat.months && this.repeat.months.length > 0 ||
this.repeat.month && this.repeat.month.day);
angular.isDefined(this.repeat.days) && this.repeat.days.length > 0 ||
angular.isDefined(this.repeat.monthdays) && this.repeat.monthdays.length > 0 ||
angular.isDefined(this.repeat.months) && this.repeat.months.length > 0 ||
angular.isDefined(this.repeat.month) && angular.isDefined(this.repeat.month.type));
return b;
};

Expand Down Expand Up @@ -1257,7 +1261,7 @@
var component = {};
angular.forEach(this, function(value, key) {
if (key != 'constructor' &&
key[0] != '$' &&
(key == '$hasAlarm' || key[0] != '$') &&
key != 'blocks') {
component[key] = angular.copy(value);
}
Expand Down
13 changes: 11 additions & 2 deletions UI/WebServerResources/js/Scheduler/ComponentController.js
Expand Up @@ -122,8 +122,8 @@

c.$reply().then(function() {
$rootScope.$emit('calendars:list');
$mdDialog.hide();
Alarm.getAlarms();
$mdDialog.hide();
});
}

Expand Down Expand Up @@ -217,6 +217,7 @@
vm.categories = {};
vm.showRecurrenceEditor = vm.component.$hasCustomRepeat;
vm.toggleRecurrenceEditor = toggleRecurrenceEditor;
vm.recurrenceMonthDaysAreRequired = recurrenceMonthDaysAreRequired;
vm.showAttendeesEditor = false;
vm.toggleAttendeesEditor = toggleAttendeesEditor;
//vm.searchText = null;
Expand Down Expand Up @@ -263,6 +264,11 @@
vm.showAttendeesEditor = !vm.showAttendeesEditor;
}

function recurrenceMonthDaysAreRequired() {
return vm.component.repeat.frequency == 'monthly' &&
vm.component.repeat.month.type == 'bymonthday';
}

// Autocomplete cards for attendees
function cardFilter($query) {
AddressBook.$filterAll($query);
Expand Down Expand Up @@ -308,8 +314,11 @@
Alarm.getAlarms();
$mdDialog.hide();
}, function(response) {
if (response.status == CalendarSettings.ConflictHTTPErrorCode)
if (response.status == CalendarSettings.ConflictHTTPErrorCode &&
_.isObject(response.data.message))
vm.attendeeConflictError = response.data.message;
else
edit(form);
});
}
}
Expand Down

0 comments on commit 23ff62a

Please sign in to comment.