From b220c0e2cf5095f0dfdfdef20bb86c0b8abf23a6 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 4 May 2022 16:40:58 +0200 Subject: [PATCH] add readonly mode for grid property editor --- .../src/less/components/umb-grid.less | 33 ++++++++++++++++--- .../propertyeditors/grid/grid.controller.js | 7 ++++ .../src/views/propertyeditors/grid/grid.html | 24 +++++++++----- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/less/components/umb-grid.less b/src/Umbraco.Web.UI.Client/src/less/components/umb-grid.less index 98438a3447..c13a898eef 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/umb-grid.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/umb-grid.less @@ -176,6 +176,14 @@ color: @ui-action-discreet-type-hover; cursor: pointer; } + + &:disabled { + cursor: not-allowed; + &:hover { + border-color: @ui-action-discreet-border; + color: @ui-action-discreet-type; + } + } } .umb-grid .umb-cell-content.-has-editors { @@ -216,6 +224,13 @@ color: @ui-action-discreet-type-hover; text-decoration: none; } + + &:disabled { + cursor: not-allowed; + &:hover { + color: @ui-action-discreet-type; + } + } } .umb-grid .cell-tools-add.-center { @@ -324,11 +339,15 @@ top: 0; left: 0; opacity: 0; - cursor: pointer; - &:hover { - background-color: @ui-action-type-hover; - opacity: 0.1; - transition: opacity 0.1s; + + &.-clickable { + cursor: pointer; + + &:hover { + background-color: @ui-action-type-hover; + opacity: 0.1; + transition: opacity 0.1s; + } } } @@ -525,6 +544,10 @@ cursor: pointer; opacity: .77; } + + &:disabled { + cursor: not-allowed; + } } diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js index 4e2bdf6ce4..c7227ad449 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js @@ -48,6 +48,7 @@ angular.module("umbraco") tolerance: "pointer", zIndex: 999999999999999999, scrollSensitivity: 100, + disabled: $scope.readonly, cursorAt: { top: 40, left: 60 @@ -120,6 +121,7 @@ angular.module("umbraco") tolerance: "pointer", zIndex: 999999999999999999, scrollSensitivity: 100, + disabled: $scope.readonly, cursorAt: { top: 45, left: 90 @@ -304,6 +306,8 @@ angular.module("umbraco") }; $scope.showReorderButton = function () { + if ($scope.readonly) return false; + if ($scope.model.value && $scope.model.value.sections) { for (var i = 0; $scope.model.value.sections.length > i; i++) { var section = $scope.model.value.sections[i]; @@ -359,6 +363,7 @@ angular.module("umbraco") // ********************************************* $scope.clickRow = function (index, rows, $event) { + if ($scope.readonly) return; $scope.currentRowWithActiveChild = null; $scope.active = rows[index]; @@ -579,6 +584,7 @@ angular.module("umbraco") // ********************************************* $scope.clickCell = function (index, cells, row, $event) { + if ($scope.readonly) return; $scope.currentCellWithActiveChild = null; @@ -601,6 +607,7 @@ angular.module("umbraco") // Control management functions // ********************************************* $scope.clickControl = function (index, controls, cell, $event) { + if ($scope.readonly) return; $scope.active = controls[index]; $scope.currentCellWithActiveChild = cell; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.html index a7e6e9314a..432c2a7d29 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.html @@ -90,7 +90,7 @@
-
+
-
+
-
+
-
+
-
- +
+
@@ -259,7 +265,7 @@ -
+