Added ACL sharing capabilities for address books

This commit is contained in:
Ludovic Marcotte 2015-04-24 11:53:08 -04:00 committed by Francis Lachapelle
parent 77269e5cd6
commit 5e3b3e6987
4 changed files with 133 additions and 123 deletions

View file

@ -183,7 +183,8 @@
sg-escape="revertEditing(folder)"/> sg-escape="revertEditing(folder)"/>
</md-input-container> </md-input-container>
<md-button class="iconButton" label:aria-label="Options" <md-button class="iconButton" label:aria-label="Options"
ng-show="currentFolder.id==folder.id"> ng-show="currentFolder.id==folder.id"
ng-click="share()">
<i class="md-icon-more-vert"><!-- options --></i> <i class="md-icon-more-vert"><!-- options --></i>
</md-button> </md-button>
</md-list-item> </md-list-item>

View file

@ -6,44 +6,34 @@
xmlns:rsrc="OGo:url" xmlns:rsrc="OGo:url"
xmlns:label="OGo:label" xmlns:label="OGo:label"
xmlns:uix="OGo:uix"> xmlns:uix="OGo:uix">
<div class="addressbookUserRights"> <div class="addressbookUserRights" layout="column">
<ul>
<li> <md-checkbox name="canViewObjects"
<label> ng-model="selectedUser.rights.canViewObjects"
<input type="checkbox" name="canViewObjects" ng-change="confirmChange(selectedUser)" >
ng-checked="selectedUser.rights.canViewObjects" <var:string label:value="This person can read the cards of this addressbook." />
ng-model="selectedUser.rights.canViewObjects" </md-checkbox>
ng-change="confirmChange(selectedUser)" />
<var:string label:value="This person can read the cards of this addressbook." /> <md-checkbox name="canCreateObjects"
</label> ng-model="selectedUser.rights.canCreateObjects"
</li> ng-change="confirmChange(selectedUser)"
<li ng-hide="selectedUser.$isAnonymous()"> ng-hide="selectedUser.$isAnonymous()">
<label> <var:string label:value="This person can add cards to this addressbook." />
<input type="checkbox" name="canCreateObjects" </md-checkbox>
ng-checked="selectedUser.rights.canCreateObjects"
ng-model="selectedUser.rights.canCreateObjects" <md-checkbox name="canEditObjects"
ng-change="confirmChange(selectedUser)" /> ng-model="selectedUser.rights.canEditObjects"
<var:string label:value="This person can add cards to this addressbook." /> ng-change="confirmChange(selectedUser)"
</label> ng-hide="selectedUser.$isAnonymous()">
</li> <var:string label:value="This person can edit the cards of this addressbook." />
<li ng-hide="selectedUser.$isAnonymous()"> </md-checkbox>
<label>
<input type="checkbox" name="canEditObjects" <md-checkbox name="canEraseObjects"
ng-checked="selectedUser.rights.canEditObjects" ng-model="selectedUser.rights.canEraseObjects"
ng-model="selectedUser.rights.canEditObjects" ng-change="confirmChange(selectedUser)"
ng-change="confirmChange(selectedUser)" /> ng-hide="selectedUser.$isAnonymous()">
<var:string label:value="This person can edit the cards of this addressbook." />
</label>
</li>
<li ng-hide="selectedUser.$isAnonymous()">
<label>
<input type="checkbox" name="canEraseObjects"
ng-checked="selectedUser.rights.canEraseObjects"
ng-model="selectedUser.rights.canEraseObjects"
ng-change="confirmChange(selectedUser)" />
<var:string label:value="This person can erase cards from this addressbook." /> <var:string label:value="This person can erase cards from this addressbook." />
</label> </md-checkbox>
</li>
</ul> </div>
</div>
</container> </container>

View file

@ -5,70 +5,72 @@
xmlns:var="http://www.skyrix.com/od/binding" xmlns:var="http://www.skyrix.com/od/binding"
xmlns:const="http://www.skyrix.com/od/constant" xmlns:const="http://www.skyrix.com/od/constant"
xmlns:label="OGo:label" xmlns:label="OGo:label"
xmlns:uix="OGo:uix"><var:string var:value="doctype" const:escapeHTML="NO" /> xmlns:uix="OGo:uix">
<div id="modalACL"> <md-dialog>
<h2><var:string label:value="Access Rights"/> - <em>{{addressbook.name}}</em></h2> <md-content>
<ul> <md-subheader><var:string label:value="Access Rights"/> - {{stateAddressbook.name}}</md-subheader>
<!-- left side -->
<li> <md-list>
<ul class="aclUsers"> <md-list-item ng-repeat="user in users | orderBy:['userClass', 'displayName']">
<li ng-repeat="user in users | orderBy:['userClass', 'displayName']" <div layout="column">
ng-click="selectUser(user)" <div layout="row">
ng-class="{_selected: user==selectedUser}"> <md-button ng-click="selectUser(user)">
<span class="card-picture" ng-switch="user.userClass"> <div layout="row" layout-align="space-between center"
<i ng-switch-when="normal-user" class="icon-ion-ios7-person"><!-- normal-user --></i> layout-fill="true">
<i ng-switch-when="public-user" class="icon-ion-ios7-people"><!-- public-user --></i> <span class="card-picture" ng-switch="user.userClass">
</span> <div ng-switch-when="normal-user" class="sg-avatar"><!-- normal-user --></div>
<span class="name">{{user.$shortFormat()}}</span> <div ng-switch-when="public-user" class="sg-list-avatar"><!-- public-user --></div>
<span class="subscriptionArea" </span>
<span class="name">{{user.$shortFormat()}}</span>
</div>
</md-button>
<md-button
ng-click="removeUser(user)"
type="button"
layout="row" layout-align="end center"
ng-hide="user.$isSpecial()"> ng-hide="user.$isSpecial()">
<label> <div class="md-icon-delete"><!-- delete --></div>
<input type="checkbox" </md-button>
ng-model="user.isSubscribed" </div>
ng-checked="user.isSubscribed" <span id="AccessRightList" ng-show="user==selectedUser">
ng-disabled="user.wasSubscribed" /> <md-checkbox ng-model="user.isSubscribed"
<span><var:string label:value="Subscribe User"/></span> arial-label="Subscribe User"
</label> ng-disabled="user.wasSubscribed"
ng-true-value="1"
ng-false-value="0"
ng-hide="user.$isSpecial()">
<var:string label:value="Subscribe User"/>
</md-checkbox>
<div ng-include="'UIxUserRightsEditor'">
<!--
Load ng-template #UIxUserRightsEditor from main module wox. Inner wox templates are:
- UI/Templates/ContactsUI/UIxContactsUserRightsEditor.wox
- UI/Templates/MailerUI/UIxMailUserRightsEditor.wox
- UI/Templates/SchedulerUI/UIxCalUserRightsEditor.wox
--></div>
</span> </span>
</li> </div>
</ul> <md-divider><!-- divider --></md-divider>
<form class="addContactsToolbar" </md-list-item>
ng-submit="addUser(userToAdd)">
<table id="bottomTable"> <md-autocomplete
<tr> md-selected-item="userToAdd"
<td id="td_1"><i class="icon-ion-search"><!-- search --></i> md-search-text="searchText"
<input type="search" class="form-control" label:placeholder="email address" md-selected-item-change="addUser(user)"
ng-model="userToAdd" md-items="user in userFilter(searchText)"
typeahead-editable="false" md-item-text="user.shortFormat"
typeahead-wait-ms="500" md-min-length="0"
typeahead="user as user.$shortFormat() for user in userFilter($viewValue)"/> placeholder="Add">
</td> <span md-highlight-text="searchText" md-highlight-flags="^i">{{user.shortFormat}}</span>
<td id="td_2"> </md-autocomplete>
<button type="submit" ><var:string label:value="Add User" /></button>
<button type="button" </md-list>
ng-disabled="!selectedUser || selectedUser.$isSpecial()"
ng-click="removeUser(selectedUser)"><var:string label:value="Remove User"/></button> <div id="aclButtons">
</td> <md-button ng-click="closeModal()"><var:string label:value="Close"/></md-button>
</tr> <md-button ng-click="saveModal()"><var:string label:value="Save"/></md-button>
</table> </div>
</form> </md-content>
</li> </md-dialog>
<!-- right side -->
<li id="AccessRightList" ng-show="selectedUser">
<h1>{{selectedUser.$shortFormat({email: false})}}</h1>
<div ng-include="'UIxUserRightsEditor'">
<!--
Load ng-template #UIxUserRightsEditor from main module wox. Inner wox templates are:
- UI/Templates/ContactsUI/UIxContactsUserRightsEditor.wox
- UI/Templates/MailerUI/UIxMailUserRightsEditor.wox
- UI/Templates/SchedulerUI/UIxCalUserRightsEditor.wox
--></div>
</li>
</ul>
</div>
<div id="aclButtons">
<button ng-click="closeModal()"><var:string label:value="Close"/></button>
<button ng-click="saveModal()"><var:string label:value="Save"/></button>
</div>
<span class="close-reveal-modal" ng-click="closeModal()"><i class="icon-close"><!-- close --></i></span>
</container> </container>

