Allow rename of calendars

This commit is contained in:
Francis Lachapelle
2015-09-17 10:33:12 -04:00
parent 70bb512bb8
commit 58ff8139e9
4 changed files with 233 additions and 98 deletions
@@ -6,8 +6,8 @@
/**
* @ngInject
*/
CalendarsController.$inject = ['$scope', '$rootScope', '$stateParams', '$state', '$timeout', '$q', '$mdDialog', '$log', 'sgFocus', 'encodeUriFilter', 'Dialog', 'sgSettings', 'Calendar', 'User', 'stateCalendars'];
function CalendarsController($scope, $rootScope, $stateParams, $state, $timeout, $q, $mdDialog, $log, focus, encodeUriFilter, Dialog, Settings, Calendar, User, stateCalendars) {
CalendarsController.$inject = ['$scope', '$rootScope', '$stateParams', '$state', '$timeout', '$q', '$mdDialog', '$log', 'sgFocus', 'Dialog', 'sgSettings', 'Calendar', 'User', 'stateCalendars'];
function CalendarsController($scope, $rootScope, $stateParams, $state, $timeout, $q, $mdDialog, $log, focus, Dialog, Settings, Calendar, User, stateCalendars) {
var vm = this;
vm.activeUser = Settings.activeUser;
@@ -15,6 +15,9 @@
vm.newCalendar = newCalendar;
vm.addWebCalendar = addWebCalendar;
vm.confirmDelete = confirmDelete;
vm.editFolder = editFolder;
vm.revertEditing = revertEditing;
vm.renameFolder = renameFolder;
vm.share = share;
vm.showLinks = showLinks;
vm.showProperties = showProperties;
@@ -157,6 +160,26 @@
}
}
function editFolder(folder) {
vm.calendarName = folder.name;
vm.editMode = folder.id;
focus('calendarName_' + folder.id);
}
function revertEditing(folder) {
folder.$reset();
vm.editMode = false;
}
function renameFolder(folder) {
folder.$rename()
.then(function(data) {
vm.editMode = false;
}, function(data, status) {
Dialog.alert(l('Warning'), data);
});
}
function share(calendar) {
calendar.$acl.$users().then(function() {
$mdDialog.show({