mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-27 09:02:43 +00:00
@@ -94,7 +94,6 @@
|
||||
list = this.$calendars;
|
||||
|
||||
sibling = _.findIndex(list, function(o, i) {
|
||||
console.debug(i + ': "' + o.id + '".localeCompare("' + calendar.name + '") = ' + o.name.localeCompare(calendar.name));
|
||||
return (calendar.id == 'personal' ||
|
||||
(o.id != 'personal' && o.name.localeCompare(calendar.name) > 0));
|
||||
});
|
||||
@@ -325,6 +324,24 @@
|
||||
return Calendar.$q.all(promises);
|
||||
};
|
||||
|
||||
/**
|
||||
* @function saveFoldersActivation
|
||||
* @memberof Calendar
|
||||
* @desc Save to the user's settings the activation state of the calendars
|
||||
* @param {string[]} folders - the folders IDs
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Calendar.saveFoldersActivation = function(ids) {
|
||||
var request = {};
|
||||
|
||||
_.forEach(ids, function(id) {
|
||||
var calendar = Calendar.$get(id);
|
||||
request[calendar.id] = calendar.active;
|
||||
});
|
||||
|
||||
return Calendar.$$resource.post(null, 'saveFoldersActivation', request);
|
||||
};
|
||||
|
||||
/**
|
||||
* @function saveFoldersOrder
|
||||
* @desc Save to the user's settings the current calendars order.
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
);
|
||||
},
|
||||
function(newList, oldList) {
|
||||
var commonList, ids, promises;
|
||||
var commonList, ids, promise;
|
||||
|
||||
// Identify which calendar has changed
|
||||
commonList = _.intersectionBy(newList, oldList, 'id');
|
||||
@@ -66,17 +66,14 @@
|
||||
var oldObject = _.find(oldList, { id: o.id });
|
||||
return !_.isEqual(o, oldObject);
|
||||
}), 'id');
|
||||
promises = [];
|
||||
promise = Calendar.$q.when();
|
||||
|
||||
if (ids.length > 0) {
|
||||
$log.debug(ids.join(', ') + ' changed');
|
||||
_.forEach(ids, function(id) {
|
||||
var calendar = Calendar.$get(id);
|
||||
promises.push(calendar.$setActivation());
|
||||
});
|
||||
promise = Calendar.saveFoldersActivation(ids);
|
||||
}
|
||||
if (promises.length > 0 || commonList.length != newList.length || commonList.length != oldList.length)
|
||||
Calendar.$q.all(promises).then(function() {
|
||||
if (ids.length > 0 || commonList.length != newList.length || commonList.length != oldList.length)
|
||||
promise.then(function() {
|
||||
$rootScope.$emit('calendars:list');
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user