2015-07-28 16:53:29 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
|
|
|
AclController.$inject = ['$mdDialog', 'Dialog', 'usersWithACL', 'User', 'folder'];
|
|
|
|
function AclController($mdDialog, Dialog, usersWithACL, User, folder) {
|
|
|
|
var vm = this;
|
|
|
|
|
|
|
|
vm.users = usersWithACL; // ACL users
|
|
|
|
vm.folder = folder;
|
|
|
|
vm.selectedUser = null;
|
2015-10-09 22:49:08 +02:00
|
|
|
vm.selectedUid = null;
|
2015-07-28 16:53:29 +02:00
|
|
|
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;
|
2015-08-06 02:23:11 +02:00
|
|
|
vm.confirmation = { showing: false,
|
|
|
|
message: ''};
|
2015-07-28 16:53:29 +02:00
|
|
|
|
|
|
|
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) {
|
2015-08-06 02:23:11 +02:00
|
|
|
vm.confirmation.showing = true;
|
|
|
|
vm.confirmation.message = confirmation;
|
2015-07-28 16:53:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeUser(user) {
|
2015-08-03 22:17:02 +02:00
|
|
|
folder.$acl.$removeUser(user.uid).catch(function(data, status) {
|
2015-07-28 16:53:29 +02:00
|
|
|
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) {
|
2015-10-09 22:49:08 +02:00
|
|
|
if (vm.selectedUid == user.uid) {
|
|
|
|
vm.selectedUid = null;
|
2015-08-03 20:44:11 +02:00
|
|
|
}
|
|
|
|
else {
|
2015-10-09 22:49:08 +02:00
|
|
|
vm.selectedUid = user.uid;
|
2015-07-28 16:53:29 +02:00
|
|
|
vm.selectedUser = user;
|
|
|
|
vm.selectedUser.$rights();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-07 17:02:34 +02:00
|
|
|
angular
|
|
|
|
.module('SOGo.Common')
|
|
|
|
.controller('AclController', AclController);
|
2015-07-28 16:53:29 +02:00
|
|
|
})();
|