Fix errore inc ascata selezione parametri

This commit is contained in:
Samuele Locatelli
2022-09-15 12:02:01 +02:00
parent 0c01e93ff3
commit 0fe40dacc7
7 changed files with 226 additions and 21 deletions
+4 -4
View File
@@ -45,8 +45,8 @@ namespace MP.SPEC.Components
if (_selFlux != value)
{
_selFlux = value;
var pUpd = Task.Run(async () => await reloadData(false));
pUpd.Wait();
//var pUpd = Task.Run(async () => await reloadData(false));
//pUpd.Wait();
}
}
}
@@ -60,8 +60,8 @@ namespace MP.SPEC.Components
if (_selMacchina != value)
{
_selMacchina = value;
var pUpd = Task.Run(async () => await reloadData(false));
pUpd.Wait();
//var pUpd = Task.Run(async () => await reloadData(false));
//pUpd.Wait();
}
}
}
+34
View File
@@ -0,0 +1,34 @@
<div class="row">
<div class="col-6">
</div>
<div class="col-6 text-end">
<div class="d-flex justify-content-between">
<div class="px-2">
</div>
<div class="px-2">
<select @bind="@selMacchina" class="form-select">
<option value="*">--- Tutti ---</option>
@if (ListMacchine != null)
{
foreach (var item in ListMacchine)
{
<option value="@item">@item</option>
}
}
</select>
</div>
<div class="px-2">
<select @bind="@selFlux" class="form-select">
<option value="*">--- Tutti ---</option>
@if (ListFlux != null)
{
foreach (var item in ListFlux)
{
<option value="@item">@item</option>
}
}
</select>
</div>
</div>
</div>
</div>
+97
View File
@@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using MP.SPEC;
using MP.SPEC.Shared;
using MP.SPEC.Components;
using MP.SPEC.Data;
namespace MP.SPEC.Components
{
public partial class ParamsFilter
{
[Parameter]
public SelectFluxParams SelFilter { get; set; }
[Parameter]
public EventCallback<SelectFluxParams> FilterChanged { get; set; }
protected string selMacchina
{
get
{
return SelFilter.IdxMacchina;
}
set
{
if (!SelFilter.IdxMacchina.Equals(value))
{
SelFilter.IdxMacchina = value;
SelFilter.CodFlux = "*";
Task.Delay(1);
ListFlux = MDService.ParametriGetFilt(selMacchina).Result;
Task.Delay(1);
StateHasChanged();
Task.Delay(1);
reportChange();
}
}
}
protected string selFlux
{
get
{
return SelFilter.CodFlux;
}
set
{
if (!SelFilter.CodFlux.Equals(value))
{
SelFilter.CodFlux = value;
reportChange();
}
}
}
private void reportChange()
{
FilterChanged.InvokeAsync(SelFilter);
}
protected override async Task OnInitializedAsync()
{
SelFilter = new SelectFluxParams();
ListMacchine = await MDService.MacchineWithFlux();
ListFlux = await MDService.ParametriGetFilt(selMacchina);
}
private List<string>? ListFlux;
private List<string>? ListMacchine;
[Inject]
protected MpDataService MDService { get; set; }
private async Task reloadFiltFlux()
{
await Task.Delay(1);
ListFlux = await MDService.ParametriGetFilt(selMacchina);
await InvokeAsync(() => StateHasChanged());
}
}
}
+36
View File
@@ -0,0 +1,36 @@
namespace MP.SPEC.Data
{
public class SelectFluxParams
{
#region Public Properties
public string IdxMacchina { get; set; } = "*";
public string CodFlux { get; set; } = "*";
#endregion Public Properties
#region Public Methods
public override bool Equals(object obj)
{
if (!(obj is SelectFluxParams item))
return false;
if (IdxMacchina != item.IdxMacchina)
return false;
if (CodFlux != item.CodFlux)
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
}
+23 -12
View File
@@ -11,7 +11,7 @@
@if (!liveUpdate)
{
<button class="btn btn-secondary" type="button" @onclick="() => toggleUpdate()">
<small>@lastUpdate</small>
<small>@lastUpdate</small>
</button>
}
else
@@ -29,7 +29,7 @@
<div class="col-2">
</div>
<div class="col-5">
<div class="d-flex justify-content-between">
@*<div class="d-flex justify-content-between">
<div class="px-2">
</div>
<div class="px-2">
@@ -45,23 +45,34 @@
</select>
</div>
<div class="px-2">
<select @bind="@selFlux" class="form-select">
<option value="*">--- Tutti ---</option>
@if (ListFlux != null)
{
foreach (var item in ListFlux)
@if (!isLoading)
{
<select @bind="@selFlux" class="form-select">
<option value="*">--- Tutti ---</option>
@if (ListFlux != null)
{
<option value="@item">@item</option>
foreach (var item in ListFlux)
{
<option value="@item">@item</option>
}
}
}
</select>
</select>
}
</div>
</div>
</div>*@
<ParamsFilter FilterChanged="updateFilter"></ParamsFilter>
</div>
</div>
</div>
<div class="card-body">
<ListPARAMS SelMacchina="@selMacchina" SelFlux="@selFlux" LiveUpdate="@liveUpdate" MaxRecord="@maxRecord" TotRecordChanged="@updateTotal"></ListPARAMS>
@if (isLoading)
{
<LoadingData></LoadingData>
}
else
{
<ListPARAMS SelMacchina="@selMacchina" SelFlux="@selFlux" LiveUpdate="@liveUpdate" MaxRecord="@maxRecord" TotRecordChanged="@updateTotal"></ListPARAMS>
}
</div>
<div class="card-footer py-1">
<DataPager @ref="pagerODL" PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
+24 -4
View File
@@ -49,7 +49,7 @@ namespace MP.SPEC.Pages
protected void ForceReloadPage(int newNum)
{
liveUpdate = newNum == 1;
liveUpdate = newNum == 1;
currPage = newNum;
}
@@ -60,6 +60,7 @@ namespace MP.SPEC.Pages
protected override async Task OnInitializedAsync()
{
isLoading = true;
// abilito ricerca...
MsgService.ShowSearch = false;
// resetto search
@@ -70,6 +71,7 @@ namespace MP.SPEC.Pages
lastUpdate = $"Updated: {DateTime.Now:yyyy/MM/dd HH:mm:ss}";
await reloadFilters();
await reloadData();
isLoading = false;
}
protected async Task pgResetReq(bool doReset)
@@ -149,9 +151,16 @@ namespace MP.SPEC.Pages
{
isLoading = true;
_selMacchina = value;
//var pUpd = Task.Run(async () => await reloadFilters());
//var pUpd = Task.Run(async () =>
//{
// await reloadFilters();
// await InvokeAsync(() => StateHasChanged());
//}
//);
//pUpd.Wait();
reloadFilters();
//reloadFilters();
ForceReloadPage(1);
isLoading = false;
}
@@ -204,7 +213,18 @@ namespace MP.SPEC.Pages
await Task.Delay(1);
selFlux = "*";
ListFlux = await MDService.ParametriGetFilt(selMacchina);
await InvokeAsync(()=> StateHasChanged());
await InvokeAsync(() => StateHasChanged());
}
private async Task updateFilter(SelectFluxParams newParams)
{
isLoading = true;
await InvokeAsync(() => StateHasChanged());
selMacchina = newParams.IdxMacchina;
selFlux = newParams.CodFlux;
//ForceReloadPage();
await InvokeAsync(() => StateHasChanged());
isLoading = false;
}
#endregion Private Methods
+8 -1
View File
@@ -194,7 +194,14 @@
</div>
<div class="card-body">
<ListPODL PagerResetReq="pgResetReq" RecordSel="@selRecord"></ListPODL>
@if (isLoading)
{
<LoadingData></LoadingData>
}
else
{
<ListPODL PagerResetReq="pgResetReq" RecordSel="@selRecord"></ListPODL>
}
</div>
<div class="card-footer py-1">
<DataPager @ref="pagerODL" PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />