Browse Source

Normalize elementId for navigation menu items

pull/16332/head
Engincan VESKE 3 years ago
parent
commit
face6ebf04
  1. 15
      framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs
  2. 15
      framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs

15
framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs

@ -5,6 +5,7 @@ namespace Volo.Abp.UI.Navigation;
public class ApplicationMenuGroup public class ApplicationMenuGroup
{ {
private string _displayName; private string _displayName;
private string _elementId;
/// <summary> /// <summary>
/// Default <see cref="Order"/> value of a group item. /// Default <see cref="Order"/> value of a group item.
@ -32,7 +33,12 @@ public class ApplicationMenuGroup
/// <summary> /// <summary>
/// Can be used to render the element with a specific Id for DOM selections. /// Can be used to render the element with a specific Id for DOM selections.
/// </summary> /// </summary>
public string ElementId { get; set; } public string ElementId {
get { return _elementId; }
set {
_elementId = NormalizeElementId(value);
}
}
/// <summary> /// <summary>
/// The Display order of the group. /// The Display order of the group.
@ -57,7 +63,12 @@ public class ApplicationMenuGroup
private string GetDefaultElementId() private string GetDefaultElementId()
{ {
return "MenuGroup_" + Name; return "MenuGroup" + Name;
}
private string NormalizeElementId(string elementId)
{
return elementId?.Replace("_", "").Replace(".", "");
} }
public override string ToString() public override string ToString()

15
framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs

@ -8,6 +8,7 @@ namespace Volo.Abp.UI.Navigation;
public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers<ApplicationMenuItem> public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers<ApplicationMenuItem>
{ {
private string _displayName; private string _displayName;
private string _elementId;
/// <summary> /// <summary>
/// Default <see cref="Order"/> value of a menu item. /// Default <see cref="Order"/> value of a menu item.
@ -85,7 +86,12 @@ public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers<Applic
/// <summary> /// <summary>
/// Can be used to render the element with a specific Id for DOM selections. /// Can be used to render the element with a specific Id for DOM selections.
/// </summary> /// </summary>
public string ElementId { get; set; } public string ElementId {
get { return _elementId; }
set {
_elementId = NormalizeElementId(value);
}
}
/// <summary> /// <summary>
/// Can be used to render the element with extra CSS classes. /// Can be used to render the element with extra CSS classes.
@ -149,7 +155,12 @@ public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers<Applic
private string GetDefaultElementId() private string GetDefaultElementId()
{ {
return "MenuItem_" + Name; return "MenuItem" + Name;
}
private string NormalizeElementId(string elementId)
{
return elementId?.Replace("_", "").Replace(".", "");
} }
public override string ToString() public override string ToString()

Loading…
Cancel
Save