(js) Fix syncing of calendar categories colors

This commit is contained in:
Francis Lachapelle
2018-09-11 15:17:31 -04:00
parent 8f4a24fb67
commit 38c733bf8b
4 changed files with 18 additions and 8 deletions
+1
View File
@@ -13,6 +13,7 @@ Bug fixes
- [web] fixed condition of copy action on cards
- [web] fixed display of notification email in calendar properties
- [web] fixed display of multi-days events when some weekdays are disabled
- [web] fixed synchronisation of calendar categories
4.0.2 (2018-08-24)
------------------
@@ -409,7 +409,7 @@
ng-repeat="item in
app.preferences.defaults.SOGoCalendarCategories
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.SOGoCalendarCategoriesColorsValues[$index]"><!-- color picker--></sg-color-picker>
<md-input-container class="md-block md-flex">
<input type="text" label:aria-label="Calendar Category" required="required"
name="calendarCategory_{{$index}}"
@@ -114,10 +114,13 @@
angular.isArray(data.Forward.forwardAddress))
data.Forward.forwardAddress = data.Forward.forwardAddress.join(",");
if (angular.isUndefined(data.SOGoCalendarCategoriesColors)) {
data.SOGoCalendarCategoriesColors = {};
// Split calendar categories colors keys and values
if (angular.isUndefined(data.SOGoCalendarCategories))
data.SOGoCalendarCategories = [];
}
data.SOGoCalendarCategoriesColorsValues = [];
_.forEach(data.SOGoCalendarCategories, function (value) {
data.SOGoCalendarCategoriesColorsValues.push(data.SOGoCalendarCategoriesColors[value]);
});
if (angular.isUndefined(data.SOGoContactsCategories))
data.SOGoContactsCategories = [];
@@ -329,6 +332,13 @@
if (preferences.defaults.Forward && preferences.defaults.Forward.forwardAddress)
preferences.defaults.Forward.forwardAddress = preferences.defaults.Forward.forwardAddress.split(",");
// Merge back calendar categories colors keys and values
preferences.defaults.SOGoCalendarCategoriesColors = {};
_.forEach(preferences.defaults.SOGoCalendarCategories, function(key, i) {
preferences.defaults.SOGoCalendarCategoriesColors[key] = preferences.defaults.SOGoCalendarCategoriesColorsValues[i];
});
delete preferences.defaults.SOGoCalendarCategoriesColorsValues;
if (preferences.settings.Calendar && preferences.settings.Calendar.PreventInvitationsWhitelist) {
_.forEach(preferences.settings.Calendar.PreventInvitationsWhitelist, function(user) {
whitelist[user.uid] = user.$shortFormat();
@@ -64,13 +64,13 @@
this.resetCalendarCategories = function(form) {
this.preferences.defaults.SOGoCalendarCategories = _.keys($window.defaultCalendarCategories);
this.preferences.defaults.SOGoCalendarCategoriesColors = angular.copy($window.defaultCalendarCategories);
this.preferences.defaults.SOGoCalendarCategoriesColorsValues = _.values($window.defaultCalendarCategories);
form.$setDirty();
};
this.addCalendarCategory = function(form) {
this.preferences.defaults.SOGoCalendarCategoriesColors[l('New category')] = "#aaa";
this.preferences.defaults.SOGoCalendarCategories.push(l('New category'));
this.preferences.defaults.SOGoCalendarCategoriesColorsValues.push("#aaa");
focus('calendarCategory_' + (this.preferences.defaults.SOGoCalendarCategories.length - 1));
form.$setDirty();
};
@@ -80,9 +80,8 @@
};
this.removeCalendarCategory = function(index, form) {
var key = this.preferences.defaults.SOGoCalendarCategories[index];
this.preferences.defaults.SOGoCalendarCategories.splice(index, 1);
delete this.preferences.defaults.SOGoCalendarCategoriesColors[key];
this.preferences.defaults.SOGoCalendarCategoriesColorsValues.splice(index, 1);
form.$setDirty();
};