From d4e1a73d5763fc21a2fa2954e29b94482f96a097 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 3 Nov 2025 16:42:37 +0100 Subject: [PATCH] Update catena eventi x richiesta reset dizionario --- Test.UI/Components/Pages/EditJWD.razor | 1 + Test.UI/Components/Pages/EditJWD.razor.cs | 22 ++- WebWindowComplex/Compo/CardFrame.razor.cs | 42 ++++-- WebWindowComplex/DTO/LivePayload.cs | 19 +++ WebWindowComplex/TableComp.razor | 1 + WebWindowComplex/TableComp.razor.cs | 132 ++++++++++-------- WebWindowComplex/WebWindowComplex.csproj | 8 +- .../WebWindowConfigurator.csproj | 8 +- 8 files changed, 159 insertions(+), 74 deletions(-) diff --git a/Test.UI/Components/Pages/EditJWD.razor b/Test.UI/Components/Pages/EditJWD.razor index 9ea528b..71ea354 100644 --- a/Test.UI/Components/Pages/EditJWD.razor +++ b/Test.UI/Components/Pages/EditJWD.razor @@ -68,6 +68,7 @@ diff --git a/Test.UI/Components/Pages/EditJWD.razor.cs b/Test.UI/Components/Pages/EditJWD.razor.cs index 44beea9..485620d 100644 --- a/Test.UI/Components/Pages/EditJWD.razor.cs +++ b/Test.UI/Components/Pages/EditJWD.razor.cs @@ -235,6 +235,26 @@ namespace Test.UI.Components.Pages hwOptionChannel = Config.GetValue("ServerConf:HwOptChannel") ?? ""; } + /// + /// Esecuzione azione richiesta + /// + /// Azione richiesta + private void DoAction(TableComp.DataAction actReq) + { + switch (actReq) + { + case TableComp.DataAction.None: + break; + + case TableComp.DataAction.ResetDictShape: + CurrData.DictShape = new Dictionary(); + break; + + default: + break; + } + } + /// /// Esecuzione richiesta /// @@ -279,7 +299,7 @@ namespace Test.UI.Components.Pages /*-------------------------------------- * FixMe Todo levare !!! * - try/catch deserializzazione - * - se fallisse metto le stesse opzioni a ttuti i GroupId + * - se fallisse metto le stesse opzioni a tutti i GroupId **--------------------------------------*/ Dictionary rawDict = new Dictionary(); try diff --git a/WebWindowComplex/Compo/CardFrame.razor.cs b/WebWindowComplex/Compo/CardFrame.razor.cs index efacc89..ba5991b 100644 --- a/WebWindowComplex/Compo/CardFrame.razor.cs +++ b/WebWindowComplex/Compo/CardFrame.razor.cs @@ -31,6 +31,12 @@ namespace WebWindowComplex.Compo [Parameter] public EventCallback EC_ReqClose { get; set; } + /// + /// Evento per richiedere reset dizionario Shape + /// + [Parameter] + public EventCallback EC_ReqResetDictShape { get; set; } + /// /// Evento per aggiornare info frame (es cambaire tutti i Joints) /// @@ -63,6 +69,27 @@ namespace WebWindowComplex.Compo #endregion Public Properties + #region Protected Properties + + protected int SelShapeIndex + { + get => FrameWindow.SelShapeIndex; + set + { + if (FrameWindow.SelShapeIndex != value) + { + // richiesta reset dict shape + _ = EC_ReqResetDictShape.InvokeAsync(true); + //foreach(var s in SashList) + // s.SelHardwareFromId = "000000"; + FrameWindow.SelShapeIndex = value; + _ = EC_UpdateShape.InvokeAsync(FrameWindow); + } + } + } + + #endregion Protected Properties + #region Private Methods /// @@ -123,21 +150,6 @@ namespace WebWindowComplex.Compo } } - protected int SelShapeIndex - { - get => FrameWindow.SelShapeIndex; - set - { - if (FrameWindow.SelShapeIndex != value) - { - //foreach(var s in SashList) - // s.SelHardwareFromId = "000000"; - FrameWindow.SelShapeIndex = value; - _ = EC_UpdateShape.InvokeAsync(FrameWindow); - } - } - } - /// /// Report aggiornamento joint /// diff --git a/WebWindowComplex/DTO/LivePayload.cs b/WebWindowComplex/DTO/LivePayload.cs index 2a35b0f..0a4172b 100644 --- a/WebWindowComplex/DTO/LivePayload.cs +++ b/WebWindowComplex/DTO/LivePayload.cs @@ -60,6 +60,25 @@ namespace WebWindowComplex.DTO return true; } + /// + /// Metodo di equality limitato al controllo del JWD + /// + /// + /// + public bool JwdEqual(object obj) + { + if ((obj == null)) + return false; + + if (!(obj is LivePayload item)) + return false; + + if (CurrJwd != item.CurrJwd) + return false; + + return true; + } + /// /// Override hash method /// diff --git a/WebWindowComplex/TableComp.razor b/WebWindowComplex/TableComp.razor index c63c04a..04d6e9d 100644 --- a/WebWindowComplex/TableComp.razor +++ b/WebWindowComplex/TableComp.razor @@ -134,6 +134,7 @@ EC_AddSash="() => AddSashToFrame(FrameWindow!)" EC_AddSplit="() => AddSplitToFrame(FrameWindow!)" EC_ReqClose="ReturnTree" + EC_ReqResetDictShape="ReqResetDict" EC_UpdateShape="UpdateShape" EC_UpdateFrame="UpdateFrame"> diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index e244d2c..88c928c 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -13,6 +13,23 @@ namespace WebWindowComplex { public partial class TableComp : IDisposable { + #region Public Enums + + public enum DataAction + { + /// + /// Nessuna richiesta + /// + None = 0, + + /// + /// Reset dizionario shape + /// + ResetDictShape + } + + #endregion Public Enums + #region Public Properties /// @@ -27,6 +44,12 @@ namespace WebWindowComplex [Parameter] public SelectPayload? CurrSelection { get; set; } = null; + /// + /// Richiesta azione al parent + /// + [Parameter] + public EventCallback EC_ActionReq { get; set; } + /// /// Richiesta update da JWD (SVG, calcoli vari...) /// @@ -592,8 +615,6 @@ namespace WebWindowComplex listWarnings = new Dictionary(); } - private bool firstDisplay = true; - /// /// Gestione update post ricezione parametri da controllo chiamante /// @@ -611,8 +632,9 @@ namespace WebWindowComplex if (ListPayload.IsValid()) { // SOLO SE modificato live data... - if (prevLiveData == null || !prevLiveData.Equals(LiveData)) + if (prevLiveData == null || !prevLiveData.Equals(LiveData)) { + bool needDeser = prevLiveData == null || !prevLiveData.JwdEqual(LiveData); updRequested = true; prevLiveData = new LivePayload() { @@ -624,22 +646,29 @@ namespace WebWindowComplex // Aggiornati parametri di ingresso selezionati UpdateSelParameter(); - JsonWindow WindowFromJson = new JsonWindow("", "", "", ""); - // provo a deserializzare - try + // provo a deserializzare SE necessario + if (needDeser || true) { - WindowFromJson = JsonConvert.DeserializeObject(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); - setCurrWindow(WindowFromJson); - //SOLO SE non sono in edit... - if (!editLock) + JsonWindow WindowFromJson = new JsonWindow("", "", "", ""); + try { - currStep = CompileStep.Tree; + WindowFromJson = JsonConvert.DeserializeObject(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + setCurrWindow(WindowFromJson); + //SOLO SE non sono in edit... + if (!editLock) + { + currStep = CompileStep.Tree; + } + } + // altrimenti errore! + catch (Exception ex) + { + listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}"); } } - // altrimenti errore! - catch (Exception ex) + else { - listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}"); + // usando m_currWindow (preesistente) impostare i parametri... } } checkWarnings(); @@ -649,7 +678,6 @@ namespace WebWindowComplex } if (updRequested) { - // se mancasse dizionario forme chiamo quello if (LiveData.DictShape.Count == 0) { @@ -665,21 +693,6 @@ namespace WebWindowComplex await DoReqShape(reqList); } } - //// se mancasse xml opzioni hardware lo chiedo - //else if (LiveData.DictOptionsXml.Count == 0) - //{ - // if (firstDisplay && isRendered) - // { - // firstDisplay = false; - // // preview SVG senza HW - // await DoPreviewSvg(true, true); - // } - // List reqList = SashList.Select(x => x.GroupId).ToList(); - // if (reqList.Count > 0) - // { - // await DoReqOptHardware(reqList); - // } - //} else { // chiedo SVG @@ -793,21 +806,18 @@ namespace WebWindowComplex #region Private Fields private int currAnta = 0; - private int currFill = -1; - private int currSash = -1; - private int currSplit = -1; - private CompileStep currStep; - private bool editLock = false; + private bool firstDisplay = true; /// /// Booleana fase loading /// private bool isLoading = false; + private bool isRendered = false; /// @@ -934,6 +944,18 @@ namespace WebWindowComplex return "btn btn-outline-secondary btn-sm"; } + /// + /// Prima chiamata alle opzioni hardware + /// + /// Group Id del sash group di cui si vuole Hw option + /// + private async Task CallFirstHwOpt(int groupId) + { + bool isFirst = true; + List reqList = new List() { groupId }; + await DoReqOptHardware(reqList, isFirst); + } + /// /// Metodo per settare tutti i Fill in contemporanea /// @@ -1102,14 +1124,6 @@ namespace WebWindowComplex return (currStep == CompileStep.Template) ? "col-8 d-grid px-2 d-md-flex justify-content-md-start" : "col-8 d-grid px-2 d-md-flex justify-content-md-start"; } - private void M_CurrWindow_OnPreview(object? sender, OnPreviewEventArgs e) - { - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}"); - Args.Add("Jwd", e.sJwd); - _ = EC_DoUpdate.InvokeAsync(Args); - } - private void M_CurrWindow_OnHwOption(object? sender, OnReqHwOptEventArgs e) { Dictionary Args = new Dictionary(); @@ -1118,7 +1132,15 @@ namespace WebWindowComplex Args.Add("Jwd", e.sJwd); string listGroupId = JsonConvert.SerializeObject(new List { e.nGroupId }); Args.Add("GroupId", listGroupId); - _ = EC_DoUpdate.InvokeAsync(Args); + _ = EC_DoUpdate.InvokeAsync(Args); + } + + private void M_CurrWindow_OnPreview(object? sender, OnPreviewEventArgs e) + { + Dictionary Args = new Dictionary(); + Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}"); + Args.Add("Jwd", e.sJwd); + _ = EC_DoUpdate.InvokeAsync(Args); } private void M_CurrWindow_OnShape(object? sender, OnReqShapeEventArgs e) @@ -1203,6 +1225,16 @@ namespace WebWindowComplex currStep = CompileStep.Tree; } + /// + /// Richiesta reset dizionario Shape con action + /// + /// + /// + private void ReqResetDict(bool args) + { + _ = EC_ActionReq.InvokeAsync(DataAction.ResetDictShape); + } + /// /// Ritorno step Tree /// @@ -1327,18 +1359,6 @@ namespace WebWindowComplex await DoReqOptHardware(reqList); } - /// - /// Prima chiamata alle opzioni hardware - /// - /// Group Id del sash group di cui si vuole Hw option - /// - private async Task CallFirstHwOpt(int groupId) - { - bool isFirst = true; - List reqList = new List() { groupId }; - await DoReqOptHardware(reqList, isFirst); - } - /// /// Aggiornamento Sash e Frame /// diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 732ce7a..debaa23 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.11.315 + 2.7.11.316 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -255,6 +255,12 @@ + + + + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index b3ffd65..597a76d 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.11.315 + 2.7.11.316 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -368,6 +368,12 @@ + + + + + +