using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.Data.DTO; using MP.SPEC.Components; using MP.SPEC.Data; namespace MP.SPEC.Pages { public partial class DOSS { #region Protected Fields protected DataPager pagerODL = null!; #endregion Protected Fields #region Protected Properties [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; [Inject] protected MpDataService MDService { get; set; } = null!; #endregion Protected Properties #region Protected Methods protected async Task cancel() { currDetFluxLogRecord = null; await Task.Delay(1); StateHasChanged(); } protected void ForceReload(int newNum) { numRecord = newNum; } protected void ForceReloadPage(int newNum) { currPage = newNum; StateHasChanged(); } protected override async Task OnInitializedAsync() { isLoading = true; isFiltering = true; // fix pagina await Task.Delay(1); var modFilter = currFilter; modFilter.CurrPage = 1; currFilter = modFilter; await Task.Delay(1); isFiltering = false; } protected async Task selRecordDoss(Dossiers selDoss) { currRecordDoss = selDoss; await Task.Delay(1); } protected async Task selRecordFlux(FluxLogDTO? selRec) { currDetFluxLogRecord = selRec; await Task.Delay(1); } protected async Task update(FluxLogDTO selRec) { var alert = await JSRuntime.InvokeAsync("confirm", "Confermi di voler salvare le modifiche? queste saranno parte del dossier inviato all'impianto"); if (alert) { await Task.Delay(1); if (currRecordDoss != null) { // METODO PER UPDATE FLUX await MDService.updateDossierValue(currRecordDoss, selRec); } return; } else { //isLoading = true; //isFiltering = true; await selRecordFlux(null); currDetFluxLogRecord = null; await Task.Delay(1); await JSRuntime.InvokeAsync("location.reload"); //var modFilter = currFilter; //modFilter.CurrPage = 1; //currFilter = modFilter; //await Task.Delay(1); //isLoading = false; //isFiltering = false; } } private string css() { string answ = ""; if (isEditing == false) { answ = "disabled"; } else { answ = "enabled"; } return answ; } protected void updateTotal(int newTotCount) { totalCount = newTotCount; } #endregion Protected Methods #region Private Fields private FluxLogDTO? _currDetFluxLogRecord = null; #endregion Private Fields #region Private Properties private FluxLogDTO? currDetFluxLogRecord { get => _currDetFluxLogRecord; set { _currDetFluxLogRecord = value; } } private SelectDossierParams currFilter { get; set; } = new SelectDossierParams(); private int currPage { get => currFilter.CurrPage; set => currFilter.CurrPage = value; } private Dossiers? currRecordDoss { get; set; } = null; private bool isFiltering { get; set; } = false; private bool isLoading { get; set; } = true; private int numRecord { get => currFilter.NumRec; set => currFilter.NumRec = value; } private bool isEditing { get => currFilter.isEditing; set => currFilter.isEditing = value; } private int totalCount { get => currFilter.TotCount; set => currFilter.TotCount = value; } #endregion Private Properties #region Private Methods private async Task updateFilter(SelectDossierParams newParams) { isFiltering = false; isLoading = true; await Task.Delay(1); currPage = 1; await Task.Delay(1); await InvokeAsync(() => StateHasChanged()); currFilter = newParams; isLoading = false; } protected void UpdateTotCount(int newTotCount) { totalCount = newTotCount; } #endregion Private Methods } }