From bc0f3045564814bcdfbf19a1a5e43b2f62ab62d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 19 Jul 2021 15:33:44 +0200 Subject: [PATCH] dont move group if alias already exists in the context. --- .../components/umbgroupsbuilder.directive.js | 26 ++++++++++++++++++- .../views/components/umb-groups-builder.html | 4 +-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js index e2d68f30c1..2016b60dd7 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js @@ -115,6 +115,13 @@ const parentAlias = scope.openTabAlias, oldAlias = group.alias || null, // null when group comes from root aka. 'generic' newAlias = contentEditingHelper.updateParentAlias(oldAlias, parentAlias); + + // Check alias is unique + // TODO: we should properly do this on hover, to let user know it cant be moved. + if (isAliasUnique(newAlias) === false) { + return; + } + group.alias = newAlias; group.parentAlias = parentAlias; updateDescendingAliases(oldAlias, newAlias); @@ -142,7 +149,24 @@ accept: '.umb-group-builder__property-sortable, .umb-group-builder__group-sortable', tolerance : 'pointer', over: function (evt, ui) { - scope.openTabAlias = evt.target.dataset.tabAlias || null; + + const hoveredTabAlias = evt.target.dataset.tabAlias || null;; + + // if group + if (ui.draggable[0].dataset.groupKey) { + + const groupKey = ui.draggable[0].dataset.groupKey ? ui.draggable[0].dataset.groupKey : false; + const group = groupKey ? scope.model.groups.find(group => group.key === groupKey) : {}; + + const newAlias = contentEditingHelper.updateParentAlias(group.alias || null, hoveredTabAlias); + // Check alias is unique + if (group.alias !== newAlias && isAliasUnique(newAlias) === false) { + // TODO: Missing UI indication of why you cant move here. + return; + } + } + + scope.openTabAlias = hoveredTabAlias; scope.$evalAsync(); } }; diff --git a/src/Umbraco.Web.UI.Client/src/views/components/umb-groups-builder.html b/src/Umbraco.Web.UI.Client/src/views/components/umb-groups-builder.html index 360b89c033..b6c17a6163 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/umb-groups-builder.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/umb-groups-builder.html @@ -120,9 +120,7 @@ ng-repeat="(groupIndex, group) in model.groups track by group.key" ng-show="group.type === 0 && group.parentAlias === openTabAlias" ng-class="{'umb-group-builder__group-sortable': sortingMode && !group.inherited}" - data-group-key="{{group.key}}" - data-group-alias="{{group.alias}}" - data-group-parent-alias="{{group.parentAlias}}"> + data-group-key="{{group.key}}">