Update catena eventi x richiesta reset dizionario

This commit is contained in:
Samuele Locatelli
2025-11-03 16:42:37 +01:00
parent 15acb8936f
commit d4e1a73d57
8 changed files with 159 additions and 74 deletions
+76 -56
View File
@@ -13,6 +13,23 @@ namespace WebWindowComplex
{
public partial class TableComp : IDisposable
{
#region Public Enums
public enum DataAction
{
/// <summary>
/// Nessuna richiesta
/// </summary>
None = 0,
/// <summary>
/// Reset dizionario shape
/// </summary>
ResetDictShape
}
#endregion Public Enums
#region Public Properties
/// <summary>
@@ -27,6 +44,12 @@ namespace WebWindowComplex
[Parameter]
public SelectPayload? CurrSelection { get; set; } = null;
/// <summary>
/// Richiesta azione al parent
/// </summary>
[Parameter]
public EventCallback<DataAction> EC_ActionReq { get; set; }
/// <summary>
/// Richiesta update da JWD (SVG, calcoli vari...)
/// </summary>
@@ -592,8 +615,6 @@ namespace WebWindowComplex
listWarnings = new Dictionary<string, string>();
}
private bool firstDisplay = true;
/// <summary>
/// Gestione update post ricezione parametri da controllo chiamante
/// </summary>
@@ -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<JsonWindow>(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<JsonWindow>(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<int> 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;
/// <summary>
/// Booleana fase loading
/// </summary>
private bool isLoading = false;
private bool isRendered = false;
/// <summary>
@@ -934,6 +944,18 @@ namespace WebWindowComplex
return "btn btn-outline-secondary btn-sm";
}
/// <summary>
/// Prima chiamata alle opzioni hardware
/// </summary>
/// <param name="groupId"> Group Id del sash group di cui si vuole Hw option </param>
/// <returns></returns>
private async Task CallFirstHwOpt(int groupId)
{
bool isFirst = true;
List<int> reqList = new List<int>() { groupId };
await DoReqOptHardware(reqList, isFirst);
}
/// <summary>
/// Metodo per settare tutti i Fill in contemporanea
/// </summary>
@@ -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<string, string> Args = new Dictionary<string, string>();
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<string, string> Args = new Dictionary<string, string>();
@@ -1118,7 +1132,15 @@ namespace WebWindowComplex
Args.Add("Jwd", e.sJwd);
string listGroupId = JsonConvert.SerializeObject(new List<int> { e.nGroupId });
Args.Add("GroupId", listGroupId);
_ = EC_DoUpdate.InvokeAsync(Args);
_ = EC_DoUpdate.InvokeAsync(Args);
}
private void M_CurrWindow_OnPreview(object? sender, OnPreviewEventArgs e)
{
Dictionary<string, string> Args = new Dictionary<string, string>();
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;
}
/// <summary>
/// Richiesta reset dizionario Shape con action
/// </summary>
/// <param name="args"></param>
/// <exception cref="NotImplementedException"></exception>
private void ReqResetDict(bool args)
{
_ = EC_ActionReq.InvokeAsync(DataAction.ResetDictShape);
}
/// <summary>
/// Ritorno step Tree
/// </summary>
@@ -1327,18 +1359,6 @@ namespace WebWindowComplex
await DoReqOptHardware(reqList);
}
/// <summary>
/// Prima chiamata alle opzioni hardware
/// </summary>
/// <param name="groupId"> Group Id del sash group di cui si vuole Hw option </param>
/// <returns></returns>
private async Task CallFirstHwOpt(int groupId)
{
bool isFirst = true;
List<int> reqList = new List<int>() { groupId };
await DoReqOptHardware(reqList, isFirst);
}
/// <summary>
/// Aggiornamento Sash e Frame
/// </summary>