From 239ee52d5fced8e2dba30bdc6756d2ab69794737 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 21 Jun 2021 11:25:40 +0200 Subject: [PATCH] Aggiunta preliminare editors x ordini distinti --- GWMS.UI/Components/OrderAdminEditor.razor | 146 +++++++++++++++++++ GWMS.UI/Components/OrderSupplierEditor.razor | 146 +++++++++++++++++++ 2 files changed, 292 insertions(+) create mode 100644 GWMS.UI/Components/OrderAdminEditor.razor create mode 100644 GWMS.UI/Components/OrderSupplierEditor.razor diff --git a/GWMS.UI/Components/OrderAdminEditor.razor b/GWMS.UI/Components/OrderAdminEditor.razor new file mode 100644 index 0000000..fa4dafc --- /dev/null +++ b/GWMS.UI/Components/OrderAdminEditor.razor @@ -0,0 +1,146 @@ +@using GWMS.UI.Components +@using GWMS.Data.DatabaseModels +@using System.Security.Claims +@using Microsoft.AspNetCore.Components.Authorization +@using GWMS.UI.Data +@using Microsoft.Extensions.Configuration + +@inject MessageService AppMessages +@inject GWMSDataService DataService +@inject IConfiguration Configuration + +
+
+ Modifica +
+
+ + + +
+
+ +
+
+
+
+ + + @foreach (var item in transpList) + { + + } + +
+
+ + +
+
+
+ + +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+ +@code { + + private List transpList; + + protected OrderModel _currItem = new OrderModel(); + protected int _supplierId { get; set; } = 0; + + [Parameter] + public OrderModel currItem + { + get + { + return _currItem = null; + } + set + { + _currItem = value; + } + } + + [Parameter] + public EventCallback DataReset { get; set; } + [Parameter] + public EventCallback DataUpdated { get; set; } + [Parameter] + public int SupplierId + { + get + { + return _supplierId; + } + set + { + _supplierId = value; + // condiziono visualizzazione... + var pUpd = Task.Run(async () => await ReloadAllData()); + pUpd.Wait(); + } + } + + private async Task saveUpdate() + { + if (_currItem != null) + { + DataService.OrderUpdate(_currItem); + await DataUpdated.InvokeAsync(1); + } + else + { + Console.WriteLine("Order null!"); + } + } + + private async Task cancelUpdate() + { + await DataReset.InvokeAsync(0); + } + + protected override async Task OnInitializedAsync() + { + await ReloadAllData(); + } + + protected async Task ReloadAllData() + { + transpList = await DataService.TransportersGetFilt(SupplierId); + } + + /// + /// Restituisce URL immagine QRCode + /// + /// Parametro da renderizzare con QRCode + /// + protected string getImgUrl(object QrValue) + { + string baseUrl = $"{Configuration["matrixUrl"]}/HOME/QR_site/JSON?val="; + string payload = "{'baseUrl':'{0}','parameters':['" + $"{QrValue}" + "']}"; + string answ = $"{baseUrl}{payload}"; + return answ; + } + +} \ No newline at end of file diff --git a/GWMS.UI/Components/OrderSupplierEditor.razor b/GWMS.UI/Components/OrderSupplierEditor.razor new file mode 100644 index 0000000..fa4dafc --- /dev/null +++ b/GWMS.UI/Components/OrderSupplierEditor.razor @@ -0,0 +1,146 @@ +@using GWMS.UI.Components +@using GWMS.Data.DatabaseModels +@using System.Security.Claims +@using Microsoft.AspNetCore.Components.Authorization +@using GWMS.UI.Data +@using Microsoft.Extensions.Configuration + +@inject MessageService AppMessages +@inject GWMSDataService DataService +@inject IConfiguration Configuration + +
+
+ Modifica +
+
+ + + +
+
+ +
+
+
+
+ + + @foreach (var item in transpList) + { + + } + +
+
+ + +
+
+
+ + +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+ +@code { + + private List transpList; + + protected OrderModel _currItem = new OrderModel(); + protected int _supplierId { get; set; } = 0; + + [Parameter] + public OrderModel currItem + { + get + { + return _currItem = null; + } + set + { + _currItem = value; + } + } + + [Parameter] + public EventCallback DataReset { get; set; } + [Parameter] + public EventCallback DataUpdated { get; set; } + [Parameter] + public int SupplierId + { + get + { + return _supplierId; + } + set + { + _supplierId = value; + // condiziono visualizzazione... + var pUpd = Task.Run(async () => await ReloadAllData()); + pUpd.Wait(); + } + } + + private async Task saveUpdate() + { + if (_currItem != null) + { + DataService.OrderUpdate(_currItem); + await DataUpdated.InvokeAsync(1); + } + else + { + Console.WriteLine("Order null!"); + } + } + + private async Task cancelUpdate() + { + await DataReset.InvokeAsync(0); + } + + protected override async Task OnInitializedAsync() + { + await ReloadAllData(); + } + + protected async Task ReloadAllData() + { + transpList = await DataService.TransportersGetFilt(SupplierId); + } + + /// + /// Restituisce URL immagine QRCode + /// + /// Parametro da renderizzare con QRCode + /// + protected string getImgUrl(object QrValue) + { + string baseUrl = $"{Configuration["matrixUrl"]}/HOME/QR_site/JSON?val="; + string payload = "{'baseUrl':'{0}','parameters':['" + $"{QrValue}" + "']}"; + string answ = $"{baseUrl}{payload}"; + return answ; + } + +} \ No newline at end of file