check for unpublish permission

This commit is contained in:
Mads Rasmussen
2022-05-12 18:07:00 +02:00
parent dae338b4e8
commit 87811bd3b3
3 changed files with 14 additions and 3 deletions

View File

@@ -323,6 +323,7 @@
<key alias="variantPublishNotAllowed">Publish is not allowed</key>
<key alias="variantSendForApprovalNotAllowed">Send for approval is not allowed</key>
<key alias="variantScheduleNotAllowed">Schedule is not allowed</key>
<key alias="variantUnpublishNotAllowed">Unpublish is not allowed</key>
</area>
<area alias="blueprints">
<key alias="createBlueprintFrom"><![CDATA[Create a new Content Template from <em>%0%</em>]]></key>

View File

@@ -34,7 +34,7 @@
var active = vm.variants.find(v => v.active);
if (active && publishedVariantFilter(active)) {
if (active && publishedVariantFilter(active) && allowUnpublish(active)) {
//ensure that the current one is selected
active.save = true;
}
@@ -45,6 +45,10 @@
}
function allowUnpublish (variant) {
return variant.allowedActions.includes("Z");
}
function changeSelection(selectedVariant) {
// if a mandatory variant is selected we want to select all other variants, we cant have anything published if a mandatory variants gets unpublished.
@@ -101,13 +105,15 @@
//determine a variant is 'published' (meaning it will show up as able unpublish)
// * it has been published
// * it has been published with pending changes
return (variant.state === "Published" || variant.state === "PublishedPendingChanges");
variant.notAllowed = allowUnpublish(variant) === false && variant.active;
return (variant.state === "Published" || variant.state === "PublishedPendingChanges") && (allowUnpublish(variant) || variant.active);
}
//when this dialog is closed, remove all unpublish and disabled flags
$scope.$on('$destroy', () => {
vm.variants.forEach(variant => {
variant.save = variant.disabled = false;
variant.notAllowed = false;
});
});

View File

@@ -21,7 +21,7 @@
name="unpublishVariantSelector"
model="variant.save"
on-change="vm.changeSelection(variant)"
disabled="variant.disabled"
disabled="variant.disabled || variant.notAllowed"
server-validation-field="{{variant.htmlId}}">
<span class="umb-variant-selector-entry__title" ng-if="!(variant.segment && variant.language)">
@@ -37,6 +37,10 @@
<umb-variant-state variant="variant"></umb-variant-state>
<span ng-if="variant.isMandatory"> - </span>
<span ng-if="variant.isMandatory" ng-class="{'text-error': (variant.publish === false) }"><localize key="general_mandatory">Mandatory</localize></span>
<span ng-if="variant.notAllowed"> - </span>
<span ng-if="variant.notAllowed" class="text-error">
<localize key="content_variantUnpublishNotAllowed"></localize>
</span>
</span>
<span class="umb-variant-selector-entry__description" ng-messages="publishVariantSelectorForm.publishVariantSelector.$error" show-validation-on-submit>
<span class="text-error" ng-message="valServerField">{{publishVariantSelectorForm.publishVariantSelector.errorMsg}}</span>