From a6afe2bdf3b00dc19a69dff69f7e91bf16ce99ad Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 21 Sep 2021 11:18:34 +0200 Subject: [PATCH 1/4] cherry picked f7b485a --- .../NestedContentController.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/Umbraco.Web/PropertyEditors/NestedContentController.cs diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentController.cs b/src/Umbraco.Web/PropertyEditors/NestedContentController.cs new file mode 100644 index 0000000000..23ca91841c --- /dev/null +++ b/src/Umbraco.Web/PropertyEditors/NestedContentController.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Linq; +using Umbraco.Core.Services; +using Umbraco.Web.Editors; +using Umbraco.Web.Mvc; + +namespace Umbraco.Web.PropertyEditors +{ + [PluginController("UmbracoApi")] + public class NestedContentController : UmbracoAuthorizedJsonController + { + [System.Web.Http.HttpGet] + public IEnumerable GetContentTypes() + { + return Services.ContentTypeService + .GetAllElementTypes() + .OrderBy(x => x.SortOrder) + .Select(x => new + { + id = x.Id, + guid = x.Key, + name = x.Name, + alias = x.Alias, + icon = x.Icon, + tabs = x.CompositionPropertyGroups.Where(y => y.Type == Core.Models.PropertyGroupType.Group && !y.Alias.Contains("/")).Select(y => y.Name).Distinct() + }); + } + } +} From de47f95c4fc1e2b692edcb08da75f2be9b9c5784 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 21 Sep 2021 11:19:04 +0200 Subject: [PATCH 2/4] alias is changed. We need to compare with label instead --- .../propertyeditors/nestedcontent/nestedcontent.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js index 64fc40d84d..3510da73a6 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js @@ -535,7 +535,7 @@ // remove all tabs except the specified tab var tabs = scaffold.variants[0].tabs; var tab = _.find(tabs, function (tab) { - return tab.id !== 0 && (tab.alias.toLowerCase() === contentType.ncTabAlias.toLowerCase() || contentType.ncTabAlias === ""); + return tab.id !== 0 && (tab.label.toLowerCase() === contentType.ncTabAlias.toLowerCase() || contentType.ncTabAlias === ""); }); scaffold.variants[0].tabs = []; if (tab) { From ae85c959d47fd9839495a5d93fe84688885c16b0 Mon Sep 17 00:00:00 2001 From: Ronald Barendse Date: Tue, 21 Sep 2021 12:01:02 +0200 Subject: [PATCH 3/4] Updated predicate to use GetParentAlias() --- src/Umbraco.Web/PropertyEditors/NestedContentController.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentController.cs b/src/Umbraco.Web/PropertyEditors/NestedContentController.cs index 23ca91841c..71c2217709 100644 --- a/src/Umbraco.Web/PropertyEditors/NestedContentController.cs +++ b/src/Umbraco.Web/PropertyEditors/NestedContentController.cs @@ -1,5 +1,6 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using Umbraco.Core.Models; using Umbraco.Core.Services; using Umbraco.Web.Editors; using Umbraco.Web.Mvc; @@ -22,7 +23,7 @@ namespace Umbraco.Web.PropertyEditors name = x.Name, alias = x.Alias, icon = x.Icon, - tabs = x.CompositionPropertyGroups.Where(y => y.Type == Core.Models.PropertyGroupType.Group && !y.Alias.Contains("/")).Select(y => y.Name).Distinct() + tabs = x.CompositionPropertyGroups.Where(x => x.Type == PropertyGroupType.Group && x.GetParentAlias() == null).Select(y => y.Name).Distinct() }); } } From a7d60badd3e675fbb31a0de33e8b7fa353cea765 Mon Sep 17 00:00:00 2001 From: Zeegaan <70372949+Zeegaan@users.noreply.github.com> Date: Tue, 21 Sep 2021 13:25:11 +0200 Subject: [PATCH 4/4] fixed NestedContentController to use pattern matching instead of equals operator --- .../NestedContentController.cs | 8 ++--- .../NestedContentController.cs | 30 ------------------- 2 files changed, 3 insertions(+), 35 deletions(-) delete mode 100644 src/Umbraco.Web/PropertyEditors/NestedContentController.cs diff --git a/src/Umbraco.Web.BackOffice/PropertyEditors/NestedContentController.cs b/src/Umbraco.Web.BackOffice/PropertyEditors/NestedContentController.cs index 25d120d807..b975a0114b 100644 --- a/src/Umbraco.Web.BackOffice/PropertyEditors/NestedContentController.cs +++ b/src/Umbraco.Web.BackOffice/PropertyEditors/NestedContentController.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc; +using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Web.BackOffice.Controllers; using Umbraco.Cms.Web.Common.Attributes; @@ -23,9 +24,7 @@ namespace Umbraco.Cms.Web.BackOffice.PropertyEditors } [HttpGet] - public IEnumerable GetContentTypes() - { - return _contentTypeService + public IEnumerable GetContentTypes() => _contentTypeService .GetAllElementTypes() .OrderBy(x => x.SortOrder) .Select(x => new @@ -35,8 +34,7 @@ namespace Umbraco.Cms.Web.BackOffice.PropertyEditors name = x.Name, alias = x.Alias, icon = x.Icon, - tabs = x.CompositionPropertyGroups.Select(y => y.Name).Distinct() + tabs = x.CompositionPropertyGroups.Where(x => x.Type == PropertyGroupType.Group && x.GetParentAlias() is null).Select(y => y.Name).Distinct() }); - } } } diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentController.cs b/src/Umbraco.Web/PropertyEditors/NestedContentController.cs deleted file mode 100644 index 71c2217709..0000000000 --- a/src/Umbraco.Web/PropertyEditors/NestedContentController.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Umbraco.Core.Models; -using Umbraco.Core.Services; -using Umbraco.Web.Editors; -using Umbraco.Web.Mvc; - -namespace Umbraco.Web.PropertyEditors -{ - [PluginController("UmbracoApi")] - public class NestedContentController : UmbracoAuthorizedJsonController - { - [System.Web.Http.HttpGet] - public IEnumerable GetContentTypes() - { - return Services.ContentTypeService - .GetAllElementTypes() - .OrderBy(x => x.SortOrder) - .Select(x => new - { - id = x.Id, - guid = x.Key, - name = x.Name, - alias = x.Alias, - icon = x.Icon, - tabs = x.CompositionPropertyGroups.Where(x => x.Type == PropertyGroupType.Group && x.GetParentAlias() == null).Select(y => y.Name).Distinct() - }); - } - } -}