add readonly mode to multi url picker property editor

This commit is contained in:
Mads Rasmussen
2022-05-02 11:18:10 +02:00
parent b459ee4053
commit b40fcd3fe3
2 changed files with 14 additions and 4 deletions

View File

@@ -6,6 +6,10 @@ function multiUrlPickerController($scope, localizationService, entityResource, i
}
};
$scope.allowAdd = !$scope.readonly;
$scope.allowEdit = !$scope.readonly;
$scope.allowRemove = !$scope.readonly;
$scope.renderModel = [];
if ($scope.preview) {
@@ -24,6 +28,7 @@ function multiUrlPickerController($scope, localizationService, entityResource, i
tolerance: "pointer",
scroll: true,
zIndex: 6000,
disabled: $scope.readonly,
update: function () {
setDirty();
}
@@ -57,19 +62,23 @@ function multiUrlPickerController($scope, localizationService, entityResource, i
else {
$scope.multiUrlPickerForm.maxCount.$setValidity("maxCount", true);
}
$scope.sortableOptions.disabled = $scope.renderModel.length === 1;
$scope.sortableOptions.disabled = $scope.renderModel.length === 1 || $scope.readonly;
//Update value
$scope.model.value = $scope.renderModel;
}
);
$scope.remove = function ($index) {
if (!$scope.allowRemove) return;
$scope.renderModel.splice($index, 1);
setDirty();
};
$scope.openLinkPicker = function (link, $index) {
if (!$scope.allowAdd || !$scope.allowEdit) return;
var target = link ? {
name: link.name,
anchor: link.queryString,

View File

@@ -10,8 +10,8 @@
published="link.published"
description="link.url + (link.queryString ? link.queryString : '')"
sortable="!sortableOptions.disabled"
allow-remove="true"
allow-edit="true"
allow-remove="allowRemove"
allow-edit="allowEdit"
on-remove="remove($index)"
on-edit="openLinkPicker(link, $index)">
</umb-node-preview>
@@ -20,7 +20,8 @@
<button ng-show="!model.config.maxNumber || renderModel.length < model.config.maxNumber"
type="button"
class="umb-node-preview-add"
ng-click="openLinkPicker()">
ng-click="openLinkPicker()"
ng-disabled="!allowAdd">
<span class="sr-only">{{ model.label }}:</span>
<localize key="general_add">Add</localize>
<span class="sr-only">url</span>