Do not allow editing read-only properties by clicking their labels (#18152)

* Do not allow editing read-only properties by clicking their labels

* Simplify the fix :)

* Fix linting issue
This commit is contained in:
Kenn Jacobsen
2025-01-29 10:29:58 +01:00
committed by GitHub
parent f54b6033ab
commit 59a4649528
4 changed files with 15 additions and 8 deletions

View File

@@ -218,6 +218,10 @@
return !canEditCulture || !canEditSegment;
}
$scope.isPreview = function(property) {
return ((property.readonly || !$scope.allowUpdate) && !property.supportsReadOnly) || ($scope.propertyEditorDisabled(property) && $scope.allowUpdate);
}
}
var directive = {

View File

@@ -25,11 +25,12 @@
propertyAlias: "@",
showInherit: "<",
inheritsFrom: "<",
hideLabel: "<?"
hideLabel: "<?",
preview: "<?"
}
});
function UmbPropertyController($scope, userService, serverValidationManager, udiService, angularHelper) {
@@ -55,7 +56,7 @@
// returns the validation path for the property to be used as the validation key for server side validation logic
vm.getValidationPath = function () {
var parentValidationPath = vm.parentUmbProperty ? vm.parentUmbProperty.getValidationPath() : null;
var parentValidationPath = vm.parentUmbProperty ? vm.parentUmbProperty.getValidationPath() : null;
var propAlias = vm.propertyAlias ? vm.propertyAlias : vm.property.alias;
// the elementKey will be empty when this is not a nested property
var valPath = vm.elementKey ? vm.elementKey + "/" + propAlias : propAlias;

View File

@@ -15,12 +15,13 @@
property="property"
node="contentNodeModel"
show-inherit="contentNodeModel.variants.length > 1 && property.variation !== 'CultureAndSegment'"
inherits-from="defaultVariant.displayName">
inherits-from="defaultVariant.displayName"
preview="isPreview(property)">
<umb-property-editor
model="property"
node="contentNodeModel"
preview="((property.readonly || !allowUpdate) && !property.supportsReadOnly) || (propertyEditorDisabled(property) && allowUpdate)"
preview="isPreview(property)"
allow-unlock="!property.readonly && allowUpdate && allowEditInvariantFromNonDefault"
on-unlock="unlockInvariantValue(property)"
ng-attr-readonly="{{property.readonly || !allowUpdate || undefined}}">
@@ -49,12 +50,13 @@
property="property"
node="contentNodeModel"
show-inherit="contentNodeModel.variants.length > 1 && property.variation !== 'CultureAndSegment'"
inherits-from="defaultVariant.displayName">
inherits-from="defaultVariant.displayName"
preview="isPreview(property)">
<umb-property-editor
model="property"
node="contentNodeModel"
preview="((property.readonly || !allowUpdate) && !property.supportsReadOnly) || (propertyEditorDisabled(property) && allowUpdate)"
preview="isPreview(property)"
allow-unlock="!property.readonly && allowUpdate && allowEditInvariantFromNonDefault"
on-unlock="unlockInvariantValue(property)"
ng-attr-readonly="{{property.readonly || !allowUpdate || undefined}}">

View File

@@ -9,7 +9,7 @@
<div class="control-header" ng-hide="(vm.hideLabel || vm.property.hideLabel) === true">
<label data-element="property-label-{{vm.property.alias}}" class="control-label" for="{{vm.property.alias}}" ng-attr-title="{{vm.controlLabelTitle}}" aria-label="Property alias: {{vm.controlAriaLabel}}">{{vm.property.label}}<span ng-if="vm.property.validation.mandatory || vm.property.ncMandatory"><strong class="umb-control-required">*</strong></span></label>
<label data-element="property-label-{{vm.property.alias}}" class="control-label" for="{{vm.preview ? undefined : vm.property.alias}}" ng-attr-title="{{vm.controlLabelTitle}}" aria-label="Property alias: {{vm.controlAriaLabel}}">{{vm.property.label}}<span ng-if="vm.property.validation.mandatory || vm.property.ncMandatory"><strong class="umb-control-required">*</strong></span></label>
<umb-property-actions actions="vm.propertyActions"></umb-property-actions>