(feat) initial selection + ops in calendar module

This commit is contained in:
Ludovic Marcotte
2015-08-12 16:11:38 -04:00
parent 54334b294e
commit 47252affba
4 changed files with 99 additions and 4 deletions
@@ -255,6 +255,31 @@
return d.promise;
};
/**
* @function $deleteComponents
* @memberof Calendar
* @desc Delete multiple components from calendar.
* @return a promise of the HTTP operation
*/
Calendar.$deleteComponents = function(components) {
// We create a c_folder -> event hash
var calendars = {}, _this = this;
_.forEach(components, function(component) {
if (!angular.isDefined(calendars[component.c_folder]))
calendars[component.c_folder] = [];
calendars[component.c_folder].push(component.c_name);
});
_.forEach(calendars, function(uids, c_folder) {
Calendar.$$resource.post(c_folder, 'batchDelete', {uids: uids});
});
_this.$Component.$events = _.difference(_this.$Component.$events, components);
};
/**
* @function $save
* @memberof Calendar.prototype