MeasuringIn improvements
This commit is contained in:
parent
4410d662d8
commit
c4061dae6f
|
|
@ -1,4 +1,5 @@
|
|||
@page "/MeasuringIn"
|
||||
@using AyCode.Utils.Extensions
|
||||
@using DevExpress.Blazor
|
||||
@using DevExpress.Blazor.Internal
|
||||
@using FruitBank.Common.Entities
|
||||
|
|
@ -9,50 +10,78 @@
|
|||
|
||||
<div style="margin-top: 50px;">
|
||||
<DxFormLayout CaptionPosition="CaptionPosition.Vertical" CssClass="w-100">
|
||||
<DxFormLayoutItem ColSpanMd="12">
|
||||
<DxCheckBox CheckedChanged="@((bool t) => OnChkAllShippingChanged(t))">Összes szállítmány listázása</DxCheckBox>
|
||||
<DxFormLayoutItem Caption="Érkezés dátuma" ColSpanMd="2">
|
||||
<DxDateEdit CssClass="cw-320"
|
||||
DisplayFormat="m"
|
||||
Format="m"
|
||||
Context="ctxShippingDate"
|
||||
Date="@(SelectedShipping?.ShippingDate.Date ?? DateTime.Now.Date)"
|
||||
CustomDisabledDate="@OnCustomDisabledDate"
|
||||
DateChanged="@((DateTime newValue) => OnSelectedShippingDateChanged(newValue))"
|
||||
InputId="deDisabledDates">
|
||||
<DayCellTemplate>
|
||||
@{
|
||||
var cssClass = GetCssClassNames(ctxShippingDate);
|
||||
if (!cssClass.IsNullOrWhiteSpace())
|
||||
{
|
||||
<a class="@GetCssClassNames(ctxShippingDate)">@ctxShippingDate.Day.ToString()</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a>@ctxShippingDate.Day.ToString()</a>
|
||||
}
|
||||
}
|
||||
|
||||
</DayCellTemplate>
|
||||
</DxDateEdit>
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Caption="Szállítmány:" ColSpanMd="4" BeginRow="true">
|
||||
<DxFormLayoutItem Caption="Kamion rendszáma:" ColSpanMd="2">
|
||||
<DxComboBox Data="@NotMeasuredShippings"
|
||||
@bind-Value="@SelectedShipping"
|
||||
Text="Select shipping"
|
||||
ValueFieldName="@nameof(Shipping.Id)"
|
||||
TextFieldName="@nameof(Shipping.ShippingDate)"
|
||||
CssClass="cw-480"
|
||||
SelectedDataItemChanged="@((SelectedDataItemChangedEventArgs<Shipping> args) => OnSelectedShippingChanged(args))"
|
||||
InputId="cbNotMeasuredShippings">
|
||||
<ItemDisplayTemplate Context="ctxCombo">
|
||||
<div class="combobox-item-template">
|
||||
<div class="combobox-item-template-text">
|
||||
<span>@($"{ctxCombo.DataItem.ShippingDate} [{ctxCombo.DataItem.LicencePlate}]")</span>
|
||||
@* <span class="combobox-item-template-employee-phone">@(string.Join("; ", context.DataItem?.ShippingDocuments?.Select(x => x.Partner?.Name ?? string.Empty)))</span> *@
|
||||
</div>
|
||||
</div>
|
||||
@bind-Value="@SelectedShipping"
|
||||
Text="Select licence plate"
|
||||
ValueFieldName="@nameof(Shipping.Id)"
|
||||
TextFieldName="@nameof(Shipping.LicencePlate)"
|
||||
CssClass="cw-480"
|
||||
Context="ctxShipping"
|
||||
SelectedDataItemChanged="@((SelectedDataItemChangedEventArgs<Shipping> args) => OnSelectedShippingChanged(args))"
|
||||
InputId="cbNotMeasuredShippings">
|
||||
<ItemDisplayTemplate>
|
||||
<span class="@(ctxShipping.DataItem.IsAllMeasured ? "text-success" : "")">@ctxShipping.DisplayText</span>
|
||||
</ItemDisplayTemplate>
|
||||
</DxComboBox>
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Caption="Dokumentum:" ColSpanMd="4">
|
||||
<DxFormLayoutItem Caption="Partner:" ColSpanMd="3">
|
||||
<DxComboBox Data="@SelectedShipping?.ShippingDocuments"
|
||||
@bind-Value="@SelectedShippingDocument"
|
||||
Text="Select document"
|
||||
Text="Select partner"
|
||||
ValueFieldName="@nameof(ShippingDocument.Id)"
|
||||
TextFieldName="@(nameof(ShippingDocument.Partner) + '.' + nameof(Partner.Name))"
|
||||
CssClass="cw-480"
|
||||
Context="ctxShippingDocument"
|
||||
SelectedDataItemChanged="@((SelectedDataItemChangedEventArgs<ShippingDocument> args) => OnSelectedShippingDocumentChanged(args))"
|
||||
InputId="cbShippingDocument"/>
|
||||
InputId="cbShippingDocument">
|
||||
<ItemDisplayTemplate>
|
||||
<span class="@(ctxShippingDocument.DataItem.IsAllMeasured ? "text-success" : "")">@ctxShippingDocument.DisplayText</span>
|
||||
</ItemDisplayTemplate>
|
||||
</DxComboBox>
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Caption="Termék:" ColSpanMd="4">
|
||||
<DxFormLayoutItem Caption="Termék:" ColSpanMd="5">
|
||||
<DxComboBox Data="@SelectedShippingDocument?.ShippingItems"
|
||||
@bind-Value="@SelectedShippingItem"
|
||||
Text="Select item"
|
||||
ValueFieldName="@nameof(ShippingItem.Id)"
|
||||
TextFieldName="@(nameof(ShippingItem.Name))"
|
||||
CssClass="cw-480"
|
||||
Context="ctxShippingitem"
|
||||
SelectedDataItemChanged="@((SelectedDataItemChangedEventArgs<ShippingItem> args) => OnSelectedShippingItemChanged(args))"
|
||||
InputId="cbShippingItem"/>
|
||||
InputId="cbShippingItem">
|
||||
<ItemDisplayTemplate>
|
||||
<span class="@(ctxShippingitem.DataItem.IsMeasured ? "text-success" : "")">@ctxShippingitem.DisplayText)</span>
|
||||
</ItemDisplayTemplate>
|
||||
</DxComboBox>
|
||||
</DxFormLayoutItem>
|
||||
</DxFormLayout>
|
||||
</div>
|
||||
|
|
@ -61,23 +90,23 @@
|
|||
@if (SelectedShippingItem != null)
|
||||
{
|
||||
<EditForm Model="@SelectedShippingItem" Context="FrmContext"
|
||||
OnValidSubmit="@HandleValidSubmit"
|
||||
OnInvalidSubmit="@HandleInvalidSubmit">
|
||||
<DataAnnotationsValidator/>
|
||||
OnValidSubmit="@HandleValidSubmit"
|
||||
OnInvalidSubmit="@HandleInvalidSubmit">
|
||||
<DataAnnotationsValidator />
|
||||
<DxFormLayout Data="@SelectedShippingItem" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" ItemUpdating="@((pair) => OnItemUpdating(pair.Key, pair.Value))">
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.Name)" Caption="Item Name:" ColSpanMd="4" />
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.GrossWeight)" Caption="GrossWeight:" ColSpanMd="4" />
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.NetWeight)" Caption="NetWeight:" ColSpanMd="4" />
|
||||
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.MeasuredGrossWeight)" Caption="MeasuredGrossWeight:" ColSpanMd="4">
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.Name)" Caption="Item Name:" Enabled="false" ColSpanMd="6" />
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.GrossWeight)" Caption="GrossWeight:" Enabled="false" ColSpanMd="3" />
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.NetWeight)" Caption="NetWeight:" Enabled="false" ColSpanMd="3" />
|
||||
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.MeasuredGrossWeight)" Caption="MeasuredGrossWeight:" ColSpanMd="3" BeginRow="true">
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.MeasuredNetWeight)" Caption="MeasuredNetWeight:" ColSpanMd="4">
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.MeasuredNetWeight)" Caption="MeasuredNetWeight:" ColSpanMd="3">
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.IsMeasured)" Caption="IsMeasured:" ColSpanMd="4">
|
||||
<DxFormLayoutItem Field="@nameof(ShippingItem.IsMeasured)" Enabled="false" Caption="IsMeasured:" ColSpanMd="6">
|
||||
</DxFormLayoutItem>
|
||||
|
||||
|
||||
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
|
||||
<ValidationSummary />
|
||||
</DxFormLayoutItem>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ using System.Linq;
|
|||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DevExpress.Data.Mask.Internal;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
|
@ -24,6 +25,17 @@ using ILogger = FruitBank.Common.Loggers.ILogger;
|
|||
|
||||
namespace FruitBankHybrid.Shared.Pages
|
||||
{
|
||||
public class ShippingDateModel
|
||||
{
|
||||
public DateTime DateTime { get; set; }
|
||||
public bool IsMeasured { get; set; }
|
||||
|
||||
public ShippingDateModel(DateTime dateTime, bool isMeasured)
|
||||
{
|
||||
DateTime = dateTime;
|
||||
IsMeasured = isMeasured;
|
||||
}
|
||||
}
|
||||
public partial class MeasuringIn : ComponentBase
|
||||
{
|
||||
[Inject] public required IEnumerable<IAcLogWriterClientBase> LogWriters { get; set; }
|
||||
|
|
@ -36,8 +48,10 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
private ShippingDocument? SelectedShippingDocument { get; set; }
|
||||
private ShippingItem? SelectedShippingItem { get; set; }
|
||||
|
||||
DateTime DateTimeValue { get; set; } = DateTime.Today;
|
||||
protected bool BtnSaveEnabled { get; set; }
|
||||
protected bool ChkAllShipping { get; set; }
|
||||
|
||||
private List<ShippingDateModel> _shippingDates = null!;
|
||||
|
||||
private string _userName = "Partner name";
|
||||
private string _message = string.Empty;
|
||||
|
|
@ -48,24 +62,47 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
_logger = new LoggerClient<MeasuringIn>(LogWriters.ToArray());
|
||||
_logger.Info("OnInitializedAsync");
|
||||
|
||||
await RefreshShippingsFromDb(ChkAllShipping);
|
||||
await RefreshShippingsFromDb(DateTime.Now);
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
private async Task RefreshShippingsFromDb(bool getAllShipping)
|
||||
private async Task RefreshShippingsFromDb(DateTime dateTime)
|
||||
{
|
||||
if (getAllShipping) NotMeasuredShippings = await FruitBankSignalRClient.GetShippings() ?? [];
|
||||
else NotMeasuredShippings = await FruitBankSignalRClient.GetNotMeasuredShippings() ?? [];
|
||||
var shippings = await FruitBankSignalRClient.GetShippings() ?? [];
|
||||
|
||||
_shippingDates = shippings.Select(x => new ShippingDateModel(x.ShippingDate.Date, x.IsAllMeasured)).ToList();
|
||||
NotMeasuredShippings = shippings.Where(x => DaysEqual(x.ShippingDate.Date, dateTime)).ToList();
|
||||
|
||||
//if (getAllShipping) NotMeasuredShippings = await FruitBankSignalRClient.GetShippings() ?? [];
|
||||
//else NotMeasuredShippings = await FruitBankSignalRClient.GetNotMeasuredShippings() ?? [];
|
||||
|
||||
SelectedShipping = NotMeasuredShippings.FirstOrDefault();
|
||||
}
|
||||
|
||||
private async Task OnChkAllShippingChanged(bool value)
|
||||
private async Task OnSelectedShippingDateChanged(DateTime selectedDateTime)
|
||||
=> await RefreshShippingsFromDb(selectedDateTime);
|
||||
|
||||
|
||||
private void OnCustomDisabledDate(CalendarCustomDisabledDateEventArgs args)
|
||||
=> args.IsDisabled = !_shippingDates.Exists(shippingDateModel => DaysEqual(shippingDateModel.DateTime, args.Date));
|
||||
|
||||
private string GetCssClassNames(DateTime date)
|
||||
{
|
||||
ChkAllShipping = value;
|
||||
await RefreshShippingsFromDb(ChkAllShipping);
|
||||
if (_shippingDates.Exists(shipping => !shipping.IsMeasured && shipping.DateTime.Date <= DateTime.Now.Date && DaysEqual(shipping.DateTime, date)))
|
||||
return "fw-bold text-danger";
|
||||
|
||||
if (_shippingDates.Exists(shipping => shipping.IsMeasured && DaysEqual(shipping.DateTime, date)))
|
||||
return "fw-bold text-success";
|
||||
|
||||
if (_shippingDates.Exists(shipping => !shipping.IsMeasured && DaysEqual(shipping.DateTime, date)))
|
||||
return "fw-bold";
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static bool DaysEqual(DateTime date1, DateTime date2)
|
||||
=> (date1.Year == date2.Year && date1.DayOfYear == date2.DayOfYear);
|
||||
|
||||
private void OnSelectedShippingChanged(SelectedDataItemChangedEventArgs<Shipping> eventArgs)
|
||||
{
|
||||
SelectedShippingDocument = eventArgs.DataItem?.ShippingDocuments?.FirstOrDefault();
|
||||
|
|
@ -102,11 +139,11 @@ namespace FruitBankHybrid.Shared.Pages
|
|||
SelectedShippingItem.MeasuredGrossWeight = shippingItemFromDb.MeasuredGrossWeight;
|
||||
SelectedShippingItem.IsMeasured = shippingItemFromDb.IsMeasured;
|
||||
|
||||
if (SelectedShippingItem is { IsMeasured: true })
|
||||
{
|
||||
SelectedShippingDocument?.ShippingItems?.Remove(SelectedShippingItem);
|
||||
SelectedShippingItem = SelectedShippingDocument?.ShippingItems?.FirstOrDefault();
|
||||
}
|
||||
//if (SelectedShippingItem is { IsMeasured: true })
|
||||
//{
|
||||
// SelectedShippingDocument?.ShippingItems?.Remove(SelectedShippingItem);
|
||||
// SelectedShippingItem = SelectedShippingDocument?.ShippingItems?.FirstOrDefault();
|
||||
//}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue