Browse Source

Merge pull request #20182 from abpframework/ApplicationMenuGroup

Add `Icon & CustomData` to `ApplicationMenuGroup`.
pull/20186/head
liangshiwei 2 years ago
committed by GitHub
parent
commit
66955aab07
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 26
      framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs

26
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
/// </summary>
public int Order { get; set; }
/// <summary>
/// Icon of the menu item if exists.
/// </summary>
public string? Icon { get; set; }
/// <summary>
/// Can be used to store a custom object related to this menu item. Optional.
/// </summary>
[NotNull]
public Dictionary<string, object> 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(".", "_");
}
/// <summary>
/// Adds a custom data item to <see cref="CustomData"/> with given key &amp; value.
/// </summary>
/// <returns>This <see cref="ApplicationMenuGroup"/> itself.</returns>
public ApplicationMenuGroup WithCustomData(string key, object value)
{
CustomData[key] = value;
return this;
}
public override string ToString()
{
return $"[ApplicationMenuGroup] Name = {Name}";

Loading…
Cancel
Save