113 lines
2.6 KiB
C#
113 lines
2.6 KiB
C#
using GPW.CORE.Data.DTO;
|
|
using GPW.CORE.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Drawing.Imaging;
|
|
|
|
namespace GPW.CORE.ADM.Components.Layout
|
|
{
|
|
public partial class NavMenu : IDisposable
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_compressUpdated { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
AppMServ.EA_MenuUpdated -= AppMServ_EA_MenuUpdated;
|
|
AppMServ.EA_LangSel -= AppMServ_EA_LangSel;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected MessageService AppMServ { get; set; } = null!;
|
|
|
|
|
|
protected string hideText { get => showText ? "" : "invisible"; }
|
|
|
|
/// <summary>
|
|
/// Idx Dipendente corrente
|
|
/// </summary>
|
|
protected int IdxDipendente
|
|
{
|
|
get
|
|
{
|
|
return AppMServ.IdxDipendente;
|
|
}
|
|
}
|
|
|
|
protected List<MenuItemDTO> ListMenu { get; set; } = new List<MenuItemDTO>();
|
|
|
|
protected bool showText { get; set; } = true;
|
|
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
AppMServ.EA_MenuUpdated += AppMServ_EA_MenuUpdated;
|
|
AppMServ.EA_LangSel += AppMServ_EA_LangSel;
|
|
ReloadData();
|
|
}
|
|
|
|
private void AppMServ_EA_LangSel()
|
|
{
|
|
ReloadData();
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
protected void ToggleCompress()
|
|
{
|
|
showText = !showText;
|
|
EC_compressUpdated.InvokeAsync(showText);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool collapseNavMenu = true;
|
|
|
|
private bool onlyIcon = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
protected string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
|
|
|
|
protected string? TextCss => onlyIcon ? "d-none" : "";
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void AppMServ_EA_MenuUpdated()
|
|
{
|
|
ReloadData();
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private void ReloadData()
|
|
{
|
|
// rilettura menù se mancasse
|
|
ListMenu = AppMServ.ListMenu;
|
|
}
|
|
|
|
private void ToggleNavMenu()
|
|
{
|
|
collapseNavMenu = !collapseNavMenu;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |