using EgwCoreLib.Lux.Data.DbModel.Task; using Microsoft.AspNetCore.Components; namespace Lux.UI.Components.Compo.JobTask { public partial class JobStepMan { [Parameter] public List CurrRecords { get; set; } [Parameter] public string CurrSearch { get; set; } = string.Empty; [Parameter] public EventCallback EC_Selected { get; set; } [Parameter] public EventCallback EC_Updated { get; set; } private int numRecord = 10; private int totalCount = 0; private int currPage = 1; protected override void OnParametersSet() { ReloadData(); } protected List FiltRecords = new List(); protected List ListRecords = new List(); private JobStepModel? editRecord = null; private JobStepModel? selRecord = null; private JobStepModel? newRecord = null; private void ReloadData() { if (CurrRecords != null) { // se ho ricerca testuale faccio filtro ulteriore... if (!string.IsNullOrEmpty(CurrSearch)) { FiltRecords = CurrRecords .Where(x => x.Description.Contains(CurrSearch, StringComparison.InvariantCultureIgnoreCase)) .ToList(); } else { FiltRecords = CurrRecords; } totalCount = FiltRecords.Count; // fix paginazione ListRecords = CurrRecords .OrderBy(x => x.Index) .Skip(numRecord * (currPage - 1)) .Take(numRecord) .ToList(); } } protected async void DoReset() { editRecord = null; selRecord = null; await EC_Selected.InvokeAsync(selRecord); } protected void ToggleAdd() { addVisible = !addVisible; if (addVisible) { newRecord = new JobStepModel() { Index = totalCount + 1, Description = $"Fase {totalCount + 1} | {DateTime.Now:yyyy.MM.dd-HH.mm.ss}" }; } } private bool addVisible = false; } }