mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
Simplify adding READ+WRITE ACL
This commit is contained in:
parent
e3962c4e3f
commit
451d913442
@ -151,7 +151,6 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* File has been drag & dropped.
|
* File has been drag & dropped.
|
||||||
* @param files
|
|
||||||
*/
|
*/
|
||||||
$scope.fileDropped = function(files) {
|
$scope.fileDropped = function(files) {
|
||||||
if (!$scope.document.writable) {
|
if (!$scope.document.writable) {
|
||||||
@ -186,8 +185,6 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload a file.
|
* Upload a file.
|
||||||
* @param file
|
|
||||||
* @param newfile
|
|
||||||
*/
|
*/
|
||||||
$scope.uploadFile = function(file, newfile) {
|
$scope.uploadFile = function(file, newfile) {
|
||||||
// Upload the file
|
// Upload the file
|
||||||
@ -210,7 +207,6 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an ACL.
|
* Delete an ACL.
|
||||||
* @param acl
|
|
||||||
*/
|
*/
|
||||||
$scope.deleteAcl = function(acl) {
|
$scope.deleteAcl = function(acl) {
|
||||||
Restangular.one('acl/' + $stateParams.id + '/' + acl.perm + '/' + acl.id, null).remove().then(function () {
|
Restangular.one('acl/' + $stateParams.id + '/' + acl.perm + '/' + acl.id, null).remove().then(function () {
|
||||||
@ -224,17 +220,45 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
|
|||||||
* Add an ACL.
|
* Add an ACL.
|
||||||
*/
|
*/
|
||||||
$scope.addAcl = function() {
|
$scope.addAcl = function() {
|
||||||
|
// Compute ACLs to add
|
||||||
$scope.acl.source = $stateParams.id;
|
$scope.acl.source = $stateParams.id;
|
||||||
Restangular.one('acl').put($scope.acl).then(function(acl) {
|
var acls = [];
|
||||||
$scope.acl = { perm: 'READ' };
|
if ($scope.acl.perm == 'READWRITE') {
|
||||||
if (_.isUndefined(acl.id)) {
|
acls = [{
|
||||||
return;
|
source: $stateParams.id,
|
||||||
}
|
username: $scope.acl.username,
|
||||||
$scope.document.acls.push(acl);
|
perm: 'READ'
|
||||||
$scope.document.acls = angular.copy($scope.document.acls);
|
}, {
|
||||||
|
source: $stateParams.id,
|
||||||
|
username: $scope.acl.username,
|
||||||
|
perm: 'WRITE'
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
acls = [{
|
||||||
|
source: $stateParams.id,
|
||||||
|
username: $scope.acl.username,
|
||||||
|
perm: $scope.acl.perm
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add ACLs
|
||||||
|
_.each(acls, function(acl) {
|
||||||
|
Restangular.one('acl').put(acl).then(function(acl) {
|
||||||
|
if (_.isUndefined(acl.id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$scope.document.acls.push(acl);
|
||||||
|
$scope.document.acls = angular.copy($scope.document.acls);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Reset form
|
||||||
|
$scope.acl = { perm: 'READ' };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-complete on ACL target.
|
||||||
|
*/
|
||||||
$scope.getTargetAclTypeahead = function($viewValue) {
|
$scope.getTargetAclTypeahead = function($viewValue) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
Restangular.one('acl/target/search')
|
Restangular.one('acl/target/search')
|
||||||
|
@ -118,8 +118,8 @@
|
|||||||
<label class=" col-sm-2 control-label" for="inputPermission">Permission</label>
|
<label class=" col-sm-2 control-label" for="inputPermission">Permission</label>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<select class="form-control" ng-model="acl.perm" id="inputPermission">
|
<select class="form-control" ng-model="acl.perm" id="inputPermission">
|
||||||
<option value="READ">Read</option>
|
<option value="READ">Can read</option>
|
||||||
<option value="WRITE">Write</option>
|
<option value="READWRITE">Can edit</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user