(js) Make sure some arrays are initialized

This commit is contained in:
Francis Lachapelle 2015-12-09 19:28:26 -05:00
parent 93ced64456
commit 6e988404d9
2 changed files with 11 additions and 7 deletions

View file

@ -40,14 +40,14 @@
} else } else
data.Vacation = {}; data.Vacation = {};
if (!angular.isDefined(data.Vacation.autoReplyEmailAddresses) && if (angular.isUndefined(data.Vacation.autoReplyEmailAddresses) &&
angular.isDefined(window.defaultEmailAddresses)) angular.isDefined(window.defaultEmailAddresses))
data.Vacation.autoReplyEmailAddresses = window.defaultEmailAddresses; data.Vacation.autoReplyEmailAddresses = window.defaultEmailAddresses;
if (!angular.isDefined(data.Vacation.daysBetweenResponse)) if (angular.isUndefined(data.Vacation.daysBetweenResponse))
data.Vacation.daysBetweenResponse = 7; data.Vacation.daysBetweenResponse = 7;
if (!angular.isDefined(data.Vacation.endDate)) { if (angular.isUndefined(data.Vacation.endDate)) {
data.Vacation.endDateEnabled = 0; data.Vacation.endDateEnabled = 0;
data.Vacation.endDate = new Date(); data.Vacation.endDate = new Date();
} }
@ -55,6 +55,14 @@
if (data.Forward && data.Forward.forwardAddress) if (data.Forward && data.Forward.forwardAddress)
data.Forward.forwardAddress = data.Forward.forwardAddress.join(","); data.Forward.forwardAddress = data.Forward.forwardAddress.join(",");
if (angular.isUndefined(data.SOGoCalendarCategoriesColors)) {
data.SOGoCalendarCategoriesColors = {};
data.SOGoCalendarCategories = [];
}
if (angular.isUndefined(data.SOGoContactsCategories))
data.SOGoContactsCategories = [];
angular.extend(_this.defaults, data); angular.extend(_this.defaults, data);
return _this.defaults; return _this.defaults;

View file

@ -71,10 +71,6 @@
} }
function addCalendarCategory() { function addCalendarCategory() {
if (!angular.isDefined(vm.preferences.defaults.SOGoCalendarCategoriesColors)) {
vm.preferences.defaults.SOGoCalendarCategoriesColors = {};
vm.preferences.defaults.SOGoCalendarCategories = [];
}
vm.preferences.defaults.SOGoCalendarCategoriesColors["New category"] = "#aaa"; vm.preferences.defaults.SOGoCalendarCategoriesColors["New category"] = "#aaa";
vm.preferences.defaults.SOGoCalendarCategories.push("New category"); vm.preferences.defaults.SOGoCalendarCategories.push("New category");
} }