Update componente window

Fix redraw on cancel
This commit is contained in:
Samuele Locatelli
2026-03-09 16:31:31 +01:00
parent c11104fe58
commit 686d38a0f5
18 changed files with 414 additions and 148 deletions
+2 -2
View File
@@ -8,8 +8,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
<PackageVersion Include="Egw.Lux.WebWindow.Base" Version="3.1.3.616" />
<PackageVersion Include="Egw.Lux.WebWindowComplex" Version="3.1.3.616" />
<PackageVersion Include="Egw.Lux.WebWindow.Base" Version="3.1.3.916" />
<PackageVersion Include="Egw.Lux.WebWindowComplex" Version="3.1.3.916" />
<PackageVersion Include="Egw.Window.Data" Version="2.8.1.2611" />
<PackageVersion Include="EgwCoreLib.Razor" Version="1.5.2511.312" />
<PackageVersion Include="EgwCoreLib.Utils" Version="1.5.2511.312" />
@@ -84,6 +84,16 @@ namespace EgwCoreLib.Lux.Data.DbModel.Items
/// </summary>
public string ItemSteps { get; set; } = "";
/// <summary>
/// Indica protetto = NON consentito edit completo (da definire...)
/// </summary>
/// <returns></returns>
[NotMapped]
public bool IsProtected
{
get => false;
}
/// <summary>
/// Navigazione Job/Cicli
/// </summary>
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.2603.0914</Version>
<Version>1.1.2603.0916</Version>
</PropertyGroup>
<ItemGroup>
@@ -1,6 +1,6 @@
<div class="d-flex justify-content-between">
<div class="px-0">
@if (!ShowItemsBuy && (!string.IsNullOrEmpty(SelCodGroup) && SelType != Enums.ItemClassType.ND))
@if (AddEnabled())
{
<button class="btn btn-sm btn-success" @onclick="DoAdd"><i class="fa-solid fa-cart-plus"></i> Nuovo</button>
}
@@ -38,6 +38,20 @@ namespace Lux.UI.Components.Compo.Item
#endregion Protected Methods
private bool AddEnabled()
{
bool answ = false;
if (ShowItemsBuy)
{
answ = (!string.IsNullOrEmpty(SelCodGroup) && SelType != Enums.ItemClassType.ND);
}
else
{
answ = (SelEnvir != EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.NULL);
}
return answ;
}
#region Private Properties
[Inject]
@@ -1,5 +1,4 @@
<div class="rounded rounded-3 bg-secondary bg-opacity-25 bg-gradient p-2 m-0 shadow">
@if (CurrRecord != null)
{
<div><span class="fs-5"># <b>@(CurrRecord?.ItemID)</b></span> | Codice @CurrRecord.ItemCode</div>
+18 -14
View File
@@ -21,20 +21,7 @@ namespace Lux.UI.Components.Compo.Item
#endregion Public Properties
#region Private Methods
private async Task DoCancel()
{
await EC_Close.InvokeAsync(true);
}
private async Task DoSave()
{
// richiede di effettuare salvataggio record...
await EC_Updated.InvokeAsync(CurrRecord);
}
#endregion Private Methods
#region Private Properties
/// <summary>
/// Wrapper per valore margine in modalità decimal
@@ -50,5 +37,22 @@ namespace Lux.UI.Components.Compo.Item
}
}
}
#endregion Private Properties
#region Private Methods
private Task DoCancel()
{
return EC_Close.InvokeAsync(true);
}
private Task DoSave()
{
// richiede di effettuare salvataggio record...
return EC_Updated.InvokeAsync(CurrRecord);
}
#endregion Private Methods
}
}
@@ -8,10 +8,6 @@ else if (totalCount == 0)
}
else
{
if (editRecord != null)
{
<ItemEdit CurrRecord="editRecord" ListItemGroup="ListItemGroup" EC_Updated="DoSave" EC_Close="DoCancel"></ItemEdit>
}
<table class="table table-sm table-striped">
<thead>
<tr>
+87 -89
View File
@@ -10,6 +10,9 @@ namespace Lux.UI.Components.Compo.Item
{
#region Public Properties
[Parameter]
public EventCallback<ItemModel?> EC_EditReq { get; set; }
[Parameter]
public List<ItemGroupModel> ListItemGroup { get; set; } = null!;
@@ -18,34 +21,62 @@ namespace Lux.UI.Components.Compo.Item
#endregion Public Properties
#region Public Classes
#endregion Public Classes
#region Protected Fields
protected List<ItemModel> AllRecords = new List<ItemModel>();
protected List<ItemModel> ListRecords = new List<ItemModel>();
#endregion Protected Fields
#region Protected Properties
[Inject]
protected DataLayerServices DLService { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnParametersSetAsync()
{
if (!SelFilt.Equals(actFilt) || true)
{
actFilt = SelFilt;
await ReloadData();
UpdateTable();
}
}
#endregion Protected Methods
#region Private Fields
private FiltSelect actFilt = new FiltSelect();
private List<ItemModel> AllRecords = new List<ItemModel>();
private int currPage = 1;
private ItemModel? editRecord = null;
private bool isLoading = false;
private List<ItemModel> ListRecords = new List<ItemModel>();
private int numRecord = 10;
private ItemModel? selRecord = null;
private int totalCount = 0;
#endregion Private Fields
#region Private Properties
[Inject]
private DataLayerServices DLService { get; set; } = null!;
[Inject]
private IJSRuntime JSRuntime { get; set; } = null!;
#endregion Private Properties
#if false
private async Task DoCancel()
{
await ResetEdit();
UpdateTable();
}
#endif
#region Private Methods
/// <summary>
/// Clona articolo
/// </summary>
/// <param name="curRec"></param>
protected void DoClone(ItemModel curRec)
private void DoClone(ItemModel curRec)
{
editRecord = new ItemModel()
{
@@ -65,11 +96,16 @@ namespace Lux.UI.Components.Compo.Item
};
}
private string doCloneCss(ItemModel item)
{
return item.ItemType == Enums.ItemClassType.Bom ? "btn-warning" : "btn-success";
}
/// <summary>
/// impossta record x eliminazione
/// </summary>
/// <param name="selRec"></param>
protected async Task DoDelete(ItemModel selRec)
private async Task DoDelete(ItemModel selRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler eliminare il record? Dettagli: {selRec.ItemID} | {selRec.CodGroup} | {selRec.ItemType} | {selRec.ExtItemCode}"))
return;
@@ -86,83 +122,22 @@ namespace Lux.UI.Components.Compo.Item
/// Edit articolo selezionato
/// </summary>
/// <param name="curRec"></param>
protected void DoEdit(ItemModel curRec)
private Task DoEdit(ItemModel curRec)
{
editRecord = curRec;
return EC_EditReq.InvokeAsync(editRecord);
}
/// <summary>
/// Reset selezione
/// </summary>
protected void DoReset()
private Task DoReset()
{
editRecord = null;
return EC_EditReq.InvokeAsync(editRecord);
}
/// <summary>
/// Selezione articolo x display info
/// </summary>
/// <param name="curRec"></param>
protected void DoSelect(ItemModel curRec)
{
selRecord = curRec;
}
protected override async Task OnParametersSetAsync()
{
if (!SelFilt.Equals(actFilt) || true)
{
actFilt = SelFilt;
await ReloadData();
UpdateTable();
}
}
protected void SaveNumRec(int newNum)
{
numRecord = newNum;
UpdateTable();
}
protected void SavePage(int newNum)
{
currPage = newNum;
UpdateTable();
}
#endregion Protected Methods
#region Private Fields
private FiltSelect actFilt = new FiltSelect();
private int currPage = 1;
private ItemModel? editRecord = null;
private bool isLoading = false;
private int numRecord = 10;
private ItemModel? selRecord = null;
private int totalCount = 0;
#endregion Private Fields
#region Private Methods
private async Task DoCancel()
{
await ResetEdit();
UpdateTable();
}
private string doCloneCss(ItemModel item)
{
return item.ItemType == Enums.ItemClassType.Bom ? "btn-warning" : "btn-success";
}
#if false
private async Task DoSave(ItemModel currRec)
{
// salvo
@@ -170,6 +145,16 @@ namespace Lux.UI.Components.Compo.Item
await ResetEdit();
UpdateTable();
}
#endif
/// <summary>
/// Selezione articolo x display info
/// </summary>
/// <param name="curRec"></param>
private void DoSelect(ItemModel curRec)
{
selRecord = curRec;
}
private async Task ReloadData()
{
@@ -193,6 +178,19 @@ namespace Lux.UI.Components.Compo.Item
// reset edit
editRecord = null;
await ReloadData();
await EC_EditReq.InvokeAsync(editRecord);
}
private void SaveNumRec(int newNum)
{
numRecord = newNum;
UpdateTable();
}
private void SavePage(int newNum)
{
currPage = newNum;
UpdateTable();
}
/// <summary>
@@ -0,0 +1,103 @@
<div class="rounded rounded-3 bg-secondary bg-opacity-25 bg-gradient p-2 m-0 shadow">
@if (CurrRecord != null)
{
<div><span class="fs-5"># <b>@(CurrRecord?.SellingItemID)</b></span> | Codice @CurrRecord.ItemCode</div>
<div class="row g-1">
<div class="col-md-2">
<div class="form-floating">
<select @bind="@CurrRecord.Envir" class="form-select">
<option value="NULL">--- Sel. Envir ---</option>
@foreach (var item in Enum.GetValues(typeof(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS))
.Cast<EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS>()
.Where(e => Convert.ToInt32(e) != 0))
{
<option value="@item">@item</option>
}
</select>
<label class="small bg-opacity-50">Envir</label>
</div>
</div>
<div class="col-md-1">
@* <div class="form-floating">
<select @bind="@CurrRecord.ItemType" class="form-select" disabled="@CurrRecord.IsProtected">
@foreach (var sType in Enum.GetValues(typeof(EgwCoreLib.Lux.Core.Enums.ItemClassType)))
{
<option value="@sType">@sType</option>
}
</select>
<label class="small bg-opacity-50">Tipo</label>
</div> *@
</div>
<div class="col-md-1">
<div class="form-floating">
<div class="form-control ">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" checked="@CurrRecord.IsService">
</div>
</div>
<label class="small bg-opacity-50">Serv</label>
</div>
</div>
<div class="col-md-2">
<div class="form-floating">
<input type="text" class="form-control" @bind="@CurrRecord.ExtItemCode" disabled="@CurrRecord.IsProtected">
<label class="small bg-opacity-50">ItemCode</label>
</div>
</div>
<div class="col-md-3">
<div class="form-floating">
<input type="text" class="form-control" @bind="@CurrRecord.SupplCode" disabled="@CurrRecord.IsProtected">
<label class="small bg-opacity-50">Suppl.Code</label>
</div>
</div>
<div class="col-md-2">
<div class="form-floating">
<InputDouble CssClass="form-control form-control-lg text-end" Decimals="2" Step="0.05" @bind-Value="@CurrRecord.Cost"></InputDouble>
@* <input type="number" class="form-control text-end" @bind="@CurrRecord.Cost"> *@
<label class="small bg-opacity-50">Costo</label>
</div>
</div>
<div class="col-md-1">
<div class="form-floating">
<InputPercent CssClass="form-control form-control-lg text-end" ForceInvariantParsing="true" Decimals="1" @bind-Value="@MarginDec"></InputPercent>
@* <input type="number" class="form-control text-end" @bind="@CurrRecord.Margin"> *@
<label class="small bg-opacity-50">Margine</label>
</div>
</div>
<div class="col-md-6">
<div class="form-floating">
<input type="text" class="form-control" @bind="@CurrRecord.Description" disabled="@CurrRecord.IsProtected">
<label class="small bg-opacity-50">Descrizione</label>
</div>
</div>
@* <div class="col-md-1">
<div class="form-floating">
<input type="number" class="form-control text-end" @bind="@CurrRecord.QtyMin">
<label class="small bg-opacity-50">Qty min</label>
</div>
</div>
<div class="col-md-1">
<div class="form-floating">
<input type="number" class="form-control text-end" @bind="@CurrRecord.QtyMax">
<label class="small bg-opacity-50">Qty MAX</label>
</div>
</div> *@
<div class="col-md-1">
<div class="form-floating">
<input type="text" class="form-control text-end" @bind="@CurrRecord.UM">
<label class="small bg-opacity-50">UM</label>
</div>
</div>
<div class="col-md-3">
<div class="row g-1 py-1">
<div class="col-md-6">
<button class="btn btn-lg btn-success w-100" @onclick="DoSave">Save</button>
</div>
<div class="col-md-6">
<button class="btn btn-lg btn-warning w-100" @onclick="DoCancel">Cancel</button>
</div>
</div>
</div>
</div>
}
</div>
@@ -0,0 +1,58 @@
using EgwCoreLib.Lux.Data.DbModel.Items;
using Microsoft.AspNetCore.Components;
namespace Lux.UI.Components.Compo.Item
{
public partial class SellingItemEdit
{
#region Public Properties
[Parameter]
public SellingItemModel? CurrRecord { get; set; } = null;
[Parameter]
public EventCallback<bool> EC_Close { get; set; }
[Parameter]
public EventCallback<SellingItemModel> EC_Updated { get; set; }
[Parameter]
public List<ItemGroupModel> ListItemGroup { get; set; } = null!;
#endregion Public Properties
#region Private Properties
/// <summary>
/// Wrapper per valore margine in modalità decimal
/// </summary>
private decimal MarginDec
{
get => CurrRecord != null ? (decimal)CurrRecord.Margin : 0M;
set
{
if (CurrRecord != null)
{
CurrRecord.Margin = (double)value;
}
}
}
#endregion Private Properties
#region Private Methods
private Task DoCancel()
{
return EC_Close.InvokeAsync(true);
}
private Task DoSave()
{
// richiede di effettuare salvataggio record...
return EC_Updated.InvokeAsync(CurrRecord);
}
#endregion Private Methods
}
}
@@ -407,8 +407,10 @@ namespace Lux.UI.Components.Compo.Templates
await DLService.TemplateRowUpdateSerStructAsync(EditRecord.TemplateRowID, prevJwd);
// salvo nel record corrente!
EditRecord.SerStruct = prevJwd;
#if false
// temporaneamenteo NON ricalcolo la BOM (NON mi serve)
//updateBom = true;
//updateBom = true;
#endif
}
else
// altrimenti ricalcolo valore salvato
@@ -416,10 +418,12 @@ namespace Lux.UI.Components.Compo.Templates
prevJwd = EditRecord.SerStruct;
CurrData.CurrJwd = EditRecord.SerStruct;
}
#if false
if (updateBom)
{
await reqBomUpdate(EditRecord);
}
}
#endif
// aggiorno nel dizionari
if (reqDict.ContainsKey("SerializedData"))
{
@@ -454,10 +458,26 @@ namespace Lux.UI.Components.Compo.Templates
private async Task CloseEditJwd(DataSave infoSave)
{
prevJwd = infoSave.currJwd;
#if false
// rileggo dati...
int trID = EditRecord?.TemplateRowID ?? 0;
#endif
// reset preview
await CloseEdit(infoSave.ForceSave);
//await InvokeAsync(StateHasChanged);
await Task.Delay(50);
#if false
await ReloadData();
// x il corrente chiamo refresh...
if (trID > 0 && AllRecords.Count > 0)
{
EditRecord = AllRecords.FirstOrDefault(x => x.TemplateRowID == trID);
if (EditRecord != null)
{
// chiamo comunque update IMG
await reqImgUpdate(EditRecord);
}
}
#endif
await Task.Delay(200);
CurrData.SvgPreview = "";
}
@@ -1179,6 +1199,10 @@ namespace Lux.UI.Components.Compo.Templates
{
case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW:
DictExec.Add(serKey, currRec.SerStruct);
if (DictExec.ContainsKey(serKey))
{
rawData = DictExec[serKey];
}
break;
case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM:
+9 -1
View File
@@ -24,10 +24,18 @@
<div class="card-body">
@if (showItemsBuy)
{
<ItemMan SelFilt="CurrFilt" ListItemGroup="ListItemGroup"></ItemMan>
if (editRecItem != null)
{
<ItemEdit CurrRecord="editRecItem" ListItemGroup="ListItemGroup" EC_Updated="DoSaveItem" EC_Close="DoCancel"></ItemEdit>
}
<ItemMan SelFilt="CurrFilt" ListItemGroup="ListItemGroup" EC_EditReq="EditItem"></ItemMan>
}
else
{
if (editRecSellItem != null)
{
<SellingItemEdit CurrRecord="editRecSellItem" ListItemGroup="ListItemGroup" EC_Updated="DoSaveSelItem" EC_Close="DoCancel"></SellingItemEdit>
}
<SellingItemMan SelFilt="CurrFilt" ListItemGroup="ListItemGroup"></SellingItemMan>
}
</div>
+79 -27
View File
@@ -9,44 +9,22 @@ namespace Lux.UI.Components.Pages
{
#region Protected Methods
protected void DoAdd()
{
editRecord = new ItemModel()
{
CodGroup = ListItemGroup.FirstOrDefault()?.CodGroup ?? "",
ItemType = EgwCoreLib.Lux.Core.Enums.ItemClassType.ND,
IsService = false,
ItemCode = 0,
ExtItemCode = "NEW-ITEM",
SupplCode = "",
Description = $"Nuovo ITEM {DateTime.Today:ddd yyyy.MM.dd}",
Cost = 0,
Margin = 0,
QtyMin = 0,
QtyMax = 0,
UM = "#"
};
}
protected override Task OnInitializedAsync()
{
isLoading = true;
return ReloadBaseData();
}
protected void UpdateFilt(FiltSelect newFilt)
{
isLoading = true;
CurrFilt = newFilt;
isLoading = false;
}
#endregion Protected Methods
#region Private Fields
private ItemModel? editRecord = null;
private ItemModel? editRecItem = null;
private SellingItemModel? editRecSellItem = null;
private bool isLoading = false;
private List<ItemGroupModel> ListItemGroup = new List<ItemGroupModel>();
/// <summary>
@@ -75,11 +53,85 @@ namespace Lux.UI.Components.Pages
#region Private Methods
private void DoAdd()
{
if (showItemsBuy)
{
editRecItem = new ItemModel()
{
CodGroup = ListItemGroup.FirstOrDefault()?.CodGroup ?? "",
ItemType = EgwCoreLib.Lux.Core.Enums.ItemClassType.ND,
IsService = false,
ItemCode = 0,
ExtItemCode = "NEW-ITEM",
SupplCode = "",
Description = $"Nuovo ITEM {DateTime.Today:ddd yyyy.MM.dd}",
Cost = 0,
Margin = 0,
QtyMin = 0,
QtyMax = 0,
UM = "#"
};
}
else
{
editRecSellItem = new SellingItemModel()
{
Cost = 0,
Description = $"Nuovo PRODOTTO {DateTime.Today:ddd yyyy.MM.dd}",
ExtItemCode = "NEW-PROD",
Envir = CurrFilt.Envir,
IsService = false,
ItemCode = 0,
Margin = 0,
SupplCode = "",
UM = "#"
};
}
}
private void DoCancel()
{
editRecItem = null;
editRecSellItem = null;
}
private async Task DoSaveItem(ItemModel currRec)
{
// salvo
await DLService.ItemUpsertAsync(currRec);
editRecItem = null;
}
private async Task DoSaveSelItem(SellingItemModel currRec)
{
// salvo
await DLService.SellingItemUpsertAsync(currRec);
editRecItem = null;
}
private void EditItem(ItemModel editRec)
{
editRecItem = editRec;
}
private void EditSellItem(SellingItemModel editRec)
{
editRecSellItem = editRec;
}
private async Task ReloadBaseData()
{
ListItemGroup = await DLService.ItemGroupGetAllAsync();
}
private void UpdateFilt(FiltSelect newFilt)
{
isLoading = true;
CurrFilt = newFilt;
isLoading = false;
}
#endregion Private Methods
}
}
+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.2603.0914</Version>
<Version>1.1.2603.0916</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 1.1.2603.0914</h4>
<h4>Versione: 1.1.2603.0916</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.1.2603.0914
1.1.2603.0916
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2603.0914</version>
<version>1.1.2603.0916</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>