mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-31 08:04:54 +00:00
(feat) added mailbox delegation support
This commit is contained in:
@@ -220,4 +220,48 @@
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $addDelegate
|
||||
* @memberof Account.prototype
|
||||
* @param {Object} user - a User object with minimal set of attributes (uid, isGroup, cn, c_email)
|
||||
* @desc Remove a user from the account's delegates
|
||||
* @see {@link User.$filter}
|
||||
*/
|
||||
Account.prototype.$addDelegate = function(user) {
|
||||
var _this = this,
|
||||
deferred = Account.$q.defer(),
|
||||
param = {uid: user.uid};
|
||||
if (!user.uid || _.indexOf(_.pluck(this.delegates, 'uid'), user.uid) > -1) {
|
||||
// No UID specified or user already in delegates
|
||||
deferred.resolve();
|
||||
}
|
||||
else {
|
||||
Account.$$resource.fetch(this.id.toString(), 'addDelegate', param).then(function() {
|
||||
_this.delegates.push(user);
|
||||
deferred.resolve(_this.users);
|
||||
}, function(data, status) {
|
||||
deferred.reject(l('An error occured please try again.'));
|
||||
});
|
||||
}
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $removeDelegate
|
||||
* @memberof Account.prototype
|
||||
* @param {Object} user - a User object with minimal set of attributes (uid, isGroup, cn, c_email)
|
||||
* @desc Remove a user from the account's delegates
|
||||
* @return a promise of the server call to remove the user from the account's delegates
|
||||
*/
|
||||
Account.prototype.$removeDelegate = function(uid) {
|
||||
var _this = this,
|
||||
param = {uid: uid};
|
||||
return Account.$$resource.fetch(this.id.toString(), 'removeDelegate', param).then(function() {
|
||||
var i = _.indexOf(_.pluck(_this.delegates, 'uid'), uid);
|
||||
if (i >= 0) {
|
||||
_this.delegates.splice(i, 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -24,6 +24,76 @@
|
||||
});
|
||||
});
|
||||
};
|
||||
$scope.delegate = function(account) {
|
||||
$mdDialog.show({
|
||||
templateUrl: account.id + '/delegation', // UI/Templates/MailerUI/UIxMailUserDelegation.wox
|
||||
controller: MailboxDelegationController,
|
||||
controllerAs: 'delegate',
|
||||
clickOutsideToClose: true,
|
||||
escapeToClose: true,
|
||||
locals: {
|
||||
User: User,
|
||||
account: account,
|
||||
$q: $q
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
MailboxDelegationController.$inject = ['$scope', '$mdDialog', 'User', 'account', '$q'];
|
||||
function MailboxDelegationController($scope, $mdDialog, User, account, $q) {
|
||||
var vm = this;
|
||||
|
||||
vm.users = account.delegates;
|
||||
vm.account = account;
|
||||
vm.selectedUser = null;
|
||||
vm.userToAdd = '';
|
||||
vm.searchText = '';
|
||||
vm.userFilter = userFilter;
|
||||
vm.closeModal = closeModal;
|
||||
vm.removeUser = removeUser;
|
||||
vm.addUser = addUser;
|
||||
vm.selectUser = selectUser;
|
||||
|
||||
function userFilter($query) {
|
||||
//return User.$filter($query, folder.$acl.users);
|
||||
return User.$filter($query, account.delegates);
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
$mdDialog.hide();
|
||||
}
|
||||
|
||||
function removeUser(user) {
|
||||
account.$removeDelegate(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) {
|
||||
account.$addDelegate(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.editFolder = function(folder) {
|
||||
$scope.editMode = folder.path;
|
||||
focus('mailboxName_' + folder.path);
|
||||
|
||||
Reference in New Issue
Block a user