From 019385411ad0e9fba0ca3d76e7dbf74b69e9b9c5 Mon Sep 17 00:00:00 2001 From: Wilmar de Hoogd Date: Wed, 25 May 2022 02:31:52 +0200 Subject: [PATCH] added option to disable automatic expand of single nc item (#12261) * added option to disable automatic expand of single nc item * remove max item conditional remove max item 1 conditional to set current node * changed description of slider property removed description of first item conditional * Update NestedContentConfiguration.cs change copy to more accurately describe the feature Co-authored-by: Wilmar --- .../PropertyEditors/NestedContentConfiguration.cs | 3 +++ .../nestedcontent/nestedcontent.controller.js | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/PropertyEditors/NestedContentConfiguration.cs b/src/Umbraco.Core/PropertyEditors/NestedContentConfiguration.cs index aed6b5cd00..5cdfd4ba15 100644 --- a/src/Umbraco.Core/PropertyEditors/NestedContentConfiguration.cs +++ b/src/Umbraco.Core/PropertyEditors/NestedContentConfiguration.cs @@ -23,6 +23,9 @@ namespace Umbraco.Cms.Core.PropertyEditors [ConfigurationField("showIcons", "Show Icons", "boolean", Description = "Show the Element Type icons.")] public bool ShowIcons { get; set; } = true; + [ConfigurationField("expandsOnLoad", "Expands on load", "boolean", Description = "A single item is automatically expanded")] + public bool ExpandsOnLoad { get; set; } = true; + [ConfigurationField("hideLabel", "Hide Label", "boolean", Description = "Hide the property label and let the item list span the full width of the editor window.")] public bool HideLabel { get; set; } 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 d406689116..b678492a0b 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 @@ -94,7 +94,8 @@ if (vm.maxItems === 0) vm.maxItems = 1000; - vm.singleMode = vm.minItems === 1 && vm.maxItems === 1 && model.config.contentTypes.length === 1;; + vm.singleMode = vm.minItems === 1 && vm.maxItems === 1 && model.config.contentTypes.length === 1; + vm.expandsOnLoad = Object.toBoolean(model.config.expandsOnLoad) vm.showIcons = Object.toBoolean(model.config.showIcons); vm.wideMode = Object.toBoolean(model.config.hideLabel); vm.hasContentTypes = model.config.contentTypes.length > 0; @@ -617,8 +618,8 @@ modelWasChanged = true; } - // If there is only one item, set it as current node - if (vm.singleMode || (vm.nodes.length === 1 && vm.maxItems === 1)) { + // If there is only one item and expandsOnLoad property is true, set it as current node + if (vm.singleMode || (vm.expandsOnLoad && vm.nodes.length === 1)) { setCurrentNode(vm.nodes[0], false); }