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 d4c8b3d300..68460f4982 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 @@ -143,6 +143,9 @@ const dropIndex = groupsInTab.findIndex(group => group.key === groupKey); updateSortOrder(groupsInTab, dropIndex); + + // when a group is dropped we need to reset the requested tab hover alias + scope.sortableRequestedTabAlias = undefined; } } }; @@ -192,7 +195,9 @@ const newAlias = contentTypeHelper.updateParentAlias(group.alias || null, hoveredTabAlias); // Check alias is unique if (group.alias !== newAlias && contentTypeHelper.isAliasUnique(scope.model.groups, newAlias) === false) { - // TODO: Missing UI indication of why you cant move here. + localizationService.localize("contentTypeEditor_groupReorderSameAliasError", [group.name, newAlias]).then((value) => { + notificationsService.error(value); + }); return; } } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/contenttypehelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/contenttypehelper.service.js index a5298aa425..5198f5d9bd 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/contenttypehelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/contenttypehelper.service.js @@ -90,6 +90,9 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje }, convertGroupToTab: function (groups, group) { + const tabs = groups.filter(group => group.type === this.TYPE_TAB).sort((a, b) => a.sortOrder - b.sortOrder); + const nextSortOrder = tabs && tabs.length > 0 ? tabs[tabs.length - 1].sortOrder + 1 : 0; + group.convertingToTab = true; group.type = this.TYPE_TAB; @@ -100,7 +103,7 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje group.alias = this.isAliasUnique(otherGroups, newAlias) ? newAlias : this.createUniqueAlias(otherGroups, newAlias); group.parentAlias = null; - + group.sortOrder = nextSortOrder; group.convertingToTab = false; }, diff --git a/src/Umbraco.Web.UI.Client/src/views/dataTypes/create.html b/src/Umbraco.Web.UI.Client/src/views/dataTypes/create.html index 3cfc6e0cc4..5a7859add9 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dataTypes/create.html +++ b/src/Umbraco.Web.UI.Client/src/views/dataTypes/create.html @@ -24,13 +24,19 @@ -
+
- + diff --git a/src/Umbraco.Web.UI.Client/src/views/documentTypes/create.html b/src/Umbraco.Web.UI.Client/src/views/documentTypes/create.html index 02db433b1c..8992c73525 100644 --- a/src/Umbraco.Web.UI.Client/src/views/documentTypes/create.html +++ b/src/Umbraco.Web.UI.Client/src/views/documentTypes/create.html @@ -54,7 +54,7 @@
-
+
@@ -67,7 +67,14 @@
- + diff --git a/src/Umbraco.Web.UI.Client/src/views/mediaTypes/create.html b/src/Umbraco.Web.UI.Client/src/views/mediaTypes/create.html index 6f74174776..cb7bd74424 100644 --- a/src/Umbraco.Web.UI.Client/src/views/mediaTypes/create.html +++ b/src/Umbraco.Web.UI.Client/src/views/mediaTypes/create.html @@ -24,7 +24,7 @@
-
+
@@ -37,7 +37,13 @@
- + diff --git a/src/Umbraco.Web.UI.Client/test/unit/common/services/content-type-helper.spec.js b/src/Umbraco.Web.UI.Client/test/unit/common/services/content-type-helper.spec.js index e9f334e09d..f86d4b2c1f 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/common/services/content-type-helper.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/common/services/content-type-helper.spec.js @@ -173,13 +173,13 @@ describe('contentTypeHelper tests', function () { describe('convertGroupToTab', function () { - const groups = [ - { type: 0, alias: 'hero', name: 'Hero' }, - { type: 0, alias: 'content' }, - { type: 0, alias: 'footer' } - ]; - it('should convert group to tab', function () { + const groups = [ + { type: 0, alias: 'hero', name: 'Hero' }, + { type: 0, alias: 'content' }, + { type: 0, alias: 'footer' } + ]; + const newTab = groups[0]; contentTypeHelper.convertGroupToTab(groups, newTab); @@ -189,6 +189,29 @@ describe('contentTypeHelper tests', function () { expect(newTab.parentAlias).toBeNull(); }); + it('should set sort order to 0 if it is the first tab', function () { + const groups = [ + { type: 0, alias: 'hero', name: 'Hero' } + ]; + + const newTab = groups[0]; + contentTypeHelper.convertGroupToTab(groups, newTab); + + expect(newTab.sortOrder).toBe(0); + }); + + it('should set sort order to 1 higher than the last tab', function () { + const groups = [ + { type: 0, alias: 'settings', name: 'Settings', sortOrder: 100 }, + { type: 1, alias: 'content', name: 'Content', sortOrder: 5 } + ]; + + const newTab = groups[0]; + contentTypeHelper.convertGroupToTab(groups, newTab); + + expect(newTab.sortOrder).toBe(6); + }); + }); }); diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index 3bd1e59797..addd6f7115 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -1669,6 +1669,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont Compositions Group + You can't move the group %0% to this tab because the group will get the same alias as a tab: "%1%". Rename the group to continue. You have not added any groups Add group Inherited from