(js) Prohibit duplicate contact categories
parent
ab7af8828c
commit
5d218e1113
1
NEWS
1
NEWS
|
@ -3,6 +3,7 @@
|
|||
|
||||
Enhancements
|
||||
- [web] avoid saving an empty calendar name
|
||||
- [web] prohibit duplicate contact categories in Preferences module
|
||||
|
||||
Bug fixes
|
||||
- [web] properly handle Windows-1256 charaset (#4781)
|
||||
|
|
|
@ -192,6 +192,7 @@
|
|||
/* Contact */
|
||||
"Personal Address Book" = "Personal Address Book";
|
||||
"Collected Address Book" = "Collected Address Book";
|
||||
"Contact categories must have unique names." = "Contact categories must have unique names.";
|
||||
|
||||
/* IMAP Accounts */
|
||||
"Settings" = "Settings";
|
||||
|
|
|
@ -509,8 +509,12 @@
|
|||
<input type="text"
|
||||
label:aria-label="Contact Category"
|
||||
required="required"
|
||||
name="contactCategory_{{$index}}"
|
||||
ng-model="app.preferences.defaults.SOGoContactsCategories[$index]"
|
||||
sg-focus-on="contactCategory_{{$index}}"/>
|
||||
<div ng-messages="preferencesForm['contactCategory_' + $index].$error">
|
||||
<div ng-message="duplicate"><var:string label:value="Duplicate name"/></div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
<md-button type="button" class="sg-icon-button"
|
||||
label:aria-label="Remove Contact Category"
|
||||
|
|
|
@ -54,10 +54,14 @@
|
|||
};
|
||||
|
||||
this.addCalendarCategory = function(form) {
|
||||
this.preferences.defaults.SOGoCalendarCategories.push(l('New category'));
|
||||
this.preferences.defaults.SOGoCalendarCategoriesColorsValues.push("#aaa");
|
||||
focus('calendarCategory_' + (this.preferences.defaults.SOGoCalendarCategories.length - 1));
|
||||
form.$setDirty();
|
||||
var i = _.indexOf(this.preferences.defaults.SOGoCalendarCategories, l('New category'));
|
||||
if (i < 0) {
|
||||
this.preferences.defaults.SOGoCalendarCategories.push(l('New category'));
|
||||
this.preferences.defaults.SOGoCalendarCategoriesColorsValues.push("#aaa");
|
||||
form.$setDirty();
|
||||
i = this.preferences.defaults.SOGoCalendarCategories.length - 1;
|
||||
}
|
||||
focus('calendarCategory_' + i);
|
||||
};
|
||||
|
||||
this.resetCalendarCategoryValidity = function(index, form) {
|
||||
|
@ -376,6 +380,20 @@
|
|||
});
|
||||
}
|
||||
|
||||
// Contact categories must be unique
|
||||
if (this.preferences.defaults.SOGoContactsCategories.length !=
|
||||
_.uniq(this.preferences.defaults.SOGoContactsCategories).length) {
|
||||
Dialog.alert(l('Error'), l("Contact categories must have unique names."));
|
||||
_.forEach(this.preferences.defaults.SOGoContactsCategories, function (value, i, keys) {
|
||||
if (form['contactCategory_' + i].$dirty &&
|
||||
(keys.indexOf(value) != i ||
|
||||
keys.indexOf(value, i+1) > -1)) {
|
||||
form['contactCategory_' + i].$setValidity('duplicate', false);
|
||||
sendForm = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (sendForm)
|
||||
return this.preferences.$save().then(function(data) {
|
||||
if (!options || !options.quick) {
|
||||
|
|
Loading…
Reference in New Issue