View file

@ -103,7 +103,9 @@
$urlRouterProvider.otherwise('/addressbooks/personal'); $urlRouterProvider.otherwise('/addressbooks/personal');
}]) }])
.controller('AddressBooksCtrl', ['$scope', '$rootScope', '$state', '$stateParams', '$timeout', '$mdDialog', 'sgFocus', 'sgCard', 'sgAddressBook', 'sgDialog', 'sgSettings', 'stateAddressbooks', function($scope, $rootScope, $state, $stateParams, $timeout, $mdDialog, focus, Card, AddressBook, Dialog, Settings, stateAddressbooks) { .controller('AddressBooksCtrl', ['$state', '$scope', '$rootScope', '$stateParams', '$timeout', '$q', '$mdDialog', 'sgFocus', 'sgCard', 'sgAddressBook', 'sgDialog', 'sgSettings', 'sgUser', 'stateAddressbooks', function($state, $scope, $rootScope, $stateParams, $timeout, $q, $mdDialog, focus, Card, AddressBook, Dialog, Settings, User, stateAddressbooks) {
var currentAddressbook;
$scope.activeUser = Settings.activeUser; $scope.activeUser = Settings.activeUser;
$scope.service = AddressBook; $scope.service = AddressBook;
@ -214,23 +216,37 @@
window.location.href = ApplicationBaseURL + '/' + $rootScope.addressbook.id + '/exportFolder'; window.location.href = ApplicationBaseURL + '/' + $rootScope.addressbook.id + '/exportFolder';
}; };
$scope.share = function() { $scope.share = function() {
var modal = $modal.open({ $mdDialog.show({
templateUrl: stateAddressbook.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox templateUrl: $scope.currentFolder.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox
resolve: { controller: AddressBookACLController,
modalUsers: function() { clickOutsideToClose: true,
return stateAddressbook.$acl.$users(); escapeToClose: true,
} locals: {
}, usersWithACL: $scope.currentFolder.$acl.$users(),
controller: ['$scope', '$modalInstance', 'sgUser', 'modalUsers', function($scope, $modalInstance, User, modalUsers) { User: User,
$scope.users = modalUsers; // ACL users stateAddressbook: $scope.currentFolder,
$scope.userFilter = User.$filter; // Filter for typeahead q: $q
$scope.closeModal = function() { }
});
function AddressBookACLController($scope, $mdDialog, usersWithACL, User, stateAddressbook, q) {
$scope.users = usersWithACL; // ACL users
$scope.stateAddressbook = stateAddressbook;
$scope.userToAdd = '';
$scope.searchText = '';
$scope.userFilter = function($query) {
var deferred = q.defer();
User.$filter($query).then(function(results) {
deferred.resolve(results)
});
return deferred.promise;
};
$scope.closeModal = function() {
stateAddressbook.$acl.$resetUsersRights(); // cancel changes stateAddressbook.$acl.$resetUsersRights(); // cancel changes
$modalInstance.close(); $mdDialog.hide();
}; };
$scope.saveModal = function() { $scope.saveModal = function() {
stateAddressbook.$acl.$saveUsersRights().then(function() { stateAddressbook.$acl.$saveUsersRights().then(function() {
$modalInstance.close(); $mdDialog.hide();
}, function(data, status) { }, function(data, status) {
Dialog.alert(l('Warning'), l('An error occured please try again.')); Dialog.alert(l('Warning'), l('An error occured please try again.'));
}); });
@ -253,9 +269,11 @@
Dialog.alert(l('Warning'), l('An error occured please try again.')) Dialog.alert(l('Warning'), l('An error occured please try again.'))
}); });
}; };
$scope.addUser = function(data) { $scope.addUser = function(data) {
$scope.userToAdd = ''; stateAddressbook.$acl.$addUser(data).then(function() {
stateAddressbook.$acl.$addUser(data).catch(function(error) { $scope.userToAdd = '';
$scope.searchText = '';
}, function(error) {
Dialog.alert(l('Warning'), error); Dialog.alert(l('Warning'), error);
}); });
}; };
@ -266,8 +284,7 @@
$scope.selectedUser.$rights(); $scope.selectedUser.$rights();
} }
}; };
}] };
});
}; };
/** /**