dont allow save if the user doesn't have save permissions

This commit is contained in:
Mads Rasmussen
2022-05-12 18:01:17 +02:00
parent 3f0ff6a752
commit 84108bbea2
3 changed files with 19 additions and 8 deletions

View File

@@ -319,6 +319,7 @@
<key alias="createEmpty">Create new</key>
<key alias="createFromClipboard">Paste from clipboard</key>
<key alias="nodeIsInTrash">This item is in the Recycle Bin</key>
<key alias="variantSaveNotAllowed">Save is not allowed</key>
</area>
<area alias="blueprints">
<key alias="createBlueprintFrom"><![CDATA[Create a new Content Template from <em>%0%</em>]]></key>

View File

@@ -17,11 +17,17 @@
$scope.model.disableSubmitButton = !firstSelected; //disable submit button if there is none selected
}
function allowUpdate (variant) {
return variant.allowedActions.includes("A");
}
function saveableVariantFilter(variant) {
//determine a variant is 'dirty' (meaning it will show up as save-able) if it's
// * the active one
// * it's editor is in a $dirty state
return (variant.active || variant.isDirty);
// the editor has update permissions for the variant
variant.notAllowed = allowUpdate(variant) === false && variant.active;
return ((variant.active || variant.isDirty) && (allowUpdate(variant) || variant.active));
}
function isMandatoryFilter(variant) {
@@ -72,7 +78,7 @@
variant.save = variant.publish = false;
variant.isMandatory = isMandatoryFilter(variant);
if(vm.isNew && hasAnyData(variant)){
if(vm.isNew && hasAnyData(variant) && allowUpdate(variant)) {
variant.save = true;
}
});
@@ -81,7 +87,7 @@
//ensure that the current one is selected
var active = vm.variants.find(v => v.active);
if (active) {
if (active && allowUpdate(active)) {
active.save = true;
}
@@ -97,10 +103,11 @@
onInit();
//when this dialog is closed, reset all 'save' flags
//when this dialog is closed, reset all 'save' and 'notAllowed' flags
$scope.$on('$destroy', () => {
vm.variants.forEach(variant => {
variant.save = false;
variant.notAllowed = false;
});
});

View File

@@ -24,9 +24,8 @@
name="saveVariantSelector"
model="variant.save"
on-change="vm.changeSelection(variant)"
server-validation-field="{{variant.htmlId}}">
server-validation-field="{{variant.htmlId}}"
disabled="variant.notAllowed">
<span class="umb-variant-selector-entry__title" ng-if="!(variant.segment && variant.language)">
<span ng-bind="variant.displayName"></span>
@@ -40,6 +39,10 @@
<umb-variant-state variant="variant"></umb-variant-state>
<span ng-if="variant.isMandatory"> - </span>
<span ng-if="variant.isMandatory"><localize key="general_mandatory">Mandatory</localize></span>
<span ng-if="variant.notAllowed"> - </span>
<span ng-if="variant.notAllowed" class="text-error">
<localize key="content_variantSaveNotAllowed"></localize>
</span>
</span>
<span class="umb-variant-selector-entry__description" ng-messages="saveVariantSelectorForm.saveVariantSelector.$error" show-validation-on-submit>
<span class="text-warning" ng-message="valServerField">{{saveVariantSelectorForm.saveVariantSelector.errorMsg}}</span>