mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-17 01:15:24 +00:00
(feat) new mailbox sharing capabilities and mailbox menu
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
this.isEditable = this.$isEditable();
|
||||
// Make a copy of the data for an eventual reset
|
||||
this.$shadowData = this.$omit();
|
||||
this.$acl = new Mailbox.$$Acl('Mail/' + this.id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -38,13 +39,14 @@
|
||||
* @desc The factory we'll use to register with Angular
|
||||
* @returns the Mailbox constructor
|
||||
*/
|
||||
Mailbox.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Message', 'sgMailbox_PRELOAD', function($q, $timeout, $log, Settings, Resource, Message, PRELOAD) {
|
||||
Mailbox.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Message', 'Acl', 'sgMailbox_PRELOAD', function($q, $timeout, $log, Settings, Resource, Message, Acl, PRELOAD) {
|
||||
angular.extend(Mailbox, {
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$log: $log,
|
||||
$$resource: new Resource(Settings.activeUser.folderURL + 'Mail', Settings.activeUser),
|
||||
$Message: Message,
|
||||
$$Acl: Acl,
|
||||
PRELOAD: PRELOAD
|
||||
});
|
||||
|
||||
@@ -489,6 +491,9 @@
|
||||
_.extend(_this.$messages[i], msg);
|
||||
});
|
||||
}
|
||||
// Instanciate Acl object
|
||||
_this.$acl = new Mailbox.$$Acl('Mail/' + _this.id);
|
||||
|
||||
Mailbox.$log.debug('mailbox ' + _this.id + ' ready');
|
||||
_this.$isLoading = false;
|
||||
deferred.resolve(_this.$messages);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
MailboxesController.$inject = ['$scope', '$rootScope', '$stateParams', '$state', '$timeout', 'sgFocus', 'encodeUriFilter', 'Dialog', 'sgSettings', 'Account', 'Mailbox', 'stateAccounts'];
|
||||
function MailboxesController($scope, $rootScope, $stateParams, $state, $timeout, focus, encodeUriFilter, Dialog, Settings, Account, Mailbox, stateAccounts) {
|
||||
MailboxesController.$inject = ['$scope', '$rootScope', '$stateParams', '$state', '$timeout', '$q', '$mdDialog', 'sgFocus', 'encodeUriFilter', 'Dialog', 'sgSettings', 'Account', 'Mailbox', 'User', 'stateAccounts'];
|
||||
function MailboxesController($scope, $rootScope, $stateParams, $state, $timeout, $q, $mdDialog, focus, encodeUriFilter, Dialog, Settings, Account, Mailbox, User, stateAccounts) {
|
||||
$scope.activeUser = Settings.activeUser;
|
||||
$scope.accounts = stateAccounts;
|
||||
|
||||
@@ -58,7 +58,106 @@
|
||||
});
|
||||
});
|
||||
};
|
||||
$scope.share = function(folder) {
|
||||
//if (addressbook.id != vm.service.selectedFolder.id) {
|
||||
// Counter the possibility to click on the "hidden" secondary button
|
||||
//select(addressbook);
|
||||
// return;
|
||||
//}
|
||||
// Fetch list of ACL users
|
||||
folder.$acl.$users().then(function() {
|
||||
// Show ACL editor
|
||||
$mdDialog.show({
|
||||
templateUrl: folder.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox
|
||||
controller: MailboxACLController,
|
||||
controllerAs: 'acl',
|
||||
clickOutsideToClose: true,
|
||||
escapeToClose: true,
|
||||
locals: {
|
||||
usersWithACL: folder.$acl.users,
|
||||
User: User,
|
||||
folder: folder,
|
||||
$q: $q
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
MailboxACLController.$inject = ['$scope', '$mdDialog', 'usersWithACL', 'User', 'folder', '$q'];
|
||||
function MailboxACLController($scope, $mdDialog, usersWithACL, User, folder, $q) {
|
||||
var vm = this;
|
||||
|
||||
vm.users = usersWithACL; // ACL users
|
||||
vm.folder = folder;
|
||||
vm.selectedUser = null;
|
||||
vm.userToAdd = '';
|
||||
vm.searchText = '';
|
||||
vm.userFilter = userFilter;
|
||||
vm.closeModal = closeModal;
|
||||
vm.saveModal = saveModal;
|
||||
vm.confirmChange = confirmChange;
|
||||
vm.removeUser = removeUser;
|
||||
vm.addUser = addUser;
|
||||
vm.selectUser = selectUser;
|
||||
|
||||
function userFilter($query) {
|
||||
return User.$filter($query, folder.$acl.users);
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
folder.$acl.$resetUsersRights(); // cancel changes
|
||||
$mdDialog.hide();
|
||||
}
|
||||
|
||||
function saveModal() {
|
||||
folder.$acl.$saveUsersRights().then(function() {
|
||||
$mdDialog.hide();
|
||||
}, function(data, status) {
|
||||
Dialog.alert(l('Warning'), l('An error occured please try again.'));
|
||||
});
|
||||
}
|
||||
|
||||
function confirmChange(user) {
|
||||
var confirmation = user.$confirmRights();
|
||||
if (confirmation) {
|
||||
Dialog.confirm(l('Warning'), confirmation).catch(function() {
|
||||
user.$resetRights(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function removeUser(user) {
|
||||
folder.$acl.$removeUser(user.uid).then(function() {
|
||||
if (user.uid == vm.selectedUser.uid) {
|
||||
vm.selectedUser = null;
|
||||
}
|
||||
}, function(data, status) {
|
||||
Dialog.alert(l('Warning'), l('An error occured please try again.'))
|
||||
});
|
||||
}
|
||||
|
||||
function addUser(data) {
|
||||
if (data) {
|
||||
folder.$acl.$addUser(data).then(function() {
|
||||
vm.userToAdd = '';
|
||||
vm.searchText = '';
|
||||
}, function(error) {
|
||||
Dialog.alert(l('Warning'), error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function selectUser(user) {
|
||||
// Check if it is a different user
|
||||
if (vm.selectedUser != user) {
|
||||
vm.selectedUser = user;
|
||||
vm.selectedUser.$rights();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.unselectMessages = function() {
|
||||
_.each($rootScope.mailbox.$messages, function(message) { message.selected = false; });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user