Files
lux/Lux.UI/Components/Pages/ProdPlanner.razor.cs
T
2026-07-03 15:05:21 +02:00

108 lines
3.0 KiB
C#

using EgwCoreLib.Lux.Core.Generic;
using EgwCoreLib.Lux.Data.Services.General;
namespace Lux.UI.Components.Pages
{
public partial class ProdPlanner
{
#region Protected Methods
protected override void OnParametersSet()
{
// preparo sel periodo custom (traduzioni)...
CustomSelDict = Enum.GetValues(typeof(DtUtils.PeriodSet))
.Cast<DtUtils.PeriodSet>()
.ToDictionary(e => e, e => Traduci("periodo_" + e.ToString()));
}
protected override Task OnParametersSetAsync()
{
isLoading = true;
return ReloadDataAsync();
}
#endregion Protected Methods
#region Private Fields
/// <summary>
/// Periodo selezionato attuale
/// </summary>
private DtUtils.Periodo PeriodoSel = new DtUtils.Periodo(DtUtils.PeriodSet.ThisYear);
/// <summary>
/// Periodo custom selezione valori
/// </summary>
private Dictionary<DtUtils.PeriodSet, string>? CustomSelDict = new();
private List<OdlAssignDto>? ListOdl = null;
private bool isLoading = false;
private bool showDetail = false;
#endregion Private Fields
#region Private Properties
[Inject]
private IDataLayerServices DLService { get; set; } = null!;
[Inject]
private IProductionOdlService POService { get; set; } = null!;
private List<EventDto> ListEventi { get; set; } = new();
private string CssDetail => showDetail ? "fa-chevron-up" : "fa-chevron-down";
#endregion Private Properties
#region Private Methods
/// <summary>
/// Legge i dati dei record completi
/// </summary>
private async Task ReloadDataAsync()
{
var rawData = await DLService.PlannerGetEventsAsync(PeriodoSel.Inizio, PeriodoSel.Fine);
if (rawData != null && rawData.Count > 0)
{
ListEventi.Clear();
// x ora copio i vari blocchi...
foreach (var item in rawData)
{
ListEventi.AddRange(item.Value);
}
}
ListOdl = await POService.GetUnassignOdlDtoAsync();
isLoading = false;
}
/// <summary>
/// Imposta periodo da filtro
/// </summary>
/// <param name="newPeriod"></param>
/// <returns></returns>
private Task SetPeriodo(DtUtils.Periodo newPeriod)
{
PeriodoSel = newPeriod;
return ReloadDataAsync();
}
private void ToggleDetail()
{
showDetail = !showDetail;
}
private string ButtonEspandi()
{
string ans = "";
if (showDetail)
ans = Traduci("caricoMac_riduci");
else
ans = Traduci("caricoMac_espandi");
return ans;
}
#endregion Private Methods
}
}