From f34937d92c7371bcadd740d99a43e35eda59303e Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 10 Oct 2017 14:55:22 -0400 Subject: [PATCH] (js) Prevent the creation of empty card categories --- NEWS | 2 ++ UI/Templates/PreferencesUI/UIxPreferences.wox | 1 + .../js/Preferences/Preferences.service.js | 2 ++ .../js/Preferences/PreferencesController.js | 8 ++++++-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index c817a6ff9..1f16b2283 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,8 @@ Bug fixes - [web] only one postal address of same type is saved (#4091) - [web] improve handling of email notifications of a calendar properties - [web] fixed XSRF cookie path when changing password (#4139) + - [web] spaces can now be inserted in address book names + - [web] prevent the creation of empty contact categories - [eas] hebrew folders encoding problem using EAS (#4240) - [eas] avoid sync requests for shared folders every second (#4275) diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index 6526d63ce..694a6adeb 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -497,6 +497,7 @@ diff --git a/UI/WebServerResources/js/Preferences/Preferences.service.js b/UI/WebServerResources/js/Preferences/Preferences.service.js index 81f253961..860b8d9f2 100644 --- a/UI/WebServerResources/js/Preferences/Preferences.service.js +++ b/UI/WebServerResources/js/Preferences/Preferences.service.js @@ -108,6 +108,8 @@ if (angular.isUndefined(data.SOGoContactsCategories)) data.SOGoContactsCategories = []; + else + data.SOGoContactsCategories = _.compact(data.SOGoContactsCategories); angular.extend(_this.defaults, data); diff --git a/UI/WebServerResources/js/Preferences/PreferencesController.js b/UI/WebServerResources/js/Preferences/PreferencesController.js index 7a4d70646..86180eb83 100644 --- a/UI/WebServerResources/js/Preferences/PreferencesController.js +++ b/UI/WebServerResources/js/Preferences/PreferencesController.js @@ -76,8 +76,12 @@ }; this.addContactCategory = function(form) { - this.preferences.defaults.SOGoContactsCategories.push(""); - focus('contactCategory_' + (this.preferences.defaults.SOGoContactsCategories.length - 1)); + var i = _.indexOf(this.preferences.defaults.SOGoContactsCategories, ""); + if (i < 0) { + this.preferences.defaults.SOGoContactsCategories.push(""); + i = this.preferences.defaults.SOGoContactsCategories.length - 1; + } + focus('contactCategory_' + i); form.$setDirty(); };