You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
2 years ago
|
using Biskilog_Accounting.Client.Models;
|
||
|
using Microsoft.AspNetCore.Components;
|
||
|
using System.Linq;
|
||
|
|
||
|
namespace Biskilog_Accounting.Client.Elements
|
||
|
{
|
||
|
public partial class MenuItem
|
||
|
{
|
||
|
[Parameter]
|
||
|
public NavItem Item { get; set; }
|
||
|
[Parameter]
|
||
|
public double ActiveId { get; set; }
|
||
|
[Parameter]
|
||
|
public EventCallback<double> ActiveChanged { get; set; }
|
||
|
private string m_expand { get; set; } = string.Empty;
|
||
|
|
||
|
protected override void OnParametersSet()
|
||
|
{
|
||
|
//Collapse expanded parents if none of its child is active
|
||
|
if (!Item.Children.Any(i => i.Id == ActiveId))
|
||
|
{
|
||
|
m_expand = string.Empty;
|
||
|
}
|
||
|
base.OnParametersSet();
|
||
|
}
|
||
|
private void Toggle()
|
||
|
{
|
||
|
if (String.IsNullOrEmpty(m_expand))
|
||
|
{
|
||
|
m_expand = "menu-item-animating open";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
m_expand = "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void ItemClick(double a_id)
|
||
|
{
|
||
|
ActiveId = a_id;
|
||
|
ActiveChanged.InvokeAsync(a_id);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|