From c11b13a420fe34e6cdc0ca3c33e676457adf8e34 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 7 Apr 2023 16:57:02 +0200 Subject: [PATCH 1/2] Correzione ordine x salvataggio --- .../Hardware/HwSingleInstance.razor | 85 ++++++++++++------ .../Hardware/HwSingleInstance.razor.cs | 87 +++++++++++++++---- .../Data/WDCVocabularyService.cs | 2 +- 3 files changed, 133 insertions(+), 41 deletions(-) diff --git a/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor b/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor index b312176..062c763 100644 --- a/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor +++ b/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor @@ -1,30 +1,65 @@ - + @if (listValuesFname != null) { - + @foreach (var folder in listValuesFname) + { + + } + } + +
+ Template + @if (listValuesFiles != null && listValuesFiles.Count > 0) + { + + } + else + { + + } +
+ @foreach (var item in currVal) + { + @if (item.Key != "folder" && item.Key != "template") + { + if (isCombo(item.Key)) + { +
+ @translate(item.Key) + +
+ } + else + { +
+ @translate(item.Key) + +
+ } } } - -
- Template - @if (listValuesFiles != null && listValuesFiles.Count > 0) - { - - } - else - { - - } -
- -@foreach (var graph in getGraphicParams()) +} +@*@foreach (var graph in getGraphicParams()) { @foreach (var graphParam in graph.Value) { @@ -49,7 +84,7 @@ } } -} +}*@
Cancel diff --git a/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs b/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs index 2ee4204..0d796e0 100644 --- a/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs +++ b/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Identity; using Newtonsoft.Json; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; @@ -23,21 +22,48 @@ namespace WebDoorCreator.UI.Components.Hardware #region Public Methods - public Dictionary>> getGraphicParams() + public void setupCurrValues() { - var deserialized = JsonConvert.DeserializeObject>>>(DoorOpInst.JsoncConfigVal!); + currVal = new Dictionary(); + if (!string.IsNullOrEmpty(DoorOpInst.JsoncActVal)) + { + var deserialized = JsonConvert.DeserializeObject>(DoorOpInst.JsoncActVal!); + if (deserialized != null) + { + currVal = deserialized; + } + } + } + + public void setupGraphicParams() + { + var deserialized = JsonConvert.DeserializeObject>>(DoorOpInst.JsoncConfigVal!); if (deserialized != null) { graphicParams = deserialized; } - return graphicParams; } #endregion Public Methods #region Protected Properties - protected string _folderName { get; set; } = ""; + //public Dictionary>> getGraphicParams() + //{ + // var deserialized = JsonConvert.DeserializeObject>>>(DoorOpInst.JsoncConfigVal!); + // if (deserialized != null) + // { + // graphicParams = deserialized; + // } + // return graphicParams; + //} + protected string _folderName + { + get => currVal != null ? currVal["folder"] : ""; + set => currVal["folder"] = value; + } + + protected Dictionary currVal { get; set; } = null!; protected string folderName { @@ -52,7 +78,13 @@ namespace WebDoorCreator.UI.Components.Hardware } } - protected Dictionary>> graphicParams { get; set; } = null!; + protected string templateName + { + get => currVal != null ? currVal["template"] : ""; + set => currVal["template"] = value; + } + + protected Dictionary> graphicParams { get; set; } = null!; protected List? listValuesFiles { get; set; } = null!; protected List? listValuesFname { get; set; } = null!; @@ -67,8 +99,40 @@ namespace WebDoorCreator.UI.Components.Hardware #region Protected Methods + protected bool isCombo(string pKey) + { + bool answ = false; + if (graphicParams.ContainsKey(pKey)) + { + answ = graphicParams[pKey].Count > 1; + } + return answ; + } + + protected List comboSet(string pKey) + { + List answ = new List(); + if (graphicParams.ContainsKey(pKey)) + { + answ = graphicParams[pKey].ToList(); + } + return answ; + } + + + protected async Task doSave() + { + // ri-serializzo i graphics parameters... + string serVal = JsonConvert.SerializeObject(currVal); + DoorOpInst.JsoncActVal = serVal; + // salvo! + await WDCService.DoorOpUpdate(DoorOpInst); + } + protected override async Task OnParametersSetAsync() { + setupCurrValues(); + setupGraphicParams(); await ReloadData(true); } @@ -81,6 +145,8 @@ namespace WebDoorCreator.UI.Components.Hardware return answ; } + + #endregion Protected Methods #region Private Methods @@ -107,15 +173,6 @@ namespace WebDoorCreator.UI.Components.Hardware } } - protected async Task doSave() - { - // ri-serializzo i graphics parameters... - string serVal = JsonConvert.SerializeObject(graphicParams); - DoorOpInst.JsoncActVal = serVal; - // salvo! - await WDCService.DoorOpUpdate(DoorOpInst); - } - #endregion Private Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Data/WDCVocabularyService.cs b/WebDoorCreator.UI/Data/WDCVocabularyService.cs index fca3140..0988903 100644 --- a/WebDoorCreator.UI/Data/WDCVocabularyService.cs +++ b/WebDoorCreator.UI/Data/WDCVocabularyService.cs @@ -73,7 +73,7 @@ namespace WebDoorCreator.UI.Data public string Traduci(string lingua, string lemma) { - string answ = $"[{lemma}]"; + string answ = lemma; if (VocabularyLemmas != null && VocabularyLemmas.ContainsKey(lingua)) { From 5deb3e00544d4ff0e01c824fde39d7303695f880 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 7 Apr 2023 17:17:07 +0200 Subject: [PATCH 2/2] Ancora update x salvataggio dati DoorOp --- .../Hardware/HwSingleInstance.razor | 5 +++-- .../Hardware/HwSingleInstance.razor.cs | 20 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor b/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor index 062c763..dff4e57 100644 --- a/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor +++ b/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor @@ -85,11 +85,12 @@ else } }*@ +
-
+
Cancel
-
\ No newline at end of file +
diff --git a/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs b/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs index 0d796e0..8af040b 100644 --- a/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs +++ b/WebDoorCreator.UI/Components/Hardware/HwSingleInstance.razor.cs @@ -24,7 +24,7 @@ namespace WebDoorCreator.UI.Components.Hardware public void setupCurrValues() { - currVal = new Dictionary(); + //currVal = new Dictionary(); if (!string.IsNullOrEmpty(DoorOpInst.JsoncActVal)) { var deserialized = JsonConvert.DeserializeObject>(DoorOpInst.JsoncActVal!); @@ -63,6 +63,9 @@ namespace WebDoorCreator.UI.Components.Hardware set => currVal["folder"] = value; } + /// + /// Array dati + /// protected Dictionary currVal { get; set; } = null!; protected string folderName @@ -129,11 +132,14 @@ namespace WebDoorCreator.UI.Components.Hardware await WDCService.DoorOpUpdate(DoorOpInst); } + protected async Task doCancel() + { + await FullReloadData(true); + } + protected override async Task OnParametersSetAsync() { - setupCurrValues(); - setupGraphicParams(); - await ReloadData(true); + await FullReloadData(true); } protected string translate(string lemma) @@ -151,6 +157,12 @@ namespace WebDoorCreator.UI.Components.Hardware #region Private Methods + private async Task FullReloadData(bool isFirst) + { + setupCurrValues(); + setupGraphicParams(); + await ReloadData(isFirst); + } private async Task ReloadData(bool isFirst) { var tempListVal = await WDCService.ListValuesGetAll(HwCode, "Folder");