140 lines
3.6 KiB
C#
140 lines
3.6 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.Data.DbModels;
|
|
using MP.SPEC.Components.Reparti;
|
|
using MP.SPEC.Data;
|
|
using NLog.LayoutRenderers;
|
|
using static MP.Core.Objects.Enums;
|
|
using static MP.Data.Services.ExecStatsCollector;
|
|
|
|
namespace MP.SPEC.Pages
|
|
{
|
|
public partial class RepStop
|
|
{
|
|
#region Protected Properties
|
|
|
|
protected List<string> CurrList { get; set; } = new List<string>();
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; } = null!;
|
|
|
|
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 void OnInitialized()
|
|
{
|
|
var rawList = MDService.MacchineGetFilt("*");
|
|
// prendo solo macchine VALIDE
|
|
SearchRecords = rawList.Where(x => !string.IsNullOrEmpty(x.locazione)).ToList();
|
|
totalCount = SearchRecords.Count;
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
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 List<MacchineModel> SearchRecords = new();
|
|
private int totalCount = 0;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
if (SearchRecords != null)
|
|
{
|
|
// filtro x display
|
|
ListRecords = SearchRecords
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |