From e3042e7d9e8cce049e987d4c2c0f5c78ba79762d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 10 Oct 2025 10:47:30 +0200 Subject: [PATCH] COmpletata prima review blocco gestione errori/warnings --- Test.UI/Data/AntaDoppia.jwd | 2 +- WebWindowComplex/TableComp.razor | 39 +++- WebWindowComplex/TableComp.razor.cs | 188 +++++++++++++----- WebWindowComplex/WebWindowComplex.csproj | 14 +- .../WebWindowConfigurator.csproj | 15 +- 5 files changed, 197 insertions(+), 61 deletions(-) diff --git a/Test.UI/Data/AntaDoppia.jwd b/Test.UI/Data/AntaDoppia.jwd index 21d2d91..141654e 100644 --- a/Test.UI/Data/AntaDoppia.jwd +++ b/Test.UI/Data/AntaDoppia.jwd @@ -1,7 +1,7 @@ { "ProfilePath": "Profilo78", "Material": "Pino", - "ColorMaterial": "Black", + "ColorMaterial": "Nero", "Glass": "Vetro BE 2S 4T/16/4T", "AreaList": [ { diff --git a/WebWindowComplex/TableComp.razor b/WebWindowComplex/TableComp.razor index 4015483..8b262f7 100644 --- a/WebWindowComplex/TableComp.razor +++ b/WebWindowComplex/TableComp.razor @@ -5,17 +5,31 @@ } else { - - @if (validErrors != null && validErrors.Count > 0) + if (listErrPre != null && listErrPre.Count > 0) {
Errori validazione!
    - @foreach (var item in validErrors) + @foreach (var item in listErrPre) { -
  • @item
  • +
  • @item.Value
  • + } +
+
+
+ } + else if (listErrLink != null && listErrLink.Count > 0) + { +
+
Errore configurazione:
+
+ +
    + @foreach (var item in listErrLink) + { +
  • @item.Value
  • }
@@ -860,7 +874,7 @@
- @foreach (string colorMaterial in ListPayload.ColorMaterial) { @@ -896,6 +910,21 @@ @outSvg
} + if (listWarnings != null && listWarnings.Count > 0) + { +
+
Mancata corrispondenza valori:
+
+ +
    + @foreach (var item in listWarnings) + { +
  • @item.Value
  • + } +
+
+
+ } } }
diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 0845818..40d9aa1 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -53,7 +53,7 @@ namespace WebWindowComplex /// Sollevo evento errore validazione con una lista di errori rilevati /// [Parameter] - public EventCallback> EC_ValidError { get; set; } + public EventCallback> EC_ValidError { get; set; } /// /// Elenco anagrafiche di base @@ -550,6 +550,11 @@ namespace WebWindowComplex await EC_OnSelectedTemplate.InvokeAsync(newSel); } + protected override void OnAfterRender(bool firstRender) + { + isLoading = false; + } + /// /// Primo init componente /// @@ -559,19 +564,11 @@ namespace WebWindowComplex editLock = false; // reset variabile errori bError = false; - validErrors = new List(); + listErrPre = new Dictionary(); + listErrLink = new Dictionary(); + listWarnings = new Dictionary(); } - protected override void OnAfterRender(bool firstRender) - { - isLoading = false; - } - - /// - /// Booleana fase loading - /// - private bool isLoading = false; - /// /// Gestione update post ricezione parametri da controllo chiamante /// @@ -582,7 +579,9 @@ namespace WebWindowComplex if (ListPayload.IsPopulated() && LiveData.IsValid()) { bool updateSvg = false; - validErrors = new List(); + listErrPre = new Dictionary(); + listErrLink = new Dictionary(); + listWarnings = new Dictionary(); // controllo elenchi BasePayload siano validi... if (ListPayload.IsValid()) { @@ -600,15 +599,27 @@ namespace WebWindowComplex m_SelSVG = LiveData.SvgPreview; // Aggiornati parametri di ingresso selezionati UpdateSelParameter(); - JsonWindow WindowFromJson = JsonConvert.DeserializeObject(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); - setCurrWindow(WindowFromJson); - //SOLO SE non sono in edit... - if (!editLock) + JsonWindow WindowFromJson = new JsonWindow("", "", "", ""); + // provo a deserializzare + 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}"); + } + updateSvg = true; } + checkWarnings(); } else if (CurrSelection != null && CurrSelection.Template != null) { @@ -618,9 +629,19 @@ namespace WebWindowComplex m_SelTemplate = CurrSelection.Template; // Aggiornamento parametri di ingresso selezionati UpdateSelParameter(); - JsonWindow WindowFromJson = JsonConvert.DeserializeObject(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); - setCurrWindow(WindowFromJson); - currStep = CompileStep.Template; + JsonWindow WindowFromJson = new JsonWindow("", "", "", ""); + // provo a deserializzare + try + { + WindowFromJson = JsonConvert.DeserializeObject(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + setCurrWindow(WindowFromJson); + currStep = CompileStep.Template; + } + // altrimenti errore! + catch (Exception ex) + { + listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}"); + } } updateSvg = true; } @@ -635,38 +656,72 @@ namespace WebWindowComplex } else { - // verifico 1:1 le liste e indico cosa manca - if (ListPayload.Hardware == null || ListPayload.Hardware.Count == 0) - { - validErrors.Add("Missing Hardware List!"); - } - else - { - if (ListPayload.FamilyHardware == null || ListPayload.FamilyHardware.Count == 0) - { - validErrors.Add("Missing Famly HW List!"); - } - } - if (ListPayload.Glass == null || ListPayload.Glass.Count == 0) - { - validErrors.Add("Missing Glass List!"); - } - if (ListPayload.Material == null || ListPayload.Material.Count == 0) - { - validErrors.Add("Missing Material List!"); - } - if (ListPayload.ColorMaterial == null || ListPayload.ColorMaterial.Count == 0) - { - validErrors.Add("Missing ColorMaterial List!"); - } + checkErrorPre(); } isLoading = false; } } + /// - /// Elenco errori preliminari di validazione + /// Verifica errori prelimionari per mostrare dove sia il problema /// - private List validErrors = new List(); + private void checkErrorPre() + { + // verifico 1:1 le liste e indico cosa manca + if (ListPayload.Hardware == null || ListPayload.Hardware.Count == 0) + { + listErrPre.Add("Hardware", "Missing Hardware List!"); + } + else + { + if (ListPayload.FamilyHardware == null || ListPayload.FamilyHardware.Count == 0) + { + listErrPre.Add("FamilyHardware", "Missing Famly HW List!"); + } + } + if (ListPayload.Glass == null || ListPayload.Glass.Count == 0) + { + listErrPre.Add("Glass", "Missing Glass List!"); + } + if (ListPayload.Material == null || ListPayload.Material.Count == 0) + { + listErrPre.Add("Material", "Missing Material List!"); + } + if (ListPayload.ColorMaterial == null || ListPayload.ColorMaterial.Count == 0) + { + listErrPre.Add("ColorMaterial", "Missing ColorMaterial List!"); + } + } + + /// + /// Verifica warning minori (es coerenza colori...) + /// + private void checkWarnings() + { + // verifico 1:1 le liste e i valori siano coerenti... + if (ListPayload.ColorMaterial != null && ListPayload.ColorMaterial.Count > 0) + { + // verifico colore attuale sia consistente... + if (m_CurrWindow != null) + { + if (!ListPayload.ColorMaterial.Contains(m_CurrWindow.sColorMaterial)) + { + listWarnings.Add("ColorMaterial", $"Missing Color: {m_CurrWindow.sColorMaterial}"); + } + } + } + } + + /// + /// Calcola CSS warning + /// + /// + /// + protected string cssValid(string fKey) + { + return listWarnings.ContainsKey(fKey) ? "border border-danger" : ""; + } + protected void setCurrWindow(JsonWindow WindowFromJson) { if (m_CurrWindow != null) @@ -729,12 +784,40 @@ namespace WebWindowComplex #region Private Fields + private bool bError = false; + private int currAnta = 0; + private int currFill = -1; + private int currSash = -1; + private int currSplit = -1; + private CompileStep currStep; + private bool editLock = false; + + /// + /// Booleana fase loading + /// + private bool isLoading = false; + + /// + /// ELenco errori di coerenza/link dati (vanno risolti per disegnare/procedere) + /// + private Dictionary listErrLink = new Dictionary(); + + /// + /// Elenco errori preliminari (mancano elementi di base di validazione modello dati)) + /// + private Dictionary listErrPre = new Dictionary(); + + /// + /// Elenco warnings non bloccanti + /// + private Dictionary listWarnings = new Dictionary(); + private List m_FillList = new List(); private Frame? m_Frame; @@ -772,6 +855,11 @@ namespace WebWindowComplex #region Private Methods + private void AddSashToFrame(Frame f) + { + bError = f.AddSash(); + } + /// /// Metodo per andare allo step successivo /// @@ -1060,12 +1148,6 @@ namespace WebWindowComplex currStep = CompileStep.Tree; } - private bool bError = false; - private void AddSashToFrame(Frame f) - { - bError = f.AddSash(); - } - /// /// Metodo per scambiare due aree di uno split /// diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index d6131cb..b323ddc 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.10.1009 + 2.7.10.1010 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -152,6 +152,18 @@ + + + + + + + + + + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index be92b44..33c9542 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.10.1009 + 2.7.10.1010 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -187,6 +187,19 @@ + + + + + + + + + + + + +