(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)
|
- [web] move mailboxes (#644, #3511, #4479)
|
||||||
|
|
||||||
Enhancements
|
Enhancements
|
||||||
|
- [web] prohibit duplicate calendar categories in Preferences module
|
||||||
- [web] added Romanian (ro) translation - thanks to Vasile Razvan Luca
|
- [web] added Romanian (ro) translation - thanks to Vasile Razvan Luca
|
||||||
|
|
||||||
Bug fixes
|
Bug fixes
|
||||||
|
|
|
@ -124,6 +124,8 @@
|
||||||
"Prevent from being invited to appointments" = "Prevent from being invited to appointments";
|
"Prevent from being invited to appointments" = "Prevent from being invited to appointments";
|
||||||
"White list for appointment invitations" = "White list for appointment invitations";
|
"White list for appointment invitations" = "White list for appointment invitations";
|
||||||
"Contacts Names" = "Contacts Names";
|
"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" = "Default calendar";
|
"Default calendar" = "Default calendar";
|
||||||
|
|
|
@ -410,9 +410,14 @@
|
||||||
track by $index">
|
track by $index">
|
||||||
<sg-color-picker ng-model="app.preferences.defaults.SOGoCalendarCategoriesColors[item]"><!-- color picker--></sg-color-picker>
|
<sg-color-picker ng-model="app.preferences.defaults.SOGoCalendarCategoriesColors[item]"><!-- color picker--></sg-color-picker>
|
||||||
<md-input-container class="md-block md-flex">
|
<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-model="app.preferences.defaults.SOGoCalendarCategories[$index]"
|
||||||
|
ng-change="app.resetCalendarCategoryValidity($index, preferencesForm)"
|
||||||
sg-focus-on="calendarCategory_{{$index}}"/>
|
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-input-container>
|
||||||
<md-button class="sg-icon-button" type="button"
|
<md-button class="sg-icon-button" type="button"
|
||||||
layout="row" layout-align="end center"
|
layout="row" layout-align="end center"
|
||||||
|
|
|
@ -69,6 +69,10 @@
|
||||||
form.$setDirty();
|
form.$setDirty();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.resetCalendarCategoryValidity = function(index, form) {
|
||||||
|
form['calendarCategory_' + index].$setValidity('duplicate', true);
|
||||||
|
};
|
||||||
|
|
||||||
this.removeCalendarCategory = function(index, form) {
|
this.removeCalendarCategory = function(index, form) {
|
||||||
var key = this.preferences.defaults.SOGoCalendarCategories[index];
|
var key = this.preferences.defaults.SOGoCalendarCategories[index];
|
||||||
this.preferences.defaults.SOGoCalendarCategories.splice(index, 1);
|
this.preferences.defaults.SOGoCalendarCategories.splice(index, 1);
|
||||||
|
@ -320,6 +324,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IMAP labels must be unique
|
||||||
if (this.preferences.defaults.SOGoMailLabelsColorsKeys.length !=
|
if (this.preferences.defaults.SOGoMailLabelsColorsKeys.length !=
|
||||||
this.preferences.defaults.SOGoMailLabelsColorsValues.length ||
|
this.preferences.defaults.SOGoMailLabelsColorsValues.length ||
|
||||||
this.preferences.defaults.SOGoMailLabelsColorsKeys.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)
|
if (sendForm)
|
||||||
return this.preferences.$save().then(function(data) {
|
return this.preferences.$save().then(function(data) {
|
||||||
if (!options || !options.quick) {
|
if (!options || !options.quick) {
|
||||||
|
|
Loading…
Reference in New Issue