137 lines
3.4 KiB
C#
137 lines
3.4 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.Data.DbModels;
|
|
|
|
namespace MP.SPEC.Components
|
|
{
|
|
public partial class ListMacc
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public List<MacchineModel> ListMSE { get; set; } = null!;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Elenco selezione corrente
|
|
/// </summary>
|
|
protected List<string> CurrList { get; set; } = new List<string>();
|
|
|
|
/// <summary>
|
|
/// Conteggio elementi selezionati
|
|
/// </summary>
|
|
protected int numSel
|
|
{
|
|
get => CurrList.Count();
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected string CheckSelect(MacchineModel currRec)
|
|
{
|
|
string answ = "";
|
|
if (CurrList.Contains(currRec.CodMacchina))
|
|
{
|
|
answ = "table-info";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
totalCount = ListMSE.Count();
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task SetNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
currPage = 1;
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task SetPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
await ReloadData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Esegue toggle selezione fino a numMax in aggiunta e rimuovendo tutti se era true
|
|
/// </summary>
|
|
protected async Task ToggleAllSel()
|
|
{
|
|
AllSelected = !AllSelected;
|
|
if (AllSelected)
|
|
{
|
|
if (ListRecords != null)
|
|
{
|
|
foreach (var record in ListRecords)
|
|
{
|
|
if (!CurrList.Contains(record.CodMacchina))
|
|
{
|
|
CurrList.Add(record.CodMacchina);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CurrList.Clear();
|
|
}
|
|
await Task.Delay(1);
|
|
#if false
|
|
await EC_ListUpdated.InvokeAsync(CurrList);
|
|
#endif
|
|
}
|
|
|
|
protected void ToggleSel(string newVal)
|
|
{
|
|
if (!CurrList.Contains(newVal))
|
|
{
|
|
CurrList.Add(newVal);
|
|
}
|
|
else
|
|
{
|
|
CurrList.Remove(newVal);
|
|
}
|
|
// riordino
|
|
CurrList = CurrList.OrderBy(x => x).ToList();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool AllSelected = false;
|
|
private int currPage = 1;
|
|
private bool isLoading = false;
|
|
|
|
private List<MacchineModel> ListRecords = new();
|
|
private int numRecord = 10;
|
|
private int totalCount = 0;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
if (ListMSE != null)
|
|
{
|
|
// filtro x display
|
|
ListRecords = ListMSE
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |