From e6366ff86ab3303e430d00e75cd0c8ec3eb4a576 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 11 Jan 2022 08:58:34 +0100 Subject: [PATCH] Modifica gestione edit timbrature x non fare reload --- GPW.CORE.UI/Components/LoadingDataSmall.razor | 6 + GPW.CORE.UI/Components/TimbList.razor | 28 +-- GPW.CORE.UI/Components/TimbrEditor.razor | 23 ++- GPW.CORE.UI/Components/TimbrEditor.razor.cs | 192 +++++++++++------- GPW.CORE.UI/GPW.CORE.UI.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 8 files changed, 152 insertions(+), 105 deletions(-) create mode 100644 GPW.CORE.UI/Components/LoadingDataSmall.razor diff --git a/GPW.CORE.UI/Components/LoadingDataSmall.razor b/GPW.CORE.UI/Components/LoadingDataSmall.razor new file mode 100644 index 0000000..8362fbb --- /dev/null +++ b/GPW.CORE.UI/Components/LoadingDataSmall.razor @@ -0,0 +1,6 @@ +
+
+ loading data + +
+
\ No newline at end of file diff --git a/GPW.CORE.UI/Components/TimbList.razor b/GPW.CORE.UI/Components/TimbList.razor index 064db74..796f478 100644 --- a/GPW.CORE.UI/Components/TimbList.razor +++ b/GPW.CORE.UI/Components/TimbList.razor @@ -50,34 +50,18 @@ public List ListTimb { get; set; } = new List(); [Parameter] - public EventCallback ItemUpdated { get; set; } + public EventCallback ReqDelete { get; set; } + + [Parameter] + public EventCallback ReqUpdate { get; set; } protected async void Delete(TimbratureModel currRecord) { - // chiedo verifica - if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare la richiesta selezionata??")) - return; - - // aggiorno - await GDataServ.TimbratureDelete(currRecord); - -#if false - // elimino dalla lista... - ListTimb.Remove(currRecord); -#endif - - // registro fatto - await ItemUpdated.InvokeAsync(true); + await ReqDelete.InvokeAsync(currRecord); } protected async void ScambioInOut(TimbratureModel currRecord) { - currRecord.Entrata = !currRecord.Entrata; - - // aggiorno - await GDataServ.TimbratureUpdate(currRecord); - - // registro fatto - await ItemUpdated.InvokeAsync(true); + await ReqUpdate.InvokeAsync(currRecord); } } diff --git a/GPW.CORE.UI/Components/TimbrEditor.razor b/GPW.CORE.UI/Components/TimbrEditor.razor index 243b739..244642a 100644 --- a/GPW.CORE.UI/Components/TimbrEditor.razor +++ b/GPW.CORE.UI/Components/TimbrEditor.razor @@ -23,7 +23,14 @@
- + @if (ListTimbAppr != null) + { + + } + else + { + + }
@@ -42,12 +49,11 @@
- | - +
- +
@@ -61,7 +67,14 @@
- + @if (ListTimbRich != null) + { + + } + else + { + + }
diff --git a/GPW.CORE.UI/Components/TimbrEditor.razor.cs b/GPW.CORE.UI/Components/TimbrEditor.razor.cs index 1982147..fa69ac2 100644 --- a/GPW.CORE.UI/Components/TimbrEditor.razor.cs +++ b/GPW.CORE.UI/Components/TimbrEditor.razor.cs @@ -1,111 +1,107 @@ -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 GPW.CORE.UI; -using GPW.CORE.UI.Shared; using GPW.CORE.Data.DbModels; using GPW.CORE.UI.Data; -using System.Net; +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; namespace GPW.CORE.UI.Components { public partial class TimbrEditor { + #region Protected Fields + protected bool vetoUpd = false; - [Inject] - private IJSRuntime JSRuntime { get; set; } + #endregion Protected Fields + + #region Private Properties [Inject] private MessageService AppMServ { get; set; } - [Parameter] - public List ListTimb { get; set; } = new List(); + [Inject] + private IHttpContextAccessor httpContextAccessor { get; set; } - [Parameter] - public DateTime DataRif { get; set; } + [Inject] + private IJSRuntime JSRuntime { get; set; } + + #endregion Private Properties + + #region Protected Properties + + protected List _ListTimb { get; set; } = new List(); + + [Inject] + protected GpwDataService GDataServ { get; set; } + + protected bool IsUscita { get; set; } = false; + + protected List ListTimbAppr { get; set; } + + protected List ListTimbRich { get; set; } + + protected string txtMsgInOut + { + get => IsUscita ? "Uscita" : "Entrata"; + } + + #endregion Protected Properties + + #region Public Properties [Parameter] public EventCallback CloseReq { get; set; } + [Parameter] + public DateTime DataRif { get; set; } + [Parameter] public EventCallback ItemReset { get; set; } [Parameter] public EventCallback ItemUpdated { get; set; } - [Inject] - protected GpwDataService GDataServ { get; set; } - - - protected List ListTimbAppr + [Parameter] + public List ListTimb { - get => ListTimb.Where(x => x.Approv == true).ToList(); - } - protected List ListTimbRich - { - get => ListTimb.Where(x => x.Approv == false).ToList(); + get + { + return _ListTimb; + } + set + { + _ListTimb = value; + } } - protected bool IsUscita { get; set; } = false; + #endregion Public Properties - protected string txtMsgInOut - { - get => IsUscita ? "Uscita" : "Entrata"; - } + #region Private Methods - protected override async Task OnInitializedAsync() + private async Task ReloadData() { DateTime adesso = DateTime.Now; // prendo primo record timbrature o oggi... if (ListTimb != null && ListTimb.Count > 0) - { + { DataRif = ListTimb.FirstOrDefault().DataOra.Date.AddHours(adesso.Hour).AddMinutes(Math.Ceiling((double)adesso.Minute / 5) * 5); } else - { - DataRif = DateTime.Today.AddHours(adesso.Hour).AddMinutes(Math.Ceiling((double)adesso.Minute / 5) * 5); + { + DataRif = DateTime.Today.AddHours(adesso.Hour).AddMinutes(Math.Ceiling((double)adesso.Minute / 5) * 5); } await Task.Delay(1); + if (ListTimb != null) + { + ListTimbAppr = ListTimb.Where(x => x.Approv == true).ToList(); + ListTimbRich = ListTimb.Where(x => x.Approv == false).ToList(); + } } - /// - /// Indico item selezionato - /// - protected async void DoReset() - { - await ItemReset.InvokeAsync(true); - } + #endregion Private Methods - /// - /// Aggiorno e riporto update - /// - protected async void DoUpdate() - { -#if false - // aggiorno - await GDataServ.RegAttUpdate(currRecord); - // resetto clone e record corrente... - AppMServ.clonedRA = null; -#endif - // registro fatto - await ItemUpdated.InvokeAsync(true); - } + #region Protected Methods - [Inject] - private IHttpContextAccessor httpContextAccessor { get; set; } - - protected async void AddRequest() + protected async void DoAdd() { //var remoteIp = httpContextAccessor.HttpContext.Connection?.RemoteIpAddress.ToString(); TimbratureModel currRecord = new TimbratureModel() @@ -121,17 +117,15 @@ namespace GPW.CORE.UI.Components // aggiorno await GDataServ.TimbratureUpdate(currRecord); - // registro fatto - await ItemUpdated.InvokeAsync(true); - } + // elimino dalla lista... + ListTimb.Add(currRecord); - /// - /// Elimino record - /// - protected async void ReportUpdated() - { + await ReloadData(); + +#if false // registro fatto await ItemUpdated.InvokeAsync(true); +#endif } /// @@ -141,5 +135,55 @@ namespace GPW.CORE.UI.Components { await CloseReq.InvokeAsync(true); } + + /// + /// Aggiorno e riporto update + /// + protected async void DoDelete(TimbratureModel currRecord) + { + // chiedo verifica + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare la richiesta selezionata??")) + return; + + // aggiorno + await GDataServ.TimbratureDelete(currRecord); + + // elimino dalla lista... + ListTimb.Remove(currRecord); + + await ReloadData(); + +#if false + // registro fatto + await ItemUpdated.InvokeAsync(true); +#endif + } + + /// + /// Aggiorno e riporto update + /// + protected async void DoUpdate(TimbratureModel currRecord) + { + // elimino da lista + ListTimb.Remove(currRecord); + + // scambio + currRecord.Entrata = !currRecord.Entrata; + + // aggiorno + await GDataServ.TimbratureUpdate(currRecord); + + // ri-aggiungo in lista... + ListTimb.Add(currRecord); + + await ReloadData(); + } + + protected override async Task OnInitializedAsync() + { + await ReloadData(); + } + + #endregion Protected Methods } } \ No newline at end of file diff --git a/GPW.CORE.UI/GPW.CORE.UI.csproj b/GPW.CORE.UI/GPW.CORE.UI.csproj index 38ad84f..30675bc 100644 --- a/GPW.CORE.UI/GPW.CORE.UI.csproj +++ b/GPW.CORE.UI/GPW.CORE.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 3.0.2201.1019 + 3.0.2201.1108 enable enable diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index e1b8b66..19c57c7 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GPW - Gestione Presenze Web -

Versione: 3.0.2201.1019

+

Versione: 3.0.2201.1108


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 8a7f820..d9d2a0d 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -3.0.2201.1019 +3.0.2201.1108 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 91283e7..c428726 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 3.0.2201.1019 + 3.0.2201.1108 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false