From e3c819a3c2bc82b05b0d3ee4f66f5e89f727e526 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 23 Jul 2024 08:18:47 +0200 Subject: [PATCH] - Completato compare vocabolario - Review confrerme compare --- MP.Land/Components/CompareAnagKeyVal.razor | 6 +- MP.Land/Components/CompareAnagKeyVal.razor.cs | 71 +++--- MP.Land/Components/CompareConfig.razor | 4 +- MP.Land/Components/CompareConfig.razor.cs | 11 +- MP.Land/Components/CompareVocabolario.razor | 124 ++++++++-- .../Components/CompareVocabolario.razor.cs | 232 +++++++++++++++++- MP.Land/MP.Land.csproj | 2 +- MP.Land/Pages/ConfSync.razor | 28 +-- MP.Land/Resources/ChangeLog.html | 2 +- MP.Land/Resources/VersNum.txt | 2 +- MP.Land/Resources/manifest.xml | 2 +- 11 files changed, 388 insertions(+), 96 deletions(-) diff --git a/MP.Land/Components/CompareAnagKeyVal.razor b/MP.Land/Components/CompareAnagKeyVal.razor index a5956899..6f8008ac 100644 --- a/MP.Land/Components/CompareAnagKeyVal.razor +++ b/MP.Land/Components/CompareAnagKeyVal.razor @@ -42,11 +42,11 @@ { if (!item.DestExist) { - + } else if ( item.SrcExist) { - + } } @@ -96,7 +96,7 @@ @if (item.DestExist) { - + } diff --git a/MP.Land/Components/CompareAnagKeyVal.razor.cs b/MP.Land/Components/CompareAnagKeyVal.razor.cs index a4ed954f..8107099b 100644 --- a/MP.Land/Components/CompareAnagKeyVal.razor.cs +++ b/MP.Land/Components/CompareAnagKeyVal.razor.cs @@ -58,10 +58,16 @@ namespace MP.Land.Components #region Protected Methods - protected async Task AddLocal(CompAnagKeyVal currItem) + protected string genClass(CompAnagKeyVal currItem) { - if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) - return; + string answ = currItem.IsEqual ? "text-dark" : currItem.SrcExist && currItem.DestExist ? "text-warning" : currItem.SrcExist ? "text-success" : "text-danger"; + return answ; + } + + protected async Task LocalAdd(CompAnagKeyVal currItem) + { + //if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) + // return; bool fatto = false; if (currItem != null) @@ -74,19 +80,7 @@ namespace MP.Land.Components } } - protected string genClass(CompAnagKeyVal currItem) - { - string answ = currItem.IsEqual ? "text-dark" : currItem.SrcExist && currItem.DestExist ? "text-warning" : currItem.SrcExist ? "text-success" : "text-danger"; - //string answ = currItem.IsEqual ? "far fa-thumbs-up text-success" : "far fa-thumbs-down text-danger"; - return answ; - } - - protected override void OnParametersSet() - { - ForceReload(); - } - - protected async Task RemLocal(CompAnagKeyVal currItem) + protected async Task LocalRem(CompAnagKeyVal currItem) { if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record?")) return; @@ -102,6 +96,27 @@ namespace MP.Land.Components } } + protected async Task LocalUpd(CompAnagKeyVal currItem) + { + //if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) + // return; + + bool fatto = false; + if (currItem != null) + { + fatto = await DataService.AnagKeyValUpd(currItem.Source); + } + if (fatto) + { + await ReqReload(); + } + } + + protected override void OnParametersSet() + { + ForceReload(); + } + /// /// Report evento richiesta confronto AnagKeyVal /// @@ -136,8 +151,6 @@ namespace MP.Land.Components { numRecord = newNum; currPage = 1; - //isLoading = true; - //ListCompare = null; await InvokeAsync(UpdPaging); await Task.Delay(1); isLoading = false; @@ -146,34 +159,12 @@ namespace MP.Land.Components protected async Task SetPage(int newNum) { isLoading = true; - //ListCompare = null; - //await Task.Delay(1); - ////StateHasChanged(); currPage = newNum; - //await Task.Delay(1); - //UpdPaging(); - //await Task.Delay(1); await InvokeAsync(UpdPaging); await Task.Delay(1); isLoading = false; } - protected async Task UpdLocal(CompAnagKeyVal currItem) - { - if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) - return; - - bool fatto = false; - if (currItem != null) - { - fatto = await DataService.AnagKeyValUpd(currItem.Source); - } - if (fatto) - { - await ReqReload(); - } - } - #endregion Protected Methods #region Private Properties diff --git a/MP.Land/Components/CompareConfig.razor b/MP.Land/Components/CompareConfig.razor index f99df2fc..39adc9a0 100644 --- a/MP.Land/Components/CompareConfig.razor +++ b/MP.Land/Components/CompareConfig.razor @@ -4,7 +4,7 @@
- Tabella AnagKeyVal - Confronto dati + Tabella Config - Confronto dati
@@ -45,7 +45,7 @@ } else if (item.SrcExist) { - + } } diff --git a/MP.Land/Components/CompareConfig.razor.cs b/MP.Land/Components/CompareConfig.razor.cs index d700bd39..a66a2456 100644 --- a/MP.Land/Components/CompareConfig.razor.cs +++ b/MP.Land/Components/CompareConfig.razor.cs @@ -58,14 +58,13 @@ namespace MP.Land.Components protected string genClass(CompConfig currItem) { string answ = currItem.IsEqual ? "text-dark" : currItem.SrcExist && currItem.DestExist ? "text-warning" : currItem.SrcExist ? "text-success" : "text-danger"; - //string answ = currItem.IsEqual ? "far fa-thumbs-up text-success" : "far fa-thumbs-down text-danger"; return answ; } protected async Task LocalAdd(CompConfig currItem) { - if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) - return; + //if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) + // return; bool fatto = false; if (currItem != null) @@ -96,10 +95,10 @@ namespace MP.Land.Components } } - protected async Task LocalUpdate(CompConfig currItem) + protected async Task LocalUpd(CompConfig currItem) { - if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) - return; + //if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) + // return; bool fatto = false; if (currItem != null) diff --git a/MP.Land/Components/CompareVocabolario.razor b/MP.Land/Components/CompareVocabolario.razor index f27360e5..dc76d06d 100644 --- a/MP.Land/Components/CompareVocabolario.razor +++ b/MP.Land/Components/CompareVocabolario.razor @@ -1,23 +1,105 @@ -
    -
  • - Tabella Vocabolario -
  • -
  • -
    -
    Remote #
    -
    Record
    -
    Local #
    +@if (ShowDetail) +{ +
    +
    +
    +
    + Tabella Vocabolario - Confronto dati +
    +
    + +
    +
    + +
    +
    +
    + @if (isLoading) + { + + } + else + { + + + + + + + + + + + @foreach (var item in ListCompare) + { + + + + + + + } + +
    RemTermineTraduzioneLoc
    + @if (!item.IsEqual) + { + if (!item.DestExist) + { + + } + else if (item.SrcExist) + { + + } + } + + @item.NomeVar + + @if (item.SrcExist) + { +
    @item.Source.Traduzione
    + } + @if (!item.IsEqual && item.DestExist) + { +
    @item.Dest.Traduzione
    + } +
    + @if (item.DestExist) + { + + } +
    + } +
    + +
    +} +else +{ +
      +
    • + Tabella Vocabolario +
    • +
    • +
      +
      Remote #
      +
      Record
      +
      Local #
      +
      -
    • -
    • -
      -
      @numRem
      -
      -
      @numLoc
      -
      -
    • -
    • - -
    • -
    +
  • +
  • +
    +
    @numRem
    +
    +
    @numLoc
    +
    +
  • +
  • + +
  • +
+} \ No newline at end of file diff --git a/MP.Land/Components/CompareVocabolario.razor.cs b/MP.Land/Components/CompareVocabolario.razor.cs index 1b915830..045769fa 100644 --- a/MP.Land/Components/CompareVocabolario.razor.cs +++ b/MP.Land/Components/CompareVocabolario.razor.cs @@ -1,6 +1,10 @@ using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.AppAuth.DTO; using MP.AppAuth.Models; +using MP.Land.Data; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; namespace MP.Land.Components @@ -12,6 +16,9 @@ namespace MP.Land.Components [Parameter] public EventCallback EC_reqAct { get; set; } + [Parameter] + public EventCallback EC_reqReload { get; set; } + [Parameter] public List ListVocabolarioLoc { get; set; } = new List(); @@ -23,8 +30,23 @@ namespace MP.Land.Components #endregion Public Properties + #region Protected Fields + + protected List ListCompare = new List(); + protected List ListCompareAll = new List(); + + #endregion Protected Fields + #region Protected Properties + protected CmpCompType.Display currFilt { get; set; } = new CmpCompType.Display(); + + [Inject] + protected AppAuthService DataService { get; set; } + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + protected int numLoc { get; set; } = 0; protected int numRem { get; set; } = 0; @@ -33,10 +55,63 @@ namespace MP.Land.Components #region Protected Methods + protected string genClass(CompVocabolario currItem) + { + string answ = currItem.IsEqual ? "text-dark" : currItem.SrcExist && currItem.DestExist ? "text-warning" : currItem.SrcExist ? "text-success" : "text-danger"; + return answ; + } + + protected async Task LocalAdd(CompVocabolario currItem) + { + //if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) + // return; + + bool fatto = false; + if (currItem != null) + { + fatto = await DataService.VocabolarioAdd(currItem.Source); + } + if (fatto) + { + await ReqReload(); + } + } + + protected async Task LocalRem(CompVocabolario currItem) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record?")) + return; + + bool fatto = false; + if (currItem != null) + { + fatto = await DataService.VocabolarioDelete(currItem.Dest); + } + if (fatto) + { + await ReqReload(); + } + } + + protected async Task LocalUpd(CompVocabolario currItem) + { + //if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) + // return; + + bool fatto = false; + if (currItem != null) + { + fatto = await DataService.VocabolarioUpd(currItem.Source); + } + if (fatto) + { + await ReqReload(); + } + } + protected override void OnParametersSet() { - numLoc = ListVocabolarioLoc != null ? ListVocabolarioLoc.Count : 0; - numRem = ListVocabolarioRem != null ? ListVocabolarioRem.Count : 0; + ForceReload(); } /// @@ -47,6 +122,159 @@ namespace MP.Land.Components await EC_reqAct.InvokeAsync("Vocabolario"); } + /// + /// Report evento richiesta confronto Vocabolario + /// + protected async Task ReqReload() + { + await EC_reqReload.InvokeAsync("Vocabolario"); + } + + /// + /// Report evento richiesta reset confronto + /// + protected async Task ResetCompare() + { + await EC_reqAct.InvokeAsync(""); + } + + protected void SetFilter(CmpCompType.Display filtDisplay) + { + currFilt = filtDisplay; + ForceReload(); + } + + protected async Task SetNumRec(int newNum) + { + numRecord = newNum; + currPage = 1; + await InvokeAsync(UpdPaging); + await Task.Delay(1); + isLoading = false; + } + + protected async Task SetPage(int newNum) + { + isLoading = true; + currPage = newNum; + await InvokeAsync(UpdPaging); + await Task.Delay(1); + isLoading = false; + } + #endregion Protected Methods + + #region Private Properties + + private int currPage { get; set; } = 1; + + private bool isLoading { get; set; } = false; + + private int numRecord { get; set; } = 10; + + private int totalCount { get; set; } = 0; + + #endregion Private Properties + + #region Private Methods + + private void ForceReload() + { + numLoc = ListVocabolarioLoc != null ? ListVocabolarioLoc.Count : 0; + numRem = ListVocabolarioRem != null ? ListVocabolarioRem.Count : 0; + // predispongo lista comparazione... + ListCompareAll = new List(); + int cIdx = 0; + // filtro EQUAL + if (currFilt.Equal) + { + foreach (var item in ListVocabolarioRem) + { + CompVocabolario newRec = new CompVocabolario() + { + Idx = cIdx++, + NomeVar = $"{item.Lemma}_{item.Lingua}", + Source = item, + Dest = ListVocabolarioLoc.Find(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma) + }; + if (newRec.IsEqual) + { + ListCompareAll.Add(newRec); + } + } + } + + // ciclo valori src... + if (currFilt.Diff) + { + foreach (var item in ListVocabolarioRem) + { + CompVocabolario newRec = new CompVocabolario() + { + Idx = cIdx++, + NomeVar = $"{item.Lemma}_{item.Lingua}", + Source = item, + Dest = ListVocabolarioLoc.Find(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma) + }; + if (!newRec.IsEqual && currFilt.Diff && newRec.SrcExist && newRec.DestExist) + { + ListCompareAll.Add(newRec); + } + } + } + + if (currFilt.Sx) + { + foreach (var item in ListVocabolarioRem) + { + // se non c'è... + if (ListVocabolarioLoc.Where(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma).Count() == 0) + { + CompVocabolario newRec = new CompVocabolario() + { + Idx = cIdx++, + NomeVar = $"{item.Lemma}_{item.Lingua}", + Source = item, + Dest = ListVocabolarioLoc.Find(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma) + }; + if (!newRec.IsEqual) + { + ListCompareAll.Add(newRec); + } + } + } + } + if (currFilt.Dx) + { + // cerco eventuali record SOLO locali... + foreach (var item in ListVocabolarioRem) + { + // se non c'è... + if (ListVocabolarioRem.Where(x => x.Lingua == item.Lingua && x.Lemma == item.Lemma).Count() == 0) + { + CompVocabolario newRec = new CompVocabolario() + { + Idx = cIdx++, + NomeVar = $"{item.Lemma}_{item.Lingua}", + Source = null, + Dest = item + }; + ListCompareAll.Add(newRec); + } + } + } + totalCount = ListCompareAll.Count; + // riordino... + ListCompareAll = ListCompareAll.OrderBy(x => x.NomeVar).ToList(); + // ciclo eventuali record locali rimasti + UpdPaging(); + } + + private void UpdPaging() + { + ListCompare = ListCompareAll.Skip((currPage - 1) * numRecord).Take(numRecord).ToList(); + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 0a86a4b9..abcdc2bc 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net6.0 MP.Land - 6.16.2407.2307 + 6.16.2407.2308 diff --git a/MP.Land/Pages/ConfSync.razor b/MP.Land/Pages/ConfSync.razor index e9a1ed05..d74dfd69 100644 --- a/MP.Land/Pages/ConfSync.razor +++ b/MP.Land/Pages/ConfSync.razor @@ -26,14 +26,6 @@ }
- @if(!string.IsNullOrEmpty(CompType)) - { -
-
- -
-
- } @if (isLoadingLoc) { @@ -47,21 +39,21 @@
@if (string.IsNullOrEmpty(CompType) || showDetail("AnagKeyVal")) { -
- -
+
+ +
} @if (string.IsNullOrEmpty(CompType) || showDetail("Config")) { -
- -
+
+ +
} @if (string.IsNullOrEmpty(CompType) || showDetail("Vocabolario")) - { -
- -
+ { +
+ +
}
} diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index 2aed179e..d40ca323 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo Tablet MAPO - DotNet6 -

Versione: 6.16.2407.2307

+

Versione: 6.16.2407.2308


Note di rilascio:
    diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt index 36da9b8d..78f3a430 100644 --- a/MP.Land/Resources/VersNum.txt +++ b/MP.Land/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2407.2307 +6.16.2407.2308 diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml index 1b5c2bb2..6ebad755 100644 --- a/MP.Land/Resources/manifest.xml +++ b/MP.Land/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2407.2307 + 6.16.2407.2308 https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html false