diff --git a/src/Umbraco.Core/PropertyEditors/ConfigurationEditorOfTConfiguration.cs b/src/Umbraco.Core/PropertyEditors/ConfigurationEditorOfTConfiguration.cs index f2a3afdbe3..f860bafd2c 100644 --- a/src/Umbraco.Core/PropertyEditors/ConfigurationEditorOfTConfiguration.cs +++ b/src/Umbraco.Core/PropertyEditors/ConfigurationEditorOfTConfiguration.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. using System.Reflection; @@ -125,6 +125,7 @@ public abstract class ConfigurationEditor : ConfigurationEditor PropertyType = property.PropertyType, Description = attribute.Description, HideLabel = attribute.HideLabel, + SortOrder = attribute.SortOrder, View = attributeView, }; @@ -150,6 +151,8 @@ public abstract class ConfigurationEditor : ConfigurationEditor field.PropertyName = property.Name; field.PropertyType = property.PropertyType; + field.SortOrder = attribute.SortOrder; + if (!string.IsNullOrWhiteSpace(attribute.Key)) { field.Key = attribute.Key; @@ -182,6 +185,6 @@ public abstract class ConfigurationEditor : ConfigurationEditor } } - return fields; + return fields.OrderBy(x => x.SortOrder).ToList(); } } diff --git a/src/Umbraco.Core/PropertyEditors/ConfigurationField.cs b/src/Umbraco.Core/PropertyEditors/ConfigurationField.cs index 40bd0c0ca9..def2135bbd 100644 --- a/src/Umbraco.Core/PropertyEditors/ConfigurationField.cs +++ b/src/Umbraco.Core/PropertyEditors/ConfigurationField.cs @@ -1,4 +1,5 @@ -using System.Runtime.Serialization; +using System.Runtime.Serialization; +using Umbraco.Cms.Core.Models.ContentEditing; using Umbraco.Extensions; namespace Umbraco.Cms.Core.PropertyEditors; @@ -47,6 +48,7 @@ public class ConfigurationField HideLabel = attribute.HideLabel; Key = attribute.Key; View = attribute.View; + SortOrder = attribute.SortOrder; } /// @@ -77,6 +79,12 @@ public class ConfigurationField [DataMember(Name = "description")] public string? Description { get; set; } + /// + /// Gets or sets the sort order of the field. + /// + [DataMember(Name = "sortOrder")] + public int SortOrder { get; set; } + /// /// Gets or sets a value indicating whether to hide the label of the field. /// diff --git a/src/Umbraco.Core/PropertyEditors/ConfigurationFieldAttribute.cs b/src/Umbraco.Core/PropertyEditors/ConfigurationFieldAttribute.cs index 07433d1504..9eec779c2c 100644 --- a/src/Umbraco.Core/PropertyEditors/ConfigurationFieldAttribute.cs +++ b/src/Umbraco.Core/PropertyEditors/ConfigurationFieldAttribute.cs @@ -124,6 +124,11 @@ public class ConfigurationFieldAttribute : Attribute /// public string? View { get; } + /// + /// Gets or sets the sort order to use to render the field editor. + /// + public int SortOrder { get; set; } + /// /// Gets or sets the description of the field. ///