- Completato compare vocabolario

- Review confrerme compare
This commit is contained in:
Samuele Locatelli
2024-07-23 08:18:47 +02:00
parent a8116b3416
commit e3c819a3c2
11 changed files with 388 additions and 96 deletions
+3 -3
View File
@@ -42,11 +42,11 @@
{
if (!item.DestExist)
{
<button class="btn w-100 btn-success btn-sm py-0" @onclick="() => AddLocal(item)">Add</button>
<button class="btn w-100 btn-success btn-sm py-0" @onclick="() => LocalAdd(item)">Add</button>
}
else if ( item.SrcExist)
{
<button class="btn w-100 btn-primary btn-sm py-0" @onclick="() => UpdLocal(item)">Mod</button>
<button class="btn w-100 btn-primary btn-sm py-0" @onclick="() => LocalUpd(item)">Mod</button>
}
}
</td>
@@ -96,7 +96,7 @@
<td>
@if (item.DestExist)
{
<button class="btn w-100 btn-danger btn-sm py-0" @onclick="() => RemLocal(item)">Rem</button>
<button class="btn w-100 btn-danger btn-sm py-0" @onclick="() => LocalRem(item)">Rem</button>
}
</td>
</tr>
+31 -40
View File
@@ -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<bool>("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<bool>("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<bool>("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<bool>("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();
}
/// <summary>
/// Report evento richiesta confronto AnagKeyVal
/// </summary>
@@ -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<bool>("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
+2 -2
View File
@@ -4,7 +4,7 @@
<div class="card-header text-light bg-dark bg-gradient">
<div class="row">
<div class="col fs-5">
Tabella AnagKeyVal - Confronto dati
Tabella Config - Confronto dati
</div>
<div class="col text-center">
<CmpCompType EC_filtUpd="SetFilter"></CmpCompType>
@@ -45,7 +45,7 @@
}
else if (item.SrcExist)
{
<button class="btn w-100 btn-primary btn-sm py-0" @onclick="() => LocalUpdate(item)">Mod</button>
<button class="btn w-100 btn-primary btn-sm py-0" @onclick="() => LocalUpd(item)">Mod</button>
}
}
</td>
+5 -6
View File
@@ -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<bool>("confirm", "Sicuro di voler aggiungere il record?"))
return;
//if (!await JSRuntime.InvokeAsync<bool>("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<bool>("confirm", "Sicuro di voler aggiungere il record?"))
return;
//if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler aggiungere il record?"))
// return;
bool fatto = false;
if (currItem != null)
+103 -21
View File
@@ -1,23 +1,105 @@
<ul class="list-group">
<li class="list-group-item active">
Tabella Vocabolario
</li>
<li class="list-group-item">
<div class="d-flex justify-content-between">
<div class="px-1">Remote #</div>
<div class="px-1">Record</div>
<div class="px-1">Local #</div>
@if (ShowDetail)
{
<div class="card">
<div class="card-header text-light bg-dark bg-gradient">
<div class="row">
<div class="col fs-5">
Tabella Vocabolario - Confronto dati
</div>
<div class="col text-center">
<CmpCompType EC_filtUpd="SetFilter"></CmpCompType>
</div>
<div class="col">
<button class="btn btn-primary w-100" @onclick="ResetCompare">Chiudi</button>
</div>
</div>
</div>
<div class="card-body">
@if (isLoading)
{
<LoadingData></LoadingData>
}
else
{
<table class="table table-striped table-sm text-start">
<thead>
<tr class="">
<th>Rem</th>
<th class="text-nowrap">Termine</th>
<th class="text-nowrap">Traduzione</th>
<th class="text-nowrap">Loc</th>
</tr>
</thead>
<tbody>
@foreach (var item in ListCompare)
{
<tr class="@genClass(item)">
<td>
@if (!item.IsEqual)
{
if (!item.DestExist)
{
<button class="btn w-100 btn-success btn-sm py-0" @onclick="() => LocalAdd(item)">Add</button>
}
else if (item.SrcExist)
{
<button class="btn w-100 btn-primary btn-sm py-0" @onclick="() => LocalUpd(item)">Mod</button>
}
}
</td>
<td class="@genClass(item)">
@item.NomeVar
</td>
<td>
@if (item.SrcExist)
{
<div class="text-dark">@item.Source.Traduzione</div>
}
@if (!item.IsEqual && item.DestExist)
{
<div class="text-secondary">@item.Dest.Traduzione</div>
}
</td>
<td>
@if (item.DestExist)
{
<button class="btn w-100 btn-danger btn-sm py-0" @onclick="() => LocalRem(item)">Rem</button>
}
</td>
</tr>
}
</tbody>
</table>
}
</div>
<div class="card-footer p-1">
<DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" totalCount="@totalCount" showLoading="@isLoading" />
</div>
</div>
}
else
{
<ul class="list-group">
<li class="list-group-item active">
Tabella Vocabolario
</li>
<li class="list-group-item">
<div class="d-flex justify-content-between">
<div class="px-1">Remote #</div>
<div class="px-1">Record</div>
<div class="px-1">Local #</div>
</div>
</li>
<li class="list-group-item font-weight-bold display-4">
<div class="d-flex justify-content-between">
<div class="px-1">@numRem</div>
<div class="px-1"><i class="fas fa-arrows-alt-h"></i></div>
<div class="px-1">@numLoc</div>
</div>
</li>
<li class="list-group-item">
<button class="btn btn-primary w-100" @onclick="ReqCompare">Sync</button>
</li>
</ul>
</li>
<li class="list-group-item font-weight-bold display-4">
<div class="d-flex justify-content-between">
<div class="px-1">@numRem</div>
<div class="px-1"><i class="fas fa-arrows-alt-h"></i></div>
<div class="px-1">@numLoc</div>
</div>
</li>
<li class="list-group-item">
<button class="btn btn-primary w-100" @onclick="ReqCompare">Sync</button>
</li>
</ul>
}
+230 -2
View File
@@ -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<string> EC_reqAct { get; set; }
[Parameter]
public EventCallback<string> EC_reqReload { get; set; }
[Parameter]
public List<VocabolarioModel> ListVocabolarioLoc { get; set; } = new List<VocabolarioModel>();
@@ -23,8 +30,23 @@ namespace MP.Land.Components
#endregion Public Properties
#region Protected Fields
protected List<CompVocabolario> ListCompare = new List<CompVocabolario>();
protected List<CompVocabolario> ListCompareAll = new List<CompVocabolario>();
#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<bool>("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<bool>("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<bool>("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();
}
/// <summary>
@@ -47,6 +122,159 @@ namespace MP.Land.Components
await EC_reqAct.InvokeAsync("Vocabolario");
}
/// <summary>
/// Report evento richiesta confronto Vocabolario
/// </summary>
protected async Task ReqReload()
{
await EC_reqReload.InvokeAsync("Vocabolario");
}
/// <summary>
/// Report evento richiesta reset confronto
/// </summary>
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<CompVocabolario>();
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
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Land</RootNamespace>
<Version>6.16.2407.2307</Version>
<Version>6.16.2407.2308</Version>
</PropertyGroup>
<ItemGroup>
+10 -18
View File
@@ -26,14 +26,6 @@
}
<div class="card shadow">
<div class="card-body">
@if(!string.IsNullOrEmpty(CompType))
{
<div class="d-flex justify-content-end">
<div class="px-1">
<button class="btn btn-primary" @onclick="doClose">Chiudi</button>
</div>
</div>
}
@if (isLoadingLoc)
{
<LoadingData Title="Loading Local..." DisplayCss="alert alert-secondary"></LoadingData>
@@ -47,21 +39,21 @@
<div class="row">
@if (string.IsNullOrEmpty(CompType) || showDetail("AnagKeyVal"))
{
<div class="col-12 col-sm-6 col-xl my-1">
<CompareAnagKeyVal ListAnagKeyValLoc="@listAnagKeyValLoc" ListAnagKeyValRem="@listAnagKeyValRem" EC_reqAct="DoCompare" ShowDetail="@showDetail("AnagKeyVal")" EC_reqReload="ReloadPartial"></CompareAnagKeyVal>
</div>
<div class="col-12 col-sm-6 col-xl my-1">
<CompareAnagKeyVal ListAnagKeyValLoc="@listAnagKeyValLoc" ListAnagKeyValRem="@listAnagKeyValRem" EC_reqAct="DoCompare" ShowDetail="@showDetail("AnagKeyVal")" EC_reqReload="ReloadPartial"></CompareAnagKeyVal>
</div>
}
@if (string.IsNullOrEmpty(CompType) || showDetail("Config"))
{
<div class="col-12 col-sm-6 col-xl my-1">
<CompareConfig ListConfigLoc="@listConfigLoc" ListConfigRem="@listConfigRem" EC_reqAct="DoCompare" ShowDetail="@showDetail("Config")" EC_reqReload="ReloadPartial"></CompareConfig>
</div>
<div class="col-12 col-sm-6 col-xl my-1">
<CompareConfig ListConfigLoc="@listConfigLoc" ListConfigRem="@listConfigRem" EC_reqAct="DoCompare" ShowDetail="@showDetail("Config")" EC_reqReload="ReloadPartial"></CompareConfig>
</div>
}
@if (string.IsNullOrEmpty(CompType) || showDetail("Vocabolario"))
{
<div class="col-12 col-sm-6 col-xl my-1">
<CompareVocabolario ListVocabolarioLoc="@listVocabolarioLoc" ListVocabolarioRem="@listVocabolarioRem" EC_reqAct="DoCompare" ShowDetail="@showDetail("Vocabolario")"></CompareVocabolario>
</div>
{
<div class="col-12 col-sm-6 col-xl my-1">
<CompareVocabolario ListVocabolarioLoc="@listVocabolarioLoc" ListVocabolarioRem="@listVocabolarioRem" EC_reqAct="DoCompare" ShowDetail="@showDetail("Vocabolario")" EC_reqReload="ReloadPartial"></CompareVocabolario>
</div>
}
</div>
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo Tablet MAPO - DotNet6</i>
<h4>Versione: 6.16.2407.2307</h4>
<h4>Versione: 6.16.2407.2308</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.16.2407.2307
6.16.2407.2308
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2407.2307</version>
<version>6.16.2407.2308</version>
<url>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>