mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-01 01:39:30 +00:00
(feat) initial selection + ops in calendar module
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
vm.componentType = 'events';
|
||||
vm.selectedList = 0;
|
||||
vm.selectComponentType = selectComponentType;
|
||||
vm.unselectComponents = unselectComponents;
|
||||
vm.selectAll = selectAll;
|
||||
vm.confirmDeleteSelectedComponents = confirmDeleteSelectedComponents;
|
||||
vm.openEvent = openEvent;
|
||||
vm.openTask = openTask;
|
||||
vm.newComponent = newComponent;
|
||||
@@ -45,11 +48,34 @@
|
||||
// TODO: save user settings (Calendar.SelectedList)
|
||||
if (angular.isUndefined(Component['$' + type]))
|
||||
Component.$filter(type);
|
||||
vm.unselectComponents();
|
||||
vm.componentType = type;
|
||||
Component.saveSelectedList(type);
|
||||
}
|
||||
}
|
||||
|
||||
function unselectComponents() {
|
||||
_.each(Component['$' + vm.componentType], function(component) { component.selected = false; });
|
||||
}
|
||||
|
||||
function selectAll() {
|
||||
_.each(Component['$' + vm.componentType], function(component) {
|
||||
component.selected = true;
|
||||
});
|
||||
}
|
||||
|
||||
function confirmDeleteSelectedComponents() {
|
||||
Dialog.confirm(l('Warning'),
|
||||
l('Are you sure you want to delete the selected components?'))
|
||||
.then(function() {
|
||||
// User confirmed the deletion
|
||||
var components = _.filter(Component['$' + vm.componentType], function(component) { return component.selected; });
|
||||
Calendar.$deleteComponents(components);
|
||||
}, function(data, status) {
|
||||
// Delete failed
|
||||
});
|
||||
}
|
||||
|
||||
function openEvent($event, event) {
|
||||
openComponent($event, event, 'appointment');
|
||||
}
|
||||
|
||||
@@ -86,9 +86,28 @@
|
||||
angular.module('SOGo.SchedulerUI')
|
||||
.factory('Component', Component.$factory);
|
||||
|
||||
/**
|
||||
* @function $selectedCount
|
||||
* @memberof Component
|
||||
* @desc Return the number of events or tasks selected by the user.
|
||||
* @returns the number of selected events or tasks
|
||||
*/
|
||||
Component.$selectedCount = function() {
|
||||
var count;
|
||||
|
||||
count = 0;
|
||||
if (Component.$events) {
|
||||
count = (_.filter(Component.$events, function(event) { return event.selected; })).length;
|
||||
}
|
||||
if (Component.$tasks) {
|
||||
count = (_.filter(Component.$tasks, function(event) { return event.selected; })).length;
|
||||
}
|
||||
return count;
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $filter
|
||||
* @memberof Component.prototype
|
||||
* @memberof Component
|
||||
* @desc Search for components matching some criterias
|
||||
* @param {string} type - either 'events' or 'tasks'
|
||||
* @param {object} [options] - additional options to the query
|
||||
@@ -403,6 +422,8 @@
|
||||
_this.updateFreeBusy(attendee);
|
||||
});
|
||||
}
|
||||
|
||||
this.selected = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user