From fb992db5ad3fc5927eea5fb3681784f6d73d2433 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 2 Jun 2015 11:14:03 -0400 Subject: [PATCH] Improve ACL editor (Scheduler & Contacts) --- UI/Common/UIxAclEditor.m | 2 +- UI/Common/UIxUserRightsEditor.m | 21 +++-- UI/Scheduler/UIxCalUserRightsEditor.h | 10 +-- UI/Scheduler/UIxCalUserRightsEditor.m | 64 ++------------- .../UIxContactsUserRightsEditor.wox | 22 ++--- .../SchedulerUI/UIxCalUserRightsEditor.wox | 50 ++++++----- UI/Templates/UIxAclEditor.wox | 5 +- .../js/Common/User.service.js | 5 +- .../js/Contacts/AddressBooksController.js | 6 +- .../js/Scheduler/CalendarsController.js | 82 +++++++++++-------- .../scss/components/card/card.scss | 6 +- 11 files changed, 120 insertions(+), 153 deletions(-) diff --git a/UI/Common/UIxAclEditor.m b/UI/Common/UIxAclEditor.m index e30b03abe..a934ec30e 100644 --- a/UI/Common/UIxAclEditor.m +++ b/UI/Common/UIxAclEditor.m @@ -84,7 +84,7 @@ } /** - * @api {get} /so/:username/:folderPath/acls Get ACLs + * @api {get} /so/:username/:folderPath/acls List users with rights * @apiVersion 1.0.0 * @apiName GetAcls * @apiGroup Common diff --git a/UI/Common/UIxUserRightsEditor.m b/UI/Common/UIxUserRightsEditor.m index 0fccd5739..8249b9bb9 100644 --- a/UI/Common/UIxUserRightsEditor.m +++ b/UI/Common/UIxUserRightsEditor.m @@ -184,19 +184,22 @@ } /** - * @api {get} /so/:username/:folderPath/acls Get ACLs + * @api {get} /so/:username/:folderPath/userRights?uid=:uid Get user's rights * @apiVersion 1.0.0 - * @apiName GetAcls + * @apiName GetUserRights * @apiGroup Common * @apiExample {curl} Example usage: - * curl -i http://localhost/SOGo/so/sogo1/Calendar/personal/acls + * curl -i http://localhost/SOGo/so/sogo1/Calendar/personal/userRights?uid=sogo2 * - * @apiSuccess (Success 200) {Object[]} users List of users with ACL for the folder - * @apiSuccess (Success 200) {String} users.uid User ID - * @apiSuccess (Success 200) {String} users.userClass Either 'normal-user', 'normal-group' or 'public-access' - * @apiSuccess (Success 200) {Number} users.isSubscribed 1 if the user is subscribed to the folder - * @apiSuccess (Success 200) {String} [users.cn] User fullname - * @apiSuccess (Success 200) {String} [users.c_email] User main email address + * @apiSuccess (Success 200) {String} [Public] Calendar: either None, DAndTViewer, Viewer, Responder, or Modifier + * @apiSuccess (Success 200) {String} [Confidential] Calendar: either None, DAndTViewer, Viewer, Responder, or Modifier + * @apiSuccess (Success 200) {Number} [Private] Calendar: either None, DAndTViewer, Viewer, Responder, or Modifier + * @apiSuccess (Success 200) {Number} [canCreateObjects] Calendar: can create events and tasks + * @apiSuccess (Success 200) {Number} [canEraseObjects] Calendar: can erase events and tasks + * @apiSuccess (Success 200) {Number} [canCreateObjects] Address Book: can create cards + * @apiSuccess (Success 200) {Number} [canEraseObjects] Address Book: can erase cards + * @apiSuccess (Success 200) {Number} [canViewObjects] Address Book: can view cards + * @apiSuccess (Success 200) {Number} [canEditObjects] Address Book: can modify cards */ - (id ) userRightsAction { diff --git a/UI/Scheduler/UIxCalUserRightsEditor.h b/UI/Scheduler/UIxCalUserRightsEditor.h index 9a38f757c..2a655ad5f 100644 --- a/UI/Scheduler/UIxCalUserRightsEditor.h +++ b/UI/Scheduler/UIxCalUserRightsEditor.h @@ -1,8 +1,6 @@ /* UIxCalUserRightsEditor.h - this file is part of SOGo * - * Copyright (C) 2007 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2007-2015 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +30,6 @@ @interface UIxCalUserRightsEditor : UIxUserRightsEditor { NSString *currentRight; - NSString *currentRightType; NSMutableDictionary *rights; } @@ -41,11 +38,6 @@ - (NSString *) currentRight; - (NSArray *) rightTypes; -- (void) setCurrentRightType: (NSString *) newCurrentRightType; -- (NSString *) currentRightType; -- (NSString *) currentRightTypeLabel; -- (NSString *) currentRightTypeName; -- (NSString *) currentRightSelection; - (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects; - (BOOL) userCanCreateObjects; diff --git a/UI/Scheduler/UIxCalUserRightsEditor.m b/UI/Scheduler/UIxCalUserRightsEditor.m index 33fa93b4a..097329003 100644 --- a/UI/Scheduler/UIxCalUserRightsEditor.m +++ b/UI/Scheduler/UIxCalUserRightsEditor.m @@ -1,8 +1,6 @@ /* UIxCalUserRightsEditor.m - this file is part of SOGo * - * Copyright (C) 2007-2010 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2007-2015 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,7 +34,6 @@ if ((self = [super init])) { currentRight = nil; - currentRightType = nil; rights = [NSMutableDictionary new]; [rights setObject: @"None" forKey: @"Public"]; [rights setObject: @"None" forKey: @"Private"]; @@ -49,7 +46,6 @@ - (void) dealloc { [currentRight release]; - [currentRightType release]; [rights release]; [super dealloc]; } @@ -95,6 +91,9 @@ return rightsForType; } +/** + * @see [UIxUserRightsEditor userRightsAction] + */ - (NSDictionary *) userRightsForObject { NSMutableDictionary *d; @@ -111,6 +110,9 @@ return d; } +/** + * @see [UIxUserRightsEditor saveUserRightsAction] + */ - (void) updateRights: (NSDictionary *) newRights { NSEnumerator *types; @@ -163,62 +165,10 @@ return currentRight; } -- (NSArray *) rightTypes -{ - return - [NSArray arrayWithObjects: @"Public", @"Confidential", @"Private", nil]; -} - -- (void) setCurrentRightType: (NSString *) newCurrentRightType -{ - ASSIGN (currentRightType, newCurrentRightType); -} - -- (NSString *) currentRightType -{ - return currentRightType; -} - - (NSString *) currentRightLabel { return [self labelForKey: [NSString stringWithFormat: @"label_%@", currentRight]]; } -- (NSString *) currentRightTypeLabel -{ - return [self labelForKey: - [NSString stringWithFormat: @"label_%@", currentRightType]]; -} - -- (NSString *) currentRightTypeName -{ - return [NSString stringWithFormat: @"%@Right", currentRightType]; -} - -- (NSString *) currentRightSelection -{ - return [rights objectForKey: currentRightType]; -} - -- (void) setUserCanCreateObjects: (BOOL) userCanCreateObjects -{ - [self appendRight: SOGoRole_ObjectCreator]; -} - -- (BOOL) userCanCreateObjects -{ - return [userRights containsObject: SOGoRole_ObjectCreator]; -} - -- (void) setUserCanEraseObjects: (BOOL) userCanEraseObjects -{ - [self appendRight: SOGoRole_ObjectEraser]; -} - -- (BOOL) userCanEraseObjects -{ - return [userRights containsObject: SOGoRole_ObjectEraser]; -} - @end diff --git a/UI/Templates/ContactsUI/UIxContactsUserRightsEditor.wox b/UI/Templates/ContactsUI/UIxContactsUserRightsEditor.wox index e79d0c8e3..d2b4d3253 100644 --- a/UI/Templates/ContactsUI/UIxContactsUserRightsEditor.wox +++ b/UI/Templates/ContactsUI/UIxContactsUserRightsEditor.wox @@ -9,35 +9,35 @@
diff --git a/UI/Templates/SchedulerUI/UIxCalUserRightsEditor.wox b/UI/Templates/SchedulerUI/UIxCalUserRightsEditor.wox index bb73fbdc6..4fba8fb60 100644 --- a/UI/Templates/SchedulerUI/UIxCalUserRightsEditor.wox +++ b/UI/Templates/SchedulerUI/UIxCalUserRightsEditor.wox @@ -11,20 +11,13 @@ const:toolbar="none" const:popup="YES"> -
- +
+
- - + + @@ -34,8 +27,10 @@
- - + + @@ -45,8 +40,10 @@
- - + + @@ -56,24 +53,25 @@
+ ng-false-value="0" + label:aria-label="This person can create objects in my calendar."> + ng-false-value="0" + label:aria-label="This person can erase objects from my calendar.">
- diff --git a/UI/Templates/UIxAclEditor.wox b/UI/Templates/UIxAclEditor.wox index 25b4ea435..ad1fb038f 100644 --- a/UI/Templates/UIxAclEditor.wox +++ b/UI/Templates/UIxAclEditor.wox @@ -53,13 +53,14 @@
+ label:md-floating-label="Add User"> {{user.c_email}} - +
diff --git a/UI/WebServerResources/js/Common/User.service.js b/UI/WebServerResources/js/Common/User.service.js index 64015596e..159ce5f90 100644 --- a/UI/WebServerResources/js/Common/User.service.js +++ b/UI/WebServerResources/js/Common/User.service.js @@ -225,7 +225,10 @@ if (zero) { // Disable all rights _.map(_.keys(this.rights), function(key) { - _this.rights[key] = 0; + if (angular.isString(_this.rights[key])) + _this.rights[key] = 'None'; + else + _this.rights[key] = 0; }); } else { diff --git a/UI/WebServerResources/js/Contacts/AddressBooksController.js b/UI/WebServerResources/js/Contacts/AddressBooksController.js index 7416b4247..2c7708d1b 100644 --- a/UI/WebServerResources/js/Contacts/AddressBooksController.js +++ b/UI/WebServerResources/js/Contacts/AddressBooksController.js @@ -141,6 +141,7 @@ vm.users = usersWithACL; // ACL users vm.folder = folder; + vm.selectedUser = null; vm.userToAdd = ''; vm.searchText = ''; vm.userFilter = userFilter; @@ -171,9 +172,8 @@ function confirmChange(user) { var confirmation = user.$confirmRights(); if (confirmation) { - Dialog.confirm(l('Warning'), confirmation).then(function(res) { - if (!res) - user.$resetRights(true); + Dialog.confirm(l('Warning'), confirmation).catch(function() { + user.$resetRights(true); }); } } diff --git a/UI/WebServerResources/js/Scheduler/CalendarsController.js b/UI/WebServerResources/js/Scheduler/CalendarsController.js index 15b234ce3..6eeb8141f 100644 --- a/UI/WebServerResources/js/Scheduler/CalendarsController.js +++ b/UI/WebServerResources/js/Scheduler/CalendarsController.js @@ -95,6 +95,7 @@ $mdDialog.show({ templateUrl: calendar.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox controller: CalendarACLController, + controllerAs: 'acl', clickOutsideToClose: true, escapeToClose: true, locals: { @@ -106,59 +107,74 @@ /** * @ngInject */ - CalendarACLController.$inject = ['$scope', '$mdDialog', 'usersWithACL', 'User', 'folder']; - function CalendarACLController($scope, $mdDialog, usersWithACL, User, folder) { - $scope.users = usersWithACL; // ACL users - $scope.folder = folder; - $scope.selectedUser = null; - $scope.userToAdd = ''; - $scope.searchText = ''; - $scope.userFilter = function($query) { - return User.$filter($query); - }; - $scope.closeModal = function() { + CalendarACLController.$inject = ['$mdDialog', 'usersWithACL', 'User', 'folder']; + function CalendarACLController($mdDialog, usersWithACL, User, folder) { + 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(); - }; - $scope.saveModal = function() { + } + + function saveModal() { folder.$acl.$saveUsersRights().then(function() { $mdDialog.hide(); }, function(data, status) { Dialog.alert(l('Warning'), l('An error occured please try again.')); }); - }; - $scope.confirmChange = function(user) { + } + + function confirmChange(user) { var confirmation = user.$confirmRights(); if (confirmation) { - Dialog.confirm(l('Warning'), confirmation).then(function(res) { - if (!res) - user.$resetRights(true); + Dialog.confirm(l('Warning'), confirmation).catch(function() { + user.$resetRights(true); }); } - }; - $scope.removeUser = function(user) { + } + + function removeUser(user) { folder.$acl.$removeUser(user.uid).then(function() { - if (user.uid == $scope.selectedUser.uid) - $scope.selectedUser = null; + if (user.uid == vm.selectedUser.uid) + vm.selectedUser = null; }, function(data, status) { Dialog.alert(l('Warning'), l('An error occured please try again.')) }); - }; - $scope.addUser = function(data) { + } + + function addUser(data) { if (data) { folder.$acl.$addUser(data).then(function() { - $scope.userToAdd = ''; - $scope.searchText = ''; + vm.userToAdd = ''; + vm.searchText = ''; }, function(error) { Dialog.alert(l('Warning'), error); }); } - }; - $scope.selectUser = function(user) { + } + + function selectUser(user) { // Check if it is a different user - if ($scope.selectedUser != user) { - $scope.selectedUser = user; - $scope.selectedUser.$rights(); + if (vm.selectedUser != user) { + vm.selectedUser = user; + vm.selectedUser.$rights(); } }; }; @@ -174,6 +190,6 @@ } angular - .module('SOGo.SchedulerUI') - .controller('CalendarsController', CalendarsController); + .module('SOGo.SchedulerUI') + .controller('CalendarsController', CalendarsController); })(); diff --git a/UI/WebServerResources/scss/components/card/card.scss b/UI/WebServerResources/scss/components/card/card.scss index 3414f2a2e..fe7526d3c 100644 --- a/UI/WebServerResources/scss/components/card/card.scss +++ b/UI/WebServerResources/scss/components/card/card.scss @@ -14,8 +14,12 @@ md-card { } &.sg-collapsed { + border-radius: 0; margin-top: 0; - margin-bottom: 1px; + margin-bottom: 0; + > .md-button { + margin: 0; + } } &.sg-expanded {