Gets content permissions saving per user group

This commit is contained in:
Shannon
2017-06-29 19:15:04 +10:00
parent 5dec4a4a94
commit 4f28cb1917
15 changed files with 175 additions and 43 deletions

View File

@@ -40,7 +40,24 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
return {
savePermissions: function (saveModel) {
if (!saveModel) {
throw "saveModel cannot be null";
}
if (!saveModel.contentId) {
throw "saveModel.contentId cannot be null";
}
if (!saveModel.permissions) {
throw "saveModel.permissions cannot be null";
}
return umbRequestHelper.resourcePromise(
$http.post(umbRequestHelper.getApiUrl("contentApiBaseUrl", "PostSaveUserGroupPermissions"),
saveModel),
'Failed to save permissions');
},
getRecycleBin: function () {
return umbRequestHelper.resourcePromise(

View File

@@ -36,7 +36,7 @@
"PostSaveUserGroup"),
formattedSaveData),
"Failed to save user group");
}
}
function getUserGroup(id) {

View File

@@ -13,6 +13,7 @@
vm.setViewSate = setViewSate;
vm.editPermissions = editPermissions;
vm.setPermissions = setPermissions;
vm.save = save;
vm.removePermissions = removePermissions;
vm.cancelManagePermissions = cancelManagePermissions;
@@ -35,7 +36,7 @@
function setPermissions(group) {
// clear allowed permissions before we make the list
// so we don't have deplicates
// so we don't have duplicates
group.allowedPermissions = [];
// get list of checked permissions
@@ -67,6 +68,27 @@
setViewSate("manageGroups");
}
function save() {
//this is a dictionary that we need to format
var permissionsSave = {};
angular.forEach(vm.selectedUserGroups, function(g) {
permissionsSave[g.id] = [];
angular.forEach(g.allowedPermissions, function(p) {
permissionsSave[g.id].push(p.permissionCode);
});
});
var saveModel = {
contentId: $scope.currentNode.id,
permissions: permissionsSave
};
contentResource.savePermissions(saveModel).then(function() {
alert("hooray!");
});
}
onInit();
}

View File

@@ -43,7 +43,7 @@
<a class="btn btn-link" ng-click="nav.hideDialog()" ng-if="!busy">
<localize key="general_cancel">Cancel</localize>
</a>
<button class="btn btn-primary" ng-click="save()" ng-disabled="busy">
<button class="btn btn-primary" ng-click="vm.save()" ng-disabled="busy">
<localize key="buttons_save">Save</localize>
</button>
</div>