+
+ @if (SelectedShippingItem != null)
+ {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+
+@*
+
-
+
@foreach (var m in _messages)
@@ -71,4 +108,5 @@
}
-
\ No newline at end of file
+
+ *@
\ No newline at end of file
diff --git a/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs b/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs
index f113497..25e7054 100644
--- a/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs
+++ b/FruitBankHybrid.Shared/Pages/MeasuringIn.razor.cs
@@ -17,6 +17,7 @@ using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Components.Forms;
using static System.Net.Mime.MediaTypeNames;
using static System.Runtime.InteropServices.JavaScript.JSType;
using ILogger = FruitBank.Common.Loggers.ILogger;
@@ -35,6 +36,9 @@ namespace FruitBankHybrid.Shared.Pages
private ShippingDocument? SelectedShippingDocument { get; set; }
private ShippingItem? SelectedShippingItem { get; set; }
+ protected bool BtnSaveEnabled { get; set; }
+ protected bool ChkAllShipping { get; set; }
+
private string _userName = "Partner name";
private string _message = string.Empty;
private readonly List<(string User, string Text)> _messages = [];
@@ -44,24 +48,118 @@ namespace FruitBankHybrid.Shared.Pages
_logger = new LoggerClient
(LogWriters.ToArray());
_logger.Info("OnInitializedAsync");
- NotMeasuredShippings = await FruitBankSignalRClient.GetNotMeasuredShippings() ?? [];
- SelectedShipping = NotMeasuredShippings?.FirstOrDefault();
-
+ await RefreshShippingsFromDb(ChkAllShipping);
await base.OnInitializedAsync();
}
- public void OnSelectedShippingChanged(SelectedDataItemChangedEventArgs eventArgs)
+ private async Task RefreshShippingsFromDb(bool getAllShipping)
{
- SelectedShippingDocument = eventArgs.DataItem.ShippingDocuments?.FirstOrDefault();
- SelectedShippingItem = SelectedShippingDocument?.ShippingItems?.FirstOrDefault();
-
+ if (getAllShipping) NotMeasuredShippings = await FruitBankSignalRClient.GetShippings() ?? [];
+ else NotMeasuredShippings = await FruitBankSignalRClient.GetNotMeasuredShippings() ?? [];
+
+ SelectedShipping = NotMeasuredShippings.FirstOrDefault();
}
- public void OnSelectedShippingDocumentChanged(SelectedDataItemChangedEventArgs eventArgs)
+ private async Task OnChkAllShippingChanged(bool value)
+ {
+ ChkAllShipping = value;
+ await RefreshShippingsFromDb(ChkAllShipping);
+ }
+
+ private void OnSelectedShippingChanged(SelectedDataItemChangedEventArgs eventArgs)
+ {
+ SelectedShippingDocument = eventArgs.DataItem?.ShippingDocuments?.FirstOrDefault();
+ }
+
+ private void OnSelectedShippingDocumentChanged(SelectedDataItemChangedEventArgs eventArgs)
{
SelectedShippingItem = eventArgs.DataItem?.ShippingItems?.FirstOrDefault();
}
+ private async Task OnSelectedShippingItemChanged(SelectedDataItemChangedEventArgs eventArgs)
+ {
+ BtnSaveEnabled = false;
+
+ if (eventArgs.DataItem == null)
+ {
+ SelectedShippingItem = null;
+ return;
+ }
+
+ await RefreshSelectedShippingItemMeasuredValuesFromDb(eventArgs.DataItem.Id);
+ }
+
+ private async Task RefreshSelectedShippingItemMeasuredValuesFromDb(int shippingItemId)
+ {
+ RefreshSelectedShippingItemMeasuredValuesFromDb(await FruitBankSignalRClient.GetShippingItemById(shippingItemId));
+ }
+
+ private void RefreshSelectedShippingItemMeasuredValuesFromDb(ShippingItem? shippingItemFromDb)
+ {
+ if (SelectedShippingItem == null || shippingItemFromDb == null) return;
+
+ SelectedShippingItem.MeasuredNetWeight = shippingItemFromDb.MeasuredNetWeight;
+ SelectedShippingItem.MeasuredGrossWeight = shippingItemFromDb.MeasuredGrossWeight;
+ SelectedShippingItem.IsMeasured = shippingItemFromDb.IsMeasured;
+
+ if (SelectedShippingItem is { IsMeasured: true })
+ {
+ SelectedShippingDocument?.ShippingItems?.Remove(SelectedShippingItem);
+ SelectedShippingItem = SelectedShippingDocument?.ShippingItems?.FirstOrDefault();
+ }
+
+ StateHasChanged();
+ }
+
+ private async Task UpdateShippingItem(ShippingItem? shippingItem)
+ {
+ if (shippingItem is { MeasuredGrossWeight: > 0, MeasuredNetWeight: > 0 })
+ {
+ BtnSaveEnabled = false;
+
+ shippingItem.IsMeasured = shippingItem is { MeasuredGrossWeight: > 0, MeasuredNetWeight: > 0 };
+ RefreshSelectedShippingItemMeasuredValuesFromDb(await FruitBankSignalRClient.UpdateShippingItem(shippingItem));
+ }
+ }
+
+ private async Task HandleValidSubmit()
+ {
+ await UpdateShippingItem(SelectedShippingItem);
+ }
+
+ private void HandleInvalidSubmit()
+ {
+ //FormValidationState = @"Form data is invalid";
+ }
+
+ protected void OnItemUpdating(string fieldName, object newValue)
+ {
+ BtnSaveEnabled = false;
+ if (SelectedShippingItem == null) return;
+
+ switch (fieldName)
+ {
+ case nameof(ShippingItem.Name):
+ SelectedShippingItem.Name = newValue.ToString() ?? string.Empty;
+ break;
+ case nameof(ShippingItem.GrossWeight):
+ SelectedShippingItem.GrossWeight = (double)newValue;
+ break;
+ case nameof(ShippingItem.NetWeight):
+ SelectedShippingItem.NetWeight = (double)newValue;
+ break;
+ case nameof(ShippingItem.MeasuredGrossWeight):
+ SelectedShippingItem.MeasuredGrossWeight = (double)newValue;
+ break;
+ case nameof(ShippingItem.MeasuredNetWeight):
+ SelectedShippingItem.MeasuredNetWeight = (double)newValue;
+ break;
+ }
+
+ //if (SelectedShippingItem.MeasuredGrossWeight > 0 && SelectedShippingItem.MeasuredNetWeight > 0)
+ BtnSaveEnabled = true;
+ }
+
private async Task GetPartner()
{
var measuringModel = new MeasuringModel();
diff --git a/FruitBankHybrid.Web.Client/FruitBankHybrid.Web.Client.csproj b/FruitBankHybrid.Web.Client/FruitBankHybrid.Web.Client.csproj
index 289c798..6cfc12e 100644
--- a/FruitBankHybrid.Web.Client/FruitBankHybrid.Web.Client.csproj
+++ b/FruitBankHybrid.Web.Client/FruitBankHybrid.Web.Client.csproj
@@ -12,8 +12,8 @@
-
-
+
+
diff --git a/FruitBankHybrid.Web.Client/Program.cs b/FruitBankHybrid.Web.Client/Program.cs
index 7902e57..8e6ab37 100644
--- a/FruitBankHybrid.Web.Client/Program.cs
+++ b/FruitBankHybrid.Web.Client/Program.cs
@@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
-builder.Services.AddDevExpressBlazor();
+builder.Services.AddDevExpressBlazor(configure => configure.SizeMode = DevExpress.Blazor.SizeMode.Large);
// Add device-specific services used by the FruitBankHybrid.Shared project
builder.Services.AddSingleton();
diff --git a/FruitBankHybrid.Web/FruitBankHybrid.Web.csproj b/FruitBankHybrid.Web/FruitBankHybrid.Web.csproj
index dda9699..f3c9748 100644
--- a/FruitBankHybrid.Web/FruitBankHybrid.Web.csproj
+++ b/FruitBankHybrid.Web/FruitBankHybrid.Web.csproj
@@ -17,9 +17,9 @@
-
-
-
+
+
+
diff --git a/FruitBankHybrid.Web/Program.cs b/FruitBankHybrid.Web/Program.cs
index e746452..8405b86 100644
--- a/FruitBankHybrid.Web/Program.cs
+++ b/FruitBankHybrid.Web/Program.cs
@@ -9,7 +9,7 @@ using FruitBankHybrid.Web.Services;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents().AddInteractiveServerComponents().AddInteractiveWebAssemblyComponents();
-builder.Services.AddDevExpressBlazor();
+builder.Services.AddDevExpressBlazor(configure => configure.SizeMode = DevExpress.Blazor.SizeMode.Large);
builder.Services.AddMvc();
builder.Services.AddSingleton();
diff --git a/FruitBankHybrid/FruitBankHybrid.csproj b/FruitBankHybrid/FruitBankHybrid.csproj
index 29156b2..9964a36 100644
--- a/FruitBankHybrid/FruitBankHybrid.csproj
+++ b/FruitBankHybrid/FruitBankHybrid.csproj
@@ -63,9 +63,9 @@
-
-
-
+
+
+
diff --git a/FruitBankHybrid/MauiProgram.cs b/FruitBankHybrid/MauiProgram.cs
index 049506a..04299fb 100644
--- a/FruitBankHybrid/MauiProgram.cs
+++ b/FruitBankHybrid/MauiProgram.cs
@@ -39,7 +39,7 @@ namespace FruitBankHybrid
builder.Services.AddMauiBlazorWebView();
- builder.Services.AddDevExpressBlazor();
+ builder.Services.AddDevExpressBlazor(configure => configure.SizeMode = DevExpress.Blazor.SizeMode.Large);
#if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools();