From 336c9701c2c4a29113b675c54ac4b5da7db8aaf9 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 8 Jul 2024 11:01:33 +0800 Subject: [PATCH] Add `Icon & CustomData` to `ApplicationMenuGroup`. --- .../Abp/Ui/Navigation/ApplicationMenuGroup.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs index ab76c1c337..6580ab09a0 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs @@ -1,4 +1,5 @@ -using JetBrains.Annotations; +using System.Collections.Generic; +using JetBrains.Annotations; namespace Volo.Abp.UI.Navigation; @@ -46,10 +47,22 @@ public class ApplicationMenuGroup /// public int Order { get; set; } + /// + /// Icon of the menu item if exists. + /// + public string? Icon { get; set; } + + /// + /// Can be used to store a custom object related to this menu item. Optional. + /// + [NotNull] + public Dictionary CustomData { get; } = new(); + public ApplicationMenuGroup( [NotNull] string name, [NotNull] string displayName, string? elementId = null, + string? icon = null, int order = DefaultOrder) { Check.NotNullOrWhiteSpace(name, nameof(name)); @@ -58,6 +71,7 @@ public class ApplicationMenuGroup Name = name; DisplayName = displayName; ElementId = elementId ?? GetDefaultElementId(); + Icon = icon; Order = order; } @@ -71,6 +85,16 @@ public class ApplicationMenuGroup return elementId?.Replace(".", "_"); } + /// + /// Adds a custom data item to with given key & value. + /// + /// This itself. + public ApplicationMenuGroup WithCustomData(string key, object value) + { + CustomData[key] = value; + return this; + } + public override string ToString() { return $"[ApplicationMenuGroup] Name = {Name}";