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 563a5d8469..ed0823a495 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 @@ -21,13 +21,13 @@ scope.compositionsButtonState = "init"; scope.tabs = []; scope.genericGroups = []; - scope.openTabKey = null; + scope.openTabAlias = null; scope.hasGenericTab = false; scope.genericTab = { key: null, name: "Generic", alias: contentEditingHelper.genericTabAlias, - parentKey: null, + parentAlias: "", type: TYPE_TAB, sortOrder: 0, properties: [] @@ -40,14 +40,15 @@ scope.tabs.forEach(tab => { tab.indexInGroups = newValue.findIndex(group => group.key === tab.key); + tab.parentAlias = contentEditingHelper.getParentAliasFromAlias(tab.alias); }); checkGenericTabVisibility(); - if (!scope.openTabKey && scope.hasGenericTab) { - scope.openTabKey = null; - } else if (!scope.openTabKey && scope.tabs.length > 0) { - scope.openTabKey = scope.tabs[0].key; + if (!scope.openTabAlias && scope.hasGenericTab) { + scope.openTabAlias = null; + } else if (!scope.openTabAlias && scope.tabs.length > 0) { + scope.openTabAlias = scope.tabs[0].alias; } })); @@ -101,10 +102,11 @@ handle: ".umb-group-builder__group-handle", items: ".umb-group-builder__group-sortable", stop: function (event, ui) { - const groupKey = ui.item[0].dataset.groupKey ? ui.item[0].dataset.groupKey : ""; - const group = groupKey ? scope.model.groups.find(group => group.key === groupKey) : ""; - group.parentKey = scope.openTabKey; - const groupsInTab = scope.model.groups.filter(group => group.parentKey === scope.openTabKey); + const groupAlias = ui.item[0].dataset.groupAlias ? ui.item[0].dataset.groupAlias : ""; + const group = groupAlias ? scope.model.groups.find(group => group.alias === groupAlias) : {}; + group.parentAlias = scope.openTabAlias; + group.alias = (group.parentAlias !== "" ? group.parentAlias + "/" : "") + group.alias.substring(group.alias.lastIndexOf('/')+1); + const groupsInTab = scope.model.groups.filter(group => group.parentAlias === scope.openTabAlias); updateSortOrder(groupsInTab); } }; @@ -402,8 +404,8 @@ }; /* ---------- TABS ---------- */ - scope.changeTab = function ({key}) { - scope.openTabKey = key; + scope.changeTab = function ({alias}) { + scope.openTabAlias = alias; }; scope.addTab = function () { diff --git a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js index 4be8d8d1c3..e087268dd5 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js @@ -182,6 +182,14 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt genericTabAlias: "_umb_genericTab", + generateTabAlias: function(alias, parentAlias) { + return (parentAlias !== "" && parentAlias != null ? parentAlias + "/" : "" ) + alias; + }, + + getParentAliasFromAlias: function(alias) { + return alias.substring(0, alias.lastIndexOf("/")); + }, + registerGenericTab: function (groups) { if (!groups) { return; @@ -194,7 +202,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt return; } - const isRootGroup = (group) => group.type === 0 && group.parentKey === null; + const isRootGroup = (group) => group.type === 0 && group.parentAlias === ""; const hasRootGroups = groups.filter(group => isRootGroup(group)).length > 0; if (!hasRootGroups) { @@ -205,7 +213,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt label: 'Generic', alias: genericTabAlias, key: null, - parentKey: null, + parentAlias: "", type: 1, properties: [] }; 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 350a6ea6f4..a44d402c7c 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 @@ -118,9 +118,11 @@