Fix validazione preliminare liste parametri

This commit is contained in:
Samuele Locatelli
2025-10-10 09:40:51 +02:00
parent 843f043c12
commit 6a35c5c871
7 changed files with 1017 additions and 1004 deletions
+1 -13
View File
@@ -10,6 +10,7 @@
EC_OnClose="CloseObj">
</WebWindowComplex.TableComp>
@if (!string.IsNullOrEmpty(outClose))
{
<div class="alert alert-danger fs-4">
@@ -25,16 +26,3 @@ else if (!string.IsNullOrEmpty(outSave))
<p>
@currJwd
</p>
@*
IN_ColorMaterialList="@AvailColorMaterialList"
IN_FamilyHardwareList="@AvailFamilyHardwareList"
IN_GlassList="@AvailGlassList"
IN_HardwareList="@AvailHardwareList"
IN_MaterialList="@AvailMaterialList"
LiveSVG="@currSvg"
CurrJwd="@InitialJwd"
IN_SelFamilyHardware="@SelFamilyHardware"
IN_SelColorMaterial="@SelColorMaterial"
IN_SelMaterial="@SelMaterial"
IN_SelGlass="@SelGlass" *@
+51 -46
View File
@@ -14,9 +14,15 @@ namespace Test.UI.Components.Pages
{
public partial class EditJWD : IDisposable
{
#region Public Properties
#region Public Fields
public string InitialJwd = "";
#endregion Public Fields
#region Public Properties
public Template SelTemplate { get; set; } = new Template(0, "---SELECT---", "", "");
#endregion Public Properties
@@ -32,32 +38,36 @@ namespace Test.UI.Components.Pages
#region Protected Fields
/// <summary>
/// Predisposizione valori live SVG/JWD
/// </summary>
protected LivePayload CurrData = new LivePayload();
protected string currJwd = "...";
protected string prevJwd = "";
protected Dictionary<string, string> m_CurrArgs = new Dictionary<string, string>();
protected string prevJwd = "";
/// <summary>
/// Configurazione elenchi anagrafiche
/// </summary>
protected BaseListPayload SetupList = new BaseListPayload();
#endregion Protected Fields
#region Protected Properties
protected List<TemplateSelectDTO> AvailTemplateList { get; set; } = new List<TemplateSelectDTO>();
protected List<Hardware> AvailHardwareList { get; set; } = new List<Hardware>();
protected List<string> AvailFamilyHardwareList { get; set; } = new List<string>()
{
new string("Arc"),
new string("Profilo78")
};
protected List<string> AvailColorMaterialList { get; set; } = new List<string>()
{
new string("White"),
new string("Black"),
new string("Blu")
};
protected List<string> AvailMaterialList { get; set; } = new List<string>()
protected List<string> AvailFamilyHardwareList { get; set; } = new List<string>()
{
new string("Pino"),
new string("Abete")
new string("Arc"),
new string("Profilo78")
};
protected List<string> AvailGlassList { get; set; } = new List<string>()
{
new string("Vetro BE 2S 4/12/4"),
@@ -67,11 +77,15 @@ namespace Test.UI.Components.Pages
new string("Vetro BE 2S 4T/12/4T"),
new string("Vetro BE 2S 4T/16/4T")
};
protected string SelFamilyHardware { get; set; } = "";
protected string SelColorMaterial { get; set; } = "";
protected string SelMaterial { get; set; } = "";
protected string SelGlass { get; set; } = "";
protected List<Hardware> AvailHardwareList { get; set; } = new List<Hardware>();
protected List<string> AvailMaterialList { get; set; } = new List<string>()
{
new string("Pino"),
new string("Abete")
};
protected List<TemplateSelectDTO> AvailTemplateList { get; set; } = new List<TemplateSelectDTO>();
[Inject]
protected IConfiguration Config { get; set; } = null!;
@@ -86,6 +100,11 @@ namespace Test.UI.Components.Pages
get => (MarkupString)currJwd.Replace(Environment.NewLine, "<br/>").Replace(" ", "&nbsp;");
}
protected string SelColorMaterial { get; set; } = "";
protected string SelFamilyHardware { get; set; } = "";
protected string SelGlass { get; set; } = "";
protected string SelMaterial { get; set; } = "";
#endregion Protected Properties
#region Protected Methods
@@ -93,10 +112,6 @@ namespace Test.UI.Components.Pages
protected override async Task OnInitializedAsync()
{
ConfInit();
//SelFamilyHardware = "Natura";
//SelColorMaterial = "Black";
//SelColorMaterial = "Pine";
//SelGlass = "4T/16/4T";
InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd");
currJwd = InitialJwd;
// rileggo altri dati
@@ -107,6 +122,8 @@ namespace Test.UI.Components.Pages
ColorMaterial = AvailColorMaterialList,
FamilyHardware = AvailFamilyHardwareList,
Glass = AvailGlassList,
//Hardware = new List<Hardware>(),
//Material = new List<string>(),
Hardware = AvailHardwareList,
Material = AvailMaterialList,
TemplateDTO = null
@@ -119,16 +136,6 @@ namespace Test.UI.Components.Pages
DLService.CalcDonePipe.EA_NewMessage += CalcDonePipe_EA_NewMessage;
}
/// <summary>
/// Configurazione elenchi anagrafiche
/// </summary>
protected BaseListPayload SetupList = new BaseListPayload();
/// <summary>
/// Predisposizione valori live SVG/JWD
/// </summary>
protected LivePayload CurrData = new LivePayload();
#endregion Protected Methods
#region Private Fields
@@ -136,14 +143,15 @@ namespace Test.UI.Components.Pages
private string apiUrl = "";
private string calcTag = "";
private string CalcUid = "CurrWindow";
private string cFileTemplate = "Data/Setup.json";
private string cFileHardware = "Hardware/Setup.json";
private string cFileTemplate = "Data/Setup.json";
private TemplateSelectDTO? currSel = null;
private string currSvg = "";
private string imgBasePath = "";
private string GenericBasePath = "";
private string imgBasePath = "";
private string outClose = "";
private string outSave = "";
private string subChannel = "";
private string windowUid = "CurrWindow";
@@ -169,6 +177,16 @@ namespace Test.UI.Components.Pages
await Task.Delay(1);
}
/// <summary>
/// Effettua chiusura oggetto con eventuale save
/// </summary>
/// <param name="reqSave"></param>
private void CloseObj(bool reqSave)
{
outClose = !reqSave ? "Richiesto chiusura!" : "";
outSave = reqSave ? "Richiesto salvataggio!" : "";
}
private void ConfInit()
{
apiUrl = Config.GetValue<string>("ServerConf:Prog.ApiUrl") ?? "";
@@ -252,18 +270,5 @@ namespace Test.UI.Components.Pages
}
#endregion Private Methods
/// <summary>
/// Effettua chiusura oggetto con eventuale save
/// </summary>
/// <param name="reqSave"></param>
private void CloseObj(bool reqSave)
{
outClose = !reqSave ? "Richiesto chiusura!" : "";
outSave = reqSave ? "Richiesto salvataggio!" : "";
}
private string outClose = "";
private string outSave = "";
}
}
+13 -1
View File
@@ -50,7 +50,6 @@ namespace WebWindowComplex.DTO
/// <returns></returns>
public bool IsValid()
{
//bool templateOK = TemplateDTO != null && TemplateDTO.Count > 0;
bool famHwOK = FamilyHardware != null && FamilyHardware.Count > 0;
bool hwOK = Hardware != null && Hardware.Count > 0;
bool glassOK = Glass != null && Glass.Count > 0;
@@ -58,5 +57,18 @@ namespace WebWindowComplex.DTO
bool colorOK = ColorMaterial != null && ColorMaterial.Count > 0;
return famHwOK && glassOK && hwOK && colorOK && matOK;
}
/// <summary>
/// Verifica che Payload sia almeno parzialmente popolato
/// </summary>
/// <returns></returns>
public bool IsPopulated()
{
bool famHwOK = FamilyHardware != null && FamilyHardware.Count > 0;
bool hwOK = Hardware != null && Hardware.Count > 0;
bool glassOK = Glass != null && Glass.Count > 0;
bool matOK = Material != null && Material.Count > 0;
bool colorOK = ColorMaterial != null && ColorMaterial.Count > 0;
return famHwOK || glassOK || hwOK || colorOK || matOK;
}
}
}
File diff suppressed because it is too large Load Diff
+92 -154
View File
@@ -49,6 +49,12 @@ namespace WebWindowComplex
[Parameter]
public EventCallback<Dictionary<string, string>> EC_OnUpdate { get; set; }
/// <summary>
/// Sollevo evento errore validazione con una lista di errori rilevati
/// </summary>
[Parameter]
public EventCallback<List<string>> EC_ValidError { get; set; }
/// <summary>
/// Elenco anagrafiche di base
/// </summary>
@@ -85,122 +91,6 @@ namespace WebWindowComplex
#endregion Protected Fields
#if false
[Parameter]
public string CurrJwd
{
get => m_CurrJwd;
set
{
// Se viene passato un JWD
if (m_CurrJwd != value && value != "")
{
m_CurrJwd = value;
// Aggiornati parametri di ingresso selezionati
UpdateSelParameter();
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
if (m_CurrWindow != null)
{
m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview;
m_CurrWindow = null;
}
m_CurrWindow = WindowFromJson.Deserialize();
m_CurrWindow.OnPreview += M_CurrWindow_OnPreview;
// Recupero dimensioni Frame e Joint del frame della finestra precedente
if (m_PreviousWindow != null)
{
for (int i = 0; i < 2; i++)
m_CurrWindow.AreaList[0].DimensionList[i] = m_PreviousWindow.AreaList[0].DimensionList[i];
for (int i = 0; i < 4; i++)
m_CurrWindow.AreaList[0].JointList[i] = m_PreviousWindow.AreaList[0].JointList[i];
}
}
if (m_CurrWindow != null)
{
// Aggiornate liste di sash, split, splitted, fill e itemTable
UpdateLists();
}
}
}
[Parameter]
public string LiveSVG
{
get => m_SelSVG;
set => m_SelSVG = value;
}
#endif
#if false
[Parameter]
public Template IN_SelTemplate
{
get => m_SelTemplate;
set
{
// Se viene passato il template selezionato oppure se non è ancora stato selezionato un template oppure se si cambia template di selezione
if (value != null && (m_SelTemplate == null || (m_SelTemplate != null && value.nIndex != m_SelTemplate.nIndex)) && !string.IsNullOrEmpty(value.JWD))
{
m_SelTemplate = value;
// Aggiornamento parametri di ingresso selezionati
UpdateSelParameter();
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
if (m_CurrWindow != null)
{
m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview;
m_CurrWindow = null;
}
m_CurrWindow = WindowFromJson.Deserialize();
m_CurrWindow.OnPreview += M_CurrWindow_OnPreview;
// Recupero dimensioni Frame e Joint del frame della finestra precedente
if (m_PreviousWindow != null)
{
for (int i = 0; i < 2; i++)
m_CurrWindow.AreaList[0].DimensionList[i] = m_PreviousWindow.AreaList[0].DimensionList[i];
for (int i = 0; i < 4; i++)
m_CurrWindow.AreaList[0].JointList[i] = m_PreviousWindow.AreaList[0].JointList[i];
}
}
if (m_CurrWindow != null)
{
// Aggiornamento liste sash, split, splitted, fill e itemTable
UpdateLists();
}
}
}
[Parameter]
public List<TemplateSelectDTO> IN_TemplateDTOList { get; set; } = null!;
[Parameter]
public List<string> IN_FamilyHardwareList { get; set; } = null!;
[Parameter]
public List<Hardware> IN_HardwareList { get; set; } = null!;
[Parameter]
public List<string> IN_ColorMaterialList { get; set; } = null!;
[Parameter]
public List<string> IN_MaterialList { get; set; } = null!;
[Parameter]
public List<string> IN_GlassList { get; set; } = null!;
#endif
#if false
[Parameter]
public string IN_SelFamilyHardware { get; set; } = null!;
[Parameter]
public string? IN_SelColorMaterial { get; set; } = null;
[Parameter]
public string? IN_SelMaterial { get; set; } = null;
[Parameter]
public string? IN_SelGlass { get; set; } = null;
#endif
#region Protected Enums
protected enum CompileStep
@@ -669,66 +559,114 @@ namespace WebWindowComplex
editLock = false;
// reset variabile errori
bError = false;
validErrors = new List<string>();
}
protected override void OnAfterRender(bool firstRender)
{
isLoading = false;
}
/// <summary>
/// Booleana fase loading
/// </summary>
private bool isLoading = false;
/// <summary>
/// Gestione update post ricezione parametri da controllo chiamante
/// </summary>
protected override async Task OnParametersSetAsync()
{
bool updateSvg = false;
// controllo elenchi BasePayload siano validi...
if (ListPayload.IsValid())
isLoading = true;
// SOLO SE sono presenti...
if (ListPayload.IsPopulated() && LiveData.IsValid())
{
// controllo sia popolato anche per la componente LIVE
if (LiveData.IsValid())
bool updateSvg = false;
validErrors = new List<string>();
// controllo elenchi BasePayload siano validi...
if (ListPayload.IsValid())
{
// SOLO SE modificato live data...
if (prevLiveData == null || !prevLiveData.Equals(LiveData))
// controllo sia popolato anche per la componente LIVE
if (LiveData.IsValid())
{
prevLiveData = new LivePayload()
// SOLO SE modificato live data...
if (prevLiveData == null || !prevLiveData.Equals(LiveData))
{
CurrJwd = LiveData.CurrJwd,
SvgPreview = LiveData.SvgPreview
};
m_SelSVG = LiveData.SvgPreview;
// Aggiornati parametri di ingresso selezionati
UpdateSelParameter();
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
setCurrWindow(WindowFromJson);
//SOLO SE non sono in edit...
if (!editLock)
prevLiveData = new LivePayload()
{
CurrJwd = LiveData.CurrJwd,
SvgPreview = LiveData.SvgPreview
};
m_SelSVG = LiveData.SvgPreview;
// Aggiornati parametri di ingresso selezionati
UpdateSelParameter();
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(LiveData.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)
{
// Se viene passato il template selezionato oppure se non è ancora stato selezionato un template oppure se si cambia template di selezione
if (m_SelTemplate == null || (m_SelTemplate != null && CurrSelection.Template.nIndex != m_SelTemplate.nIndex) && !string.IsNullOrEmpty(CurrSelection.Template.JWD))
{
currStep = CompileStep.Tree;
m_SelTemplate = CurrSelection.Template;
// Aggiornamento parametri di ingresso selezionati
UpdateSelParameter();
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
setCurrWindow(WindowFromJson);
currStep = CompileStep.Template;
}
updateSvg = true;
}
}
else if (CurrSelection != null && CurrSelection.Template != null)
{
// Se viene passato il template selezionato oppure se non è ancora stato selezionato un template oppure se si cambia template di selezione
if (m_SelTemplate == null || (m_SelTemplate != null && CurrSelection.Template.nIndex != m_SelTemplate.nIndex) && !string.IsNullOrEmpty(CurrSelection.Template.JWD))
if (SashList.Count > 0)
{
m_SelTemplate = CurrSelection.Template;
// Aggiornamento parametri di ingresso selezionati
UpdateSelParameter();
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
setCurrWindow(WindowFromJson);
currStep = CompileStep.Template;
currAnta = 0;
}
if (updateSvg)
{
await DoPreviewSvg();
}
updateSvg = true;
}
if (SashList.Count > 0)
else
{
currAnta = 0;
}
if (updateSvg)
{
await DoPreviewSvg();
// 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!");
}
}
isLoading = false;
}
}
/// <summary>
/// Elenco errori preliminari di validazione
/// </summary>
private List<string> validErrors = new List<string>();
protected void setCurrWindow(JsonWindow WindowFromJson)
{
if (m_CurrWindow != null)
+23 -1
View File
@@ -6,7 +6,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>2.7.10.918</Version>
<Version>2.7.10.1009</Version>
<Authors>Annamaria Sassi</Authors>
<Company>Egalware</Company>
<Description>Componente gestione Configurazioni avanzate Window per LUX</Description>
@@ -123,6 +123,28 @@
@@ -6,7 +6,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>2.7.10.918</Version>
<Version>2.7.10.1009</Version>
<Authors>Annamaria Sassi</Authors>
<Company>Egalware</Company>
<Description>Componente gestione JWD per LUX</Description>
@@ -159,6 +159,28 @@