Fix validazione preliminare liste parametri
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user