- FIX Selezione stato comemssa e filtraggio
This commit is contained in:
Samuele Locatelli
2022-09-13 14:40:54 +02:00
parent 681aa44b32
commit 00a0fc81ce
8 changed files with 80 additions and 176 deletions
-2
View File
@@ -1,8 +1,6 @@
@using MP.SPEC.Components
@using MP.SPEC.Data
<h3>ODL</h3>
@if (ListRecords == null)
{
<LoadingData></LoadingData>
+7 -20
View File
@@ -9,9 +9,6 @@ namespace MP.SPEC.Components
{
#region Public Properties
[Parameter]
public bool isActive { get; set; } = false;
[Parameter]
public EventCallback<bool> PagerResetReq { get; set; }
@@ -24,11 +21,8 @@ namespace MP.SPEC.Components
if (_statoSel != value)
{
_statoSel = value;
if (isActive)
{
var pUpd = Task.Run(async () => await reloadData());
pUpd.Wait();
}
var pUpd = Task.Run(async () => await reloadData());
pUpd.Wait();
}
}
}
@@ -146,18 +140,11 @@ namespace MP.SPEC.Components
private async Task reloadData()
{
isLoading = true;
if (isActive)
{
SearchRecords = await MDService.ListODLFilt(true, SearchVal, StatoSel);
totalCount = SearchRecords.Count;
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
}
else
{
await Task.Delay(1);
}
SearchRecords = await MDService.ListODLFilt(true, SearchVal, StatoSel);
totalCount = SearchRecords.Count;
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
isLoading = false;
}
-2
View File
@@ -1,8 +1,6 @@
@using MP.SPEC.Components
@using MP.SPEC.Data
<h3>PODL</h3>
@if (ListRecords == null)
{
<LoadingData></LoadingData>
+43 -41
View File
@@ -9,28 +9,23 @@ namespace MP.SPEC.Components
{
#region Public Properties
[Parameter]
public bool isActive { get; set; } = false;
[Parameter]
public EventCallback<bool> PagerResetReq { get; set; }
[Parameter]
public string StatoSel
private string StatoSel
{
get => _statoSel;
set
{
if (_statoSel != value)
{
_statoSel = value;
if (isActive)
{
var pUpd = Task.Run(async () => await reloadData());
pUpd.Wait();
}
}
}
get => MsgService.StateSel;
set => MsgService.StateSel = value;
//get => _statoSel;
//set
//{
// if (_statoSel != value)
// {
// _statoSel = value;
// var pUpd = Task.Run(async () => await reloadData());
// pUpd.Wait();
// }
//}
}
#endregion Public Properties
@@ -63,7 +58,7 @@ namespace MP.SPEC.Components
protected MpDataService MDService { get; set; } = null!;
[Inject]
protected MessageService MessageService { get; set; } = null!;
protected MessageService MsgService { get; set; } = null!;
#endregion Protected Properties
@@ -71,11 +66,23 @@ namespace MP.SPEC.Components
protected override async Task OnInitializedAsync()
{
MessageService.EA_PageUpdated += MessageService_EA_PageUpdated;
MessageService.EA_SearchUpdated += OnSeachUpdated;
MsgService.EA_PageUpdated += MessageService_EA_PageUpdated;
MsgService.EA_SearchUpdated += OnSeachUpdated;
MsgService.EA_StatoSearch += MsgService_EA_StatoSearch;
await reloadData();
}
private async void MsgService_EA_StatoSearch()
{
await InvokeAsync(() =>
{
PagerResetReq.InvokeAsync(true);
//currPage = 1;
Task task = UpdateData();
StateHasChanged();
});
}
protected async void OnSeachUpdated()
{
await InvokeAsync(() =>
@@ -97,7 +104,9 @@ namespace MP.SPEC.Components
#region Private Fields
private string _statoSel = "*";
#if false
private string _statoSel = "*";
#endif
private PODLModel? currRecord = null;
@@ -111,27 +120,27 @@ namespace MP.SPEC.Components
private int currPage
{
get => MessageService.currPage;
set => MessageService.currPage = value;
get => MsgService.currPage;
set => MsgService.currPage = value;
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get => MessageService.numRecord;
set => MessageService.numRecord = value;
get => MsgService.numRecord;
set => MsgService.numRecord = value;
}
private string SearchVal
{
get => string.IsNullOrEmpty(MessageService.SearchVal) ? "*" : MessageService.SearchVal;
get => string.IsNullOrEmpty(MsgService.SearchVal) ? "*" : MsgService.SearchVal;
}
private int totalCount
{
get => MessageService.totalCount;
set => MessageService.totalCount = value;
get => MsgService.totalCount;
set => MsgService.totalCount = value;
}
#endregion Private Properties
@@ -146,18 +155,11 @@ namespace MP.SPEC.Components
private async Task reloadData()
{
isLoading = true;
if (isActive)
{
SearchRecords = await MDService.ListPODLFilt(SearchVal, StatoSel);
totalCount = SearchRecords.Count;
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
}
else
{
await Task.Delay(1);
}
SearchRecords = await MDService.ListPODLFilt(SearchVal, StatoSel);
totalCount = SearchRecords.Count;
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
isLoading = false;
}