mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-22 11:55:24 +00:00
(html,js) Reorder and filter calendars list
This commit is contained in:
@@ -99,6 +99,12 @@
|
||||
});
|
||||
i = sibling ? _.indexOf(_.map(list, 'id'), sibling.id) : 1;
|
||||
list.splice(i, 0, calendar);
|
||||
|
||||
this.$Preferences.ready().then(function() {
|
||||
if (Calendar.$Preferences.settings.Calendar.FoldersOrder)
|
||||
// Save list order
|
||||
Calendar.saveFoldersOrder(_.flatMap(Calendar.$findAll(), 'id'));
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -129,8 +135,8 @@
|
||||
this.$calendars = [];
|
||||
this.$subscriptions = [];
|
||||
this.$webcalendars = [];
|
||||
Calendar.$$resource.fetch('calendarslist').then(function(data) {
|
||||
Calendar.$findAll(data.calendars, writable);
|
||||
return Calendar.$$resource.fetch('calendarslist').then(function(data) {
|
||||
return Calendar.$findAll(data.calendars, writable);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -261,6 +267,23 @@
|
||||
return Calendar.$q.all(promises);
|
||||
};
|
||||
|
||||
/**
|
||||
* @function saveFoldersOrder
|
||||
* @desc Save to the user's settings the current calendars order.
|
||||
* @param {string[]} folders - the folders IDs
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Calendar.saveFoldersOrder = function(folders) {
|
||||
return this.$$resource.post(null, 'saveFoldersOrder', { folders: folders }).then(function() {
|
||||
Calendar.$Preferences.settings.Calendar.FoldersOrder = folders;
|
||||
if (!folders)
|
||||
// Calendars order was reset; reload list
|
||||
return Calendar.$$resource.fetch('calendarslist').then(function(data) {
|
||||
return Calendar.$findAll(data.calendars);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @function init
|
||||
* @memberof Calendar.prototype
|
||||
|
||||
@@ -28,6 +28,22 @@
|
||||
vm.subscribeToFolder = subscribeToFolder;
|
||||
vm.today = today;
|
||||
|
||||
vm.filter = { name: '' };
|
||||
vm.toggleSortableMode = toggleSortableMode;
|
||||
vm.resetSort = resetSort;
|
||||
vm.sortableCalendars = {
|
||||
disabled: true,
|
||||
animation: 150,
|
||||
draggable: 'md-list-item',
|
||||
handle: '.md-menu',
|
||||
ghostClass: 'sg-sortable-ghost',
|
||||
chosenClass: 'sg-sortable-chosen',
|
||||
setData: sortable_setData,
|
||||
onEnd: sortable_onEnd
|
||||
};
|
||||
vm.sortableSubscriptions = angular.copy(vm.sortableCalendars);
|
||||
vm.sortableWebCalendars = angular.copy(vm.sortableCalendars);
|
||||
|
||||
Preferences.ready().then(function() {
|
||||
vm.categories = _.map(Preferences.defaults.SOGoCalendarCategories, function(name) {
|
||||
return { id: name.asCSSIdentifier(),
|
||||
@@ -65,7 +81,7 @@
|
||||
promises.push(calendar.$setActivation());
|
||||
});
|
||||
}
|
||||
if (commonList.length > 0)
|
||||
if (promises.length > 0 || commonList.length != newList.length || commonList.length != oldList.length)
|
||||
Calendar.$q.all(promises).then(function() {
|
||||
$rootScope.$emit('calendars:list');
|
||||
});
|
||||
@@ -73,6 +89,25 @@
|
||||
true // compare for object equality
|
||||
);
|
||||
|
||||
function sortable_setData(dataTransfer, dragEl) {
|
||||
dataTransfer.clearData();
|
||||
}
|
||||
|
||||
function sortable_onEnd() {
|
||||
Calendar.saveFoldersOrder(_.flatMap(Calendar.$findAll(), 'id'));
|
||||
}
|
||||
|
||||
function toggleSortableMode() {
|
||||
vm.sortableCalendars.disabled = !vm.sortableCalendars.disabled;
|
||||
vm.sortableSubscriptions.disabled = !vm.sortableSubscriptions.disabled;
|
||||
vm.sortableWebCalendars.disabled = !vm.sortableWebCalendars.disabled;
|
||||
vm.filter.name = '';
|
||||
}
|
||||
|
||||
function resetSort() {
|
||||
Calendar.saveFoldersOrder();
|
||||
}
|
||||
|
||||
function newCalendar(ev) {
|
||||
Dialog.prompt(l('New calendar'), l('Name of the Calendar'))
|
||||
.then(function(name) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular.module('SOGo.SchedulerUI', ['ui.router', 'angularFileUpload', 'SOGo.Common', 'SOGo.PreferencesUI', 'SOGo.ContactsUI', 'SOGo.MailerUI'])
|
||||
angular.module('SOGo.SchedulerUI', ['ui.router', 'angularFileUpload', 'SOGo.Common', 'SOGo.PreferencesUI', 'SOGo.ContactsUI', 'SOGo.MailerUI', 'ng-sortable'])
|
||||
.config(configure)
|
||||
.run(runBlock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user