(js) Prohibit duplicate calendar categories
parent
5a48fca43d
commit
30a81528a2
1
NEWS
1
NEWS
|
@ -5,6 +5,7 @@ New features
|
|||
- [web] move mailboxes (#644, #3511, #4479)
|
||||
|
||||
Enhancements
|
||||
- [web] prohibit duplicate calendar categories in Preferences module
|
||||
- [web] added Romanian (ro) translation - thanks to Vasile Razvan Luca
|
||||
|
||||
Bug fixes
|
||||
|
|
|
@ -124,6 +124,8 @@
|
|||
"Prevent from being invited to appointments" = "Prevent from being invited to appointments";
|
||||
"White list for appointment invitations" = "White list for appointment invitations";
|
||||
"Contacts Names" = "Contacts Names";
|
||||
"Duplicate name" = "Duplicate name";
|
||||
"Calendar categories must have unique names." = "Calendar categories must have unique names.";
|
||||
|
||||
/* Default Calendar */
|
||||
"Default calendar" = "Default calendar";
|
||||
|
|
|
@ -410,9 +410,14 @@
|
|||
track by $index">
|
||||
<sg-color-picker ng-model="app.preferences.defaults.SOGoCalendarCategoriesColors[item]"><!-- color picker--></sg-color-picker>
|
||||
<md-input-container class="md-block md-flex">
|
||||
<input type="text" label:aria-label="Calendar Category"
|
||||
<input type="text" label:aria-label="Calendar Category" required="required"
|
||||
name="calendarCategory_{{$index}}"
|
||||
ng-model="app.preferences.defaults.SOGoCalendarCategories[$index]"
|
||||
ng-change="app.resetCalendarCategoryValidity($index, preferencesForm)"
|
||||
sg-focus-on="calendarCategory_{{$index}}"/>
|
||||
<div ng-messages="preferencesForm['calendarCategory_' + $index].$error">
|
||||
<div ng-message="duplicate"><var:string label:value="Duplicate name"/></div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
<md-button class="sg-icon-button" type="button"
|
||||
layout="row" layout-align="end center"
|
||||
|
|
|
@ -69,6 +69,10 @@
|
|||
form.$setDirty();
|
||||
};
|
||||
|
||||
this.resetCalendarCategoryValidity = function(index, form) {
|
||||
form['calendarCategory_' + index].$setValidity('duplicate', true);
|
||||
};
|
||||
|
||||
this.removeCalendarCategory = function(index, form) {
|
||||
var key = this.preferences.defaults.SOGoCalendarCategories[index];
|
||||
this.preferences.defaults.SOGoCalendarCategories.splice(index, 1);
|
||||
|
@ -320,6 +324,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// IMAP labels must be unique
|
||||
if (this.preferences.defaults.SOGoMailLabelsColorsKeys.length !=
|
||||
this.preferences.defaults.SOGoMailLabelsColorsValues.length ||
|
||||
this.preferences.defaults.SOGoMailLabelsColorsKeys.length !=
|
||||
|
@ -335,6 +340,20 @@
|
|||
});
|
||||
}
|
||||
|
||||
// Calendar categories must be unique
|
||||
if (this.preferences.defaults.SOGoCalendarCategories.length !=
|
||||
_.uniq(this.preferences.defaults.SOGoCalendarCategories).length) {
|
||||
Dialog.alert(l('Error'), l("Calendar categories must have unique names."));
|
||||
_.forEach(this.preferences.defaults.SOGoCalendarCategories, function (value, i, keys) {
|
||||
if (form['calendarCategory_' + i].$dirty &&
|
||||
(keys.indexOf(value) != i ||
|
||||
keys.indexOf(value, i+1) > -1)) {
|
||||
form['calendarCategory_' + i].$setValidity('duplicate', false);
|
||||
sendForm = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (sendForm)
|
||||
return this.preferences.$save().then(function(data) {
|
||||
if (!options || !options.quick) {
|
||||
|
|
Loading…
Reference in New Issue