ok salvataggio modifiche x blocco
This commit is contained in:
@@ -6,6 +6,6 @@ else
|
||||
{
|
||||
@foreach (var item in CurrBaseDoorOp)
|
||||
{
|
||||
<DoorDataBlock BlockDoorOp="@item"></DoorDataBlock>
|
||||
<DoorDataBlock E_doorOp2Save=doSaveParams BlockDoorOp="@item"></DoorDataBlock>
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using WebDoorCreator.Data.DbModels;
|
||||
using WebDoorCreator.UI.Data;
|
||||
|
||||
namespace WebDoorCreator.UI.Components.DoorDef
|
||||
{
|
||||
@@ -13,6 +14,9 @@ namespace WebDoorCreator.UI.Components.DoorDef
|
||||
[Parameter]
|
||||
public List<DoorOpModel>? CurrBaseDoorOp { get; set; } = null;
|
||||
|
||||
[Inject]
|
||||
protected WebDoorCreatorService WDService { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Properties
|
||||
@@ -22,6 +26,14 @@ namespace WebDoorCreator.UI.Components.DoorDef
|
||||
/// </summary>
|
||||
protected string userLang { get; set; } = "EN";
|
||||
|
||||
protected async Task doSaveParams(DoorOpModel savingDoorOp)
|
||||
{
|
||||
if (savingDoorOp != null)
|
||||
{
|
||||
await WDService.DoorOpUpdate(savingDoorOp);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,43 @@
|
||||
<div class="text-center">
|
||||
<h5>@BlockDoorOp.ObjectId</h5>
|
||||
</div>
|
||||
|
||||
@if (bdpList != null)
|
||||
@if (bdpList != null)
|
||||
{
|
||||
foreach (var item in bdpList)
|
||||
{
|
||||
<DoorDefSizingSI Lingua="@userLang" currValRef="@item.Value" paramsConfig="@getParamsConfig(item.Key)" HwCode="@item.Key" E_ItemChanged="@doSaveBlock"></DoorDefSizingSI>
|
||||
}
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="text-center">
|
||||
<h5>@BlockDoorOp.ObjectId</h5>
|
||||
</div>
|
||||
@foreach (var item in bdpList)
|
||||
{
|
||||
<DoorDefSizingSI Lingua="@userLang" currValRef="@item.Value" paramsConfig="@getParamsConfig(item.Key)" HwCode="@item.Key" E_ItemChanged="@doSaveBlock"></DoorDefSizingSI>
|
||||
}
|
||||
<hr />
|
||||
</div>
|
||||
<div class="col-6">
|
||||
@if (paramsChanged)
|
||||
{
|
||||
<div class="col-10">
|
||||
<div class="btn-group w-100">
|
||||
<button class="btn btn-outline-dark" style="cursor: pointer;">
|
||||
CANCEL
|
||||
</button>
|
||||
<button class="btn btn-outline-dark" style="cursor: pointer;">
|
||||
SAVE
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="col-10">
|
||||
<div class="btn-group w-100">
|
||||
<button class="btn btn-outline-secondary" style="cursor: pointer;" disabled>
|
||||
CANCEL
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" style="cursor: pointer;" disabled>
|
||||
SAVE
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -34,7 +34,14 @@ namespace WebDoorCreator.UI.Components.DoorDef
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public DoorOpModel BlockDoorOp { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Evento per salvataggio oggetto serializzato
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<DoorOpModel> E_doorOp2Save { get; set; }
|
||||
|
||||
protected string userLang { get; set; } = "EN";
|
||||
protected bool paramsChanged { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// spacchetto componenti
|
||||
@@ -80,6 +87,7 @@ namespace WebDoorCreator.UI.Components.DoorDef
|
||||
|
||||
protected async Task doSaveBlock(Dictionary<string, Dictionary<string, string>> updSet)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
if (bdpList != null)
|
||||
{
|
||||
if (updSet != null && updSet.Count > 0)
|
||||
@@ -88,7 +96,17 @@ namespace WebDoorCreator.UI.Components.DoorDef
|
||||
if (bdpList.ContainsKey(currSet.Key))
|
||||
{
|
||||
bdpList[currSet.Key] = currSet.Value;
|
||||
paramsChanged = true;
|
||||
// serializzo e salvo, rimandando evento ad obj contenitore
|
||||
var serVal2Save = JsonConvert.SerializeObject(bdpList);
|
||||
|
||||
if (serVal2Save != null)
|
||||
{
|
||||
BlockDoorOp.JsoncActVal = serVal2Save;
|
||||
|
||||
await E_doorOp2Save.InvokeAsync(BlockDoorOp);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
// FixMe ToDo !!!
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ else
|
||||
<div class="row my-1">
|
||||
<b>@HwCode</b>
|
||||
</div>
|
||||
@doCheckVal()
|
||||
@foreach (var item in currVal)
|
||||
{
|
||||
@if (isCombo(item.Key))
|
||||
@@ -38,32 +39,7 @@ else
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@if (doCheckVal())
|
||||
{
|
||||
<div class="col-10">
|
||||
<div class="btn-group w-100">
|
||||
<button class="btn btn-outline-dark" style="cursor: pointer;" @onclick="() => doCancel()">
|
||||
CANCEL
|
||||
</button>
|
||||
<button class="btn btn-outline-dark" style="cursor: pointer;" @onclick="() => doSave()">
|
||||
SAVE
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="col-10">
|
||||
<div class="btn-group w-100">
|
||||
<button class="btn btn-outline-secondary" style="cursor: pointer;" disabled>
|
||||
CANCEL
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" style="cursor: pointer;" disabled>
|
||||
SAVE
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -41,10 +41,19 @@ namespace WebDoorCreator.UI.Components.DoorDef
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
Dictionary<string, string> _currVal = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Array dati effettivo x gestione modifiche
|
||||
/// </summary>
|
||||
protected Dictionary<string, string> currVal { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> currVal
|
||||
{
|
||||
get => _currVal;
|
||||
set
|
||||
{
|
||||
_currVal = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
@@ -89,6 +98,10 @@ namespace WebDoorCreator.UI.Components.DoorDef
|
||||
if (k.Value != currValRef[k.Key])
|
||||
{
|
||||
answ = true;
|
||||
if (answ)
|
||||
{
|
||||
Task.Run(async () => await doSave());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user