diff --git a/WebWindowComplex/DTO/LivePayload.cs b/WebWindowComplex/DTO/LivePayload.cs index ddf6f30..f1f3da8 100644 --- a/WebWindowComplex/DTO/LivePayload.cs +++ b/WebWindowComplex/DTO/LivePayload.cs @@ -11,6 +11,7 @@ namespace WebWindowComplex.DTO /// public class LivePayload { + #region Public Properties /// /// JWD Corrente @@ -22,6 +23,36 @@ namespace WebWindowComplex.DTO /// public string SvgPreview { get; set; } = string.Empty; + #endregion Public Properties + + #region Public Methods + + /// + /// Override metodo di equality + /// + /// + /// + public override bool Equals(object obj) + { + if (!(obj is LivePayload item)) + return false; + + if (CurrJwd != item.CurrJwd) + return false; + if (SvgPreview != item.SvgPreview) + return false; + + return true; + } + + /// + /// Override hash method + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } /// /// Verifica di validità del Payload (solo jwd) @@ -32,5 +63,7 @@ namespace WebWindowComplex.DTO bool jwdOK = !string.IsNullOrEmpty(CurrJwd); return jwdOK; } + + #endregion Public Methods } -} +} \ No newline at end of file diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 054ce9f..3019e57 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -63,6 +63,28 @@ namespace WebWindowComplex #endregion Public Properties + #region Public Methods + + public void Dispose() + { + if (m_CurrWindow != null) + { + m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; + m_CurrWindow = null; + } + } + + #endregion Public Methods + + #region Protected Fields + + /// + /// Dati live precedenti x comparazione + /// + protected LivePayload? prevLiveData = null; + + #endregion Protected Fields + #if false [Parameter] public string CurrJwd @@ -179,19 +201,6 @@ namespace WebWindowComplex public string? IN_SelGlass { get; set; } = null; #endif - #region Public Methods - - public void Dispose() - { - if (m_CurrWindow != null) - { - m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; - m_CurrWindow = null; - } - } - - #endregion Public Methods - #region Protected Enums protected enum CompileStep @@ -689,22 +698,29 @@ namespace WebWindowComplex /// protected override async Task OnParametersSetAsync() { + bool updateSvg = false; // controllo elenchi BasePayload siano validi... if (ListPayload.IsValid()) { // controllo sia popolato anche per la componente LIVE if (LiveData.IsValid()) { - m_CurrJwd = LiveData.CurrJwd; - m_SelSVG = LiveData.SvgPreview; - // Aggiornati parametri di ingresso selezionati - UpdateSelParameter(); - JsonWindow WindowFromJson = JsonConvert.DeserializeObject(m_CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); - setCurrWindow(WindowFromJson); - //SOLO SE non sono in edit... - if (!editLock) + // SOLO SE modificato live data... + if (prevLiveData == null || !prevLiveData.Equals(LiveData)) { - currStep = CompileStep.Tree; + prevLiveData = LiveData; + m_CurrJwd = LiveData.CurrJwd; + m_SelSVG = LiveData.SvgPreview; + // Aggiornati parametri di ingresso selezionati + UpdateSelParameter(); + JsonWindow WindowFromJson = JsonConvert.DeserializeObject(m_CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + setCurrWindow(WindowFromJson); + //SOLO SE non sono in edit... + if (!editLock) + { + currStep = CompileStep.Tree; + } + updateSvg = true; } } else if (CurrSelection != null && CurrSelection.Template != null) @@ -719,11 +735,15 @@ namespace WebWindowComplex setCurrWindow(WindowFromJson); currStep = CompileStep.Template; } + updateSvg = true; } if (SashList.Count > 0) currAnta = 0; - await DoPreviewSvg(); + if (updateSvg) + { + await DoPreviewSvg(); + } } } @@ -774,16 +794,24 @@ namespace WebWindowComplex /// protected void UpdateSelParameter() { + Sash.m_HardwareCompleteList = ListPayload.Hardware; + Sash.s_FamilyHardwareList = ListPayload.FamilyHardware; if (CurrSelection != null && CurrSelection.IsValid()) { SelFamilyHardware = CurrSelection.FamilyHardware; SelColorMaterial = CurrSelection.ColorMaterial ?? ""; SelMaterial = CurrSelection.Material ?? ""; SelGlass = CurrSelection.Glass ?? ""; - Sash.m_HardwareCompleteList = ListPayload.Hardware; - Sash.s_FamilyHardwareList = ListPayload.FamilyHardware; Sash.s_SelFamilyHW = CurrSelection.FamilyHardware ?? ""; } + else + { + // se ho elementi, seleziono la prima + if (ListPayload.FamilyHardware.Count > 0) + { + Sash.s_SelFamilyHW = Sash.s_FamilyHardwareList.FirstOrDefault(); + } + } } #endregion Protected Methods diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 2048541..12fd4fa 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.10.715 + 2.7.10.717 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -91,6 +91,13 @@ + + + + + + + diff --git a/WebWindowComplex/Window.cs b/WebWindowComplex/Window.cs index 279104f..ddfb77f 100644 --- a/WebWindowComplex/Window.cs +++ b/WebWindowComplex/Window.cs @@ -1316,28 +1316,31 @@ namespace WebWindowComplex public void RefreshHardwareList() { - m_HardwareList.Clear(); - string sSashShape = FindSashShape(); - string sOpeningType = ConvertOpeningType(); - var iComp = StringComparison.InvariantCultureIgnoreCase; - var rawList = m_HardwareCompleteList - .Where(x => x.Id == "000000" || - (!string.IsNullOrEmpty(s_SelFamilyHW) && x.FamilyName.Equals(s_SelFamilyHW, iComp) && x.SashQty == nSashQty && x.Shape.Equals(sSashShape, iComp) && x.OpeningType.Equals(sOpeningType, iComp)) - ) - .ToList(); - if (rawList != null && rawList.Count > 0) + if (m_HardwareCompleteList != null && m_HardwareCompleteList.Count > 0) { - m_HardwareList = new ObservableCollection(rawList); - } - else - { - m_HardwareList = new ObservableCollection(); - } + m_HardwareList.Clear(); + string sSashShape = FindSashShape(); + string sOpeningType = ConvertOpeningType(); + var iComp = StringComparison.InvariantCultureIgnoreCase; + var rawList = m_HardwareCompleteList + .Where(x => x.Id == "000000" || + (!string.IsNullOrEmpty(s_SelFamilyHW) && x.FamilyName.Equals(s_SelFamilyHW, iComp) && x.SashQty == nSashQty && x.Shape.Equals(sSashShape, iComp) && x.OpeningType.Equals(sOpeningType, iComp)) + ) + .ToList(); + if (rawList != null && rawList.Count > 0) + { + m_HardwareList = new ObservableCollection(rawList); + } + else + { + m_HardwareList = new ObservableCollection(); + } #if false m_HardwareList = new ObservableCollection(from Hardware in m_HardwareCompleteList where Hardware.Id == "000000" || (Hardware.FamilyName == s_SelFamilyHW && Hardware.SashQty == nSashQty && Hardware.Shape == sSashShape && Hardware.OpeningType == sOpeningType) select Hardware); #endif + } } internal void RefreshHardwareOptionList() diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index c9c2d43..64c7f5c 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.10.715 + 2.7.10.717 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -106,6 +106,13 @@ + + + + + + +