Add sortorder to configuration field (#13075)

This commit is contained in:
Bjarne Fyrstenborg
2023-03-28 09:58:56 +02:00
committed by GitHub
parent 1f6307944b
commit 3a214975ed
3 changed files with 19 additions and 3 deletions

View File

@@ -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<TConfiguration> : ConfigurationEditor
PropertyType = property.PropertyType,
Description = attribute.Description,
HideLabel = attribute.HideLabel,
SortOrder = attribute.SortOrder,
View = attributeView,
};
@@ -150,6 +151,8 @@ public abstract class ConfigurationEditor<TConfiguration> : 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<TConfiguration> : ConfigurationEditor
}
}
return fields;
return fields.OrderBy(x => x.SortOrder).ToList();
}
}

View File

@@ -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;
}
/// <summary>
@@ -77,6 +79,12 @@ public class ConfigurationField
[DataMember(Name = "description")]
public string? Description { get; set; }
/// <summary>
/// Gets or sets the sort order of the field.
/// </summary>
[DataMember(Name = "sortOrder")]
public int SortOrder { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to hide the label of the field.
/// </summary>

View File

@@ -124,6 +124,11 @@ public class ConfigurationFieldAttribute : Attribute
/// </summary>
public string? View { get; }
/// <summary>
/// Gets or sets the sort order to use to render the field editor.
/// </summary>
public int SortOrder { get; set; }
/// <summary>
/// Gets or sets the description of the field.
/// </summary>