Aggiunta pagina gestione vocabolario

This commit is contained in:
Samuele Locatelli
2026-05-29 19:21:52 +02:00
parent 0ad786bc1c
commit 1d43e05045
14 changed files with 349 additions and 9 deletions
+10 -1
View File
@@ -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<TemplateModel> DbSetTemplate { get; set; }
public virtual DbSet<TemplateRowModel> DbSetTemplateRow { get; set; }
public virtual DbSet<LinguaModel> DbSetLingua { get; set; }
public virtual DbSet<VocabolarioModel> DbSetVocabolario { get; set; }
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
@@ -152,6 +157,10 @@
.HasForeignKey(x => x.ProdODLID)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<VocabolarioModel>()
.HasKey(jst => new { jst.Lingua, jst.Lemma });
// gestione dati DTX calcolati nel DB
#if false
modelBuilder.Entity<ProductionItemModel>()
@@ -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<IConnectionMultiplexer>(redisConn);
services.TryAddSingleton<IRedisService, RedisService>();
services.TryAddSingleton<IRedisSubscriptionManager, RedisSubscriptionManager>();
services.TryAddSingleton<IVocabolarioRepository, VocabolarioRepository>();
// Repository Scoped
services.TryAddScoped<IBuyOrderRepository, BuyOrderRepository>();
@@ -112,6 +115,7 @@ namespace EgwCoreLib.Lux.Data
services.TryAddSingleton<ICalcRequestService, CalcRequestService>();
services.TryAddSingleton<IFileService, FileService>();
services.TryAddSingleton<IProdService, ProdService>();
services.TryAddSingleton<IVocabolarioService, VocabolarioService>();
//services.TryAddSingleton<CalcRequestService>();
+1
View File
@@ -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;
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.2605.2916</Version>
<Version>1.1.2605.2919</Version>
</PropertyGroup>
<ItemGroup>
+2 -2
View File
@@ -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
@@ -0,0 +1,67 @@
<div class="card shadow">
<div class="card-header d-flex justify-content-between">
<div class="px-1 fs-4 align-items-center">
Lingua
</div>
<div class="px-1">
<select class="form-select" @bind="@selLingua" @bind:after="FiltLingua">
@if (string.IsNullOrEmpty(selLingua))
{
<option value="">Sel &rarr;</option>
}
@foreach (var item in ListLingue)
{
<option value="@item.Lingua">@item.Lingua</option>
}
</select>
</div>
</div>
<div class="card-body">
@if (isLoading)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning fs-5">Nessun Record Trovato</div>
}
else
{
<table class="table table-sm table-striped">
<thead>
<tr>
<td>Lemma</td>
<td class="text-end w-75">Traduzione</td>
</tr>
</thead>
<tbody>
@foreach (var item in ListPaged)
{
<tr>
<td><button class="btn btn-outline-primary btn-sm" @onclick="() => DoEdit(item)"><i class="fa-solid fa-pen me-2"></i> @item.Lemma</button></td>
<td class="text-end">
@if (currRec != null && item.Lemma == currRec.Lemma && item.Lingua == currRec.Lingua)
{
<div class="input-group">
<input type="text" class="form-control" @bind="@item.Traduzione">
<button class="btn btn-success" style="width: 3rem;" @onclick="DoSave"><i class="fa-solid fa-floppy-disk"></i></button>
<button class="btn btn-warning" style="width: 3rem;" @onclick="DoCancel"><i class="fa-solid fa-ban"></i></button>
</div>
}
else
{
<span>@item.Traduzione</span>
}
</td>
</tr>
}
</tbody>
</table>
}
</div>
<div class="card-footer py-1">
<EgwCoreLib.Razor.DataPager currPage="@currPage" PageSize="@numRecord" totalCount="@totalCount" numPageChanged="SavePage" numRecordChanged="SaveNumRec"></EgwCoreLib.Razor.DataPager>
</div>
</div>
@@ -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<VocabolarioModel> AllRecord { get; set; } = null!;
[Parameter]
public EventCallback<VocabolarioModel> EC_Updated { get; set; }
[Parameter]
public List<LinguaModel> 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<VocabolarioModel> 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();
}
/// <summary>
/// Filtro e paginazione
/// </summary>
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
}
}
+53
View File
@@ -0,0 +1,53 @@
@page "/vocabulary"
@using Lux.UI.Components.Compo.Admin
<div class="card shadow">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="px-0">
<h3>Gestione Vocabolario</h3>
</div>
<div class="px-0">
@if (currRec == null)
{
<div class="input-group input-group-sm" title="ricerca">
<span class="input-group-text"><i class="fas fa-search"></i></span>
<input type="text" class="form-control" @bind="@SearchVal">
<button class="btn @btnResetCss" @onclick="ResetSearch"><i class="fas fa-ban"></i></button>
<button class="ms-2 btn btn-success" @onclick="DoAddNew">Add New</button>
</div>
}
else
{
<div class="input-group">
<span class="input-group-text">Lemma</span>
<input type="text" class="form-control" style="width: 10rem;" @bind="@currRec.Lemma">
<span class="input-group-text">Traduzione</span>
<input type="text" class="form-control" style="width: 30rem;" @bind="@currRec.Traduzione">
<button class="btn btn-sm btn-success" style="width: 6rem;" @onclick="DoSave">Save</button>
<button class="btn btn-sm btn-warning" style="width: 6rem;" @onclick="DoCancel">Cancel</button>
</div>
}
</div>
</div>
</div>
<div class="card-body">
@if (isLoading)
{
<LoadingData></LoadingData>
}
else
{
<div class="row">
<div class="col-6">
<VocabMan ListLingue="@ListLingue" AllRecord="FullVocab" SearchVal="@SearchVal" EC_Updated="UpdateRec"></VocabMan>
</div>
<div class="col-6">
<VocabMan ListLingue="@ListLingue" AllRecord="FullVocab" SearchVal="@SearchVal" EC_Updated="UpdateRec"></VocabMan>
</div>
</div>
}
</div>
</div>
@@ -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<VocabolarioModel> FiltVocab = new();
private List<VocabolarioModel> FullVocab = new();
private bool isLoading = false;
private string langDef = "IT";
private List<LinguaModel> 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
}
}
+1
View File
@@ -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;
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>1.1.2605.2916</Version>
<Version>1.1.2605.2919</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 1.1.2605.2916</h4>
<h4>Versione: 1.1.2605.2919</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.1.2605.2916
1.1.2605.2919
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2605.2916</version>
<version>1.1.2605.2919</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>