From 1d43e0504535b6dfbec607879ef2adfec9e3ae2c Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 29 May 2026 19:21:52 +0200 Subject: [PATCH] Aggiunta pagina gestione vocabolario --- EgwCoreLib.Lux.Data/DataLayerContext.cs | 11 +- .../DataServiceCollectionExtensions.cs | 6 +- EgwCoreLib.Lux.Data/GlobalUsings.cs | 1 + Lux.API/Lux.API.csproj | 2 +- Lux.All.sln | 4 +- Lux.UI/Components/Compo/Admin/VocabMan.razor | 67 ++++++++++ .../Components/Compo/Admin/VocabMan.razor.cs | 114 ++++++++++++++++++ Lux.UI/Components/Pages/Vocabulary.razor | 53 ++++++++ Lux.UI/Components/Pages/Vocabulary.razor.cs | 91 ++++++++++++++ Lux.UI/GlobalUsings.cs | 1 + Lux.UI/Lux.UI.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 14 files changed, 349 insertions(+), 9 deletions(-) create mode 100644 Lux.UI/Components/Compo/Admin/VocabMan.razor create mode 100644 Lux.UI/Components/Compo/Admin/VocabMan.razor.cs create mode 100644 Lux.UI/Components/Pages/Vocabulary.razor create mode 100644 Lux.UI/Components/Pages/Vocabulary.razor.cs diff --git a/EgwCoreLib.Lux.Data/DataLayerContext.cs b/EgwCoreLib.Lux.Data/DataLayerContext.cs index b003879e..cf21a882 100644 --- a/EgwCoreLib.Lux.Data/DataLayerContext.cs +++ b/EgwCoreLib.Lux.Data/DataLayerContext.cs @@ -1,4 +1,6 @@ -namespace EgwCoreLib.Lux.Data +using EgwCoreLib.Lux.Data.DbModel.Admin; + +namespace EgwCoreLib.Lux.Data { public partial class DataLayerContext : DbContext { @@ -79,6 +81,9 @@ public virtual DbSet DbSetTemplate { get; set; } public virtual DbSet DbSetTemplateRow { get; set; } + public virtual DbSet DbSetLingua { get; set; } + public virtual DbSet DbSetVocabolario { get; set; } + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); @@ -152,6 +157,10 @@ .HasForeignKey(x => x.ProdODLID) .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasKey(jst => new { jst.Lingua, jst.Lemma }); + // gestione dati DTX calcolati nel DB #if false modelBuilder.Entity() diff --git a/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs b/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs index 3bc2078b..6da9a5e6 100644 --- a/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs +++ b/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs @@ -1,5 +1,7 @@ -using EgwCoreLib.Lux.Data.Repository.Report; +using EgwCoreLib.Lux.Data.Repository.Admin; +using EgwCoreLib.Lux.Data.Repository.Report; using EgwCoreLib.Lux.Data.Repository.Supplier; +using EgwCoreLib.Lux.Data.Services.Admin; using EgwCoreLib.Lux.Data.Services.Catalog; using EgwCoreLib.Lux.Data.Services.Config; using EgwCoreLib.Lux.Data.Services.Cost; @@ -29,6 +31,7 @@ namespace EgwCoreLib.Lux.Data //services.TryAddSingleton(redisConn); services.TryAddSingleton(); services.TryAddSingleton(); + services.TryAddSingleton(); // Repository Scoped services.TryAddScoped(); @@ -112,6 +115,7 @@ namespace EgwCoreLib.Lux.Data services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); + services.TryAddSingleton(); //services.TryAddSingleton(); diff --git a/EgwCoreLib.Lux.Data/GlobalUsings.cs b/EgwCoreLib.Lux.Data/GlobalUsings.cs index d59b12ea..1093b318 100644 --- a/EgwCoreLib.Lux.Data/GlobalUsings.cs +++ b/EgwCoreLib.Lux.Data/GlobalUsings.cs @@ -1,6 +1,7 @@ global using EgwCoreLib.Lux.Core.Dto; global using EgwCoreLib.Lux.Core.RestPayload; global using EgwCoreLib.Lux.Data.Data.DbModel.Admin; +global using EgwCoreLib.Lux.Data.DbModel.Admin; global using EgwCoreLib.Lux.Data.DbModel.Catalog; global using EgwCoreLib.Lux.Data.DbModel.Config; global using EgwCoreLib.Lux.Data.DbModel.Cost; diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index ca90649c..99cbc707 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 1.1.2605.2916 + 1.1.2605.2919 diff --git a/Lux.All.sln b/Lux.All.sln index 5c62c028..c1e91c85 100644 --- a/Lux.All.sln +++ b/Lux.All.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.14.37216.2 +# Visual Studio Version 18 +VisualStudioVersion = 18.5.11801.241 oobstable MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwCoreLib.Lux.Core", "EgwCoreLib.Lux.Core\EgwCoreLib.Lux.Core.csproj", "{CCE87D58-1E6C-47B3-A28C-65BFCF5F1D0C}" EndProject diff --git a/Lux.UI/Components/Compo/Admin/VocabMan.razor b/Lux.UI/Components/Compo/Admin/VocabMan.razor new file mode 100644 index 00000000..8a09b2f5 --- /dev/null +++ b/Lux.UI/Components/Compo/Admin/VocabMan.razor @@ -0,0 +1,67 @@ +
+
+
+ Lingua +
+
+ +
+
+
+ @if (isLoading) + { + + } + else if (totalCount == 0) + { +
Nessun Record Trovato
+ } + else + { + + + + + + + + + @foreach (var item in ListPaged) + { + + + + + } + +
LemmaTraduzione
+ @if (currRec != null && item.Lemma == currRec.Lemma && item.Lingua == currRec.Lingua) + { +
+ + + +
+ } + else + { + @item.Traduzione + } +
+ } +
+ +
+ + diff --git a/Lux.UI/Components/Compo/Admin/VocabMan.razor.cs b/Lux.UI/Components/Compo/Admin/VocabMan.razor.cs new file mode 100644 index 00000000..c2cf1c36 --- /dev/null +++ b/Lux.UI/Components/Compo/Admin/VocabMan.razor.cs @@ -0,0 +1,114 @@ +using EgwCoreLib.Lux.Data.DbModel.Admin; + +namespace Lux.UI.Components.Compo.Admin +{ + public partial class VocabMan + { + #region Public Properties + + [Parameter] + public List AllRecord { get; set; } = null!; + + [Parameter] + public EventCallback EC_Updated { get; set; } + + [Parameter] + public List ListLingue { get; set; } = null!; + + [Parameter] + public string SearchVal { get; set; } = string.Empty; + + #endregion Public Properties + + #region Protected Methods + + protected override void OnParametersSet() + { + if (AllRecord != null && AllRecord.Count > 0) + { + isLoading = true; + UpdateTable(); + } + } + + #endregion Protected Methods + + #region Private Fields + + private int currPage = 1; + private VocabolarioModel? currRec = null; + private bool isLoading = false; + private List ListPaged = new(); + private int numRecord = 10; + private string selLingua = ""; + + private int totalCount = 0; + + #endregion Private Fields + + #region Private Methods + + private void DoCancel() + { + currRec = null; + } + + private void DoEdit(VocabolarioModel selRec) + { + currRec = currRec == null || currRec.Lemma != selRec.Lemma ? selRec : null; + } + + private async Task DoSave() + { + await EC_Updated.InvokeAsync(currRec); + currRec = null; + } + + private void FiltLingua() + { + UpdateTable(); + } + + private void SaveNumRec(int newNum) + { + numRecord = newNum; + currPage = 1; + UpdateTable(); + } + + private void SavePage(int newNum) + { + currPage = newNum; + UpdateTable(); + } + + /// + /// Filtro e paginazione + /// + private void UpdateTable() + { + ListPaged.Clear(); + if (!string.IsNullOrEmpty(selLingua)) + { + var rawList = AllRecord.Where(x => x.Lingua == selLingua).ToList(); + if (!string.IsNullOrEmpty(SearchVal)) + { + rawList = rawList.Where(x => + x.Lemma.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) || + x.Traduzione.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) + ).ToList(); + } + + totalCount = rawList.Count; + // fix paginazione + ListPaged = rawList + .Skip(numRecord * (currPage - 1)) + .Take(numRecord) + .ToList(); + } + isLoading = false; + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/Lux.UI/Components/Pages/Vocabulary.razor b/Lux.UI/Components/Pages/Vocabulary.razor new file mode 100644 index 00000000..0a5ef741 --- /dev/null +++ b/Lux.UI/Components/Pages/Vocabulary.razor @@ -0,0 +1,53 @@ +@page "/vocabulary" +@using Lux.UI.Components.Compo.Admin +
+
+
+
+

Gestione Vocabolario

+
+
+ @if (currRec == null) + { +
+ + + + +
+ } + else + { +
+ Lemma + + Traduzione + + + +
+ } +
+
+
+
+ @if (isLoading) + { + + } + else + { +
+
+ +
+
+ +
+
+ } +
+
+ + + diff --git a/Lux.UI/Components/Pages/Vocabulary.razor.cs b/Lux.UI/Components/Pages/Vocabulary.razor.cs new file mode 100644 index 00000000..1b94b88f --- /dev/null +++ b/Lux.UI/Components/Pages/Vocabulary.razor.cs @@ -0,0 +1,91 @@ +using EgwCoreLib.Lux.Data.DbModel.Admin; + +namespace Lux.UI.Components.Pages +{ + public partial class Vocabulary + { + #region Protected Methods + + protected override Task OnInitializedAsync() + { + return ReloadDataAsync(); + } + + #endregion Protected Methods + + #region Private Fields + + private bool addNew = false; + private VocabolarioModel? currRec = null; + private List FiltVocab = new(); + private List FullVocab = new(); + private bool isLoading = false; + private string langDef = "IT"; + private List ListLingue = new(); + + private string SearchVal = ""; + + #endregion Private Fields + + #region Private Properties + + private string btnResetCss => string.IsNullOrEmpty(SearchVal) ? "btn-secondary" : "btn-primary"; + + [Inject] + private IVocabolarioService VService { get; set; } = null!; + + #endregion Private Properties + + #region Private Methods + + private void DoAddNew() + { + currRec = new(); + } + + private void DoCancel() + { + currRec = null; + } + + private async Task DoSave() + { + if (currRec != null) + { + // genero 1 rec x ogni lingua + var listNew = ListLingue.Select(x => new VocabolarioModel() + { + Lingua = x.Lingua, + Lemma = currRec.Lemma, + Traduzione = currRec.Traduzione + }).ToList(); + // salvo + await VService.UpsertManyAsync(listNew); + } + currRec = null; + //rileggo + await ReloadDataAsync(); + } + + private async Task ReloadDataAsync() + { + isLoading = true; + ListLingue = await VService.ListLingueAsync(); + FullVocab = await VService.GetAllAsync(); + isLoading = false; + } + + private void ResetSearch() + { + SearchVal = ""; + } + + private async Task UpdateRec(VocabolarioModel updRec) + { + await VService.UpsertAsync(updRec); + await ReloadDataAsync(); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/Lux.UI/GlobalUsings.cs b/Lux.UI/GlobalUsings.cs index 43e1aca4..d63ea81b 100644 --- a/Lux.UI/GlobalUsings.cs +++ b/Lux.UI/GlobalUsings.cs @@ -10,6 +10,7 @@ global using EgwCoreLib.Lux.Data.DbModel.Production; global using EgwCoreLib.Lux.Data.DbModel.Sales; global using EgwCoreLib.Lux.Data.DbModel.Utils; global using EgwCoreLib.Lux.Data.Domains; +global using EgwCoreLib.Lux.Data.Services.Admin; global using EgwCoreLib.Lux.Data.Services.Catalog; global using EgwCoreLib.Lux.Data.Services.Config; global using EgwCoreLib.Lux.Data.Services.Cost; diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index 23128a62..444a2f2a 100644 --- a/Lux.UI/Lux.UI.csproj +++ b/Lux.UI/Lux.UI.csproj @@ -5,7 +5,7 @@ enable enable aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50 - 1.1.2605.2916 + 1.1.2605.2919 diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 80b6959d..024cca04 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 1.1.2605.2916

+

Versione: 1.1.2605.2919


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index c4ee575b..466d0b6f 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2605.2916 +1.1.2605.2919 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 3174e6ac..3b0391e4 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2605.2916 + 1.1.2605.2919 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false