ComboboxItemSelector.razor improvements, fixes, etc...
This commit is contained in:
parent
5bc9663930
commit
1f59b4b8a3
|
|
@ -1,7 +1,9 @@
|
||||||
@using System.Linq.Expressions
|
@using System.Linq.Expressions
|
||||||
@using AyCode.Core.Extensions
|
@using AyCode.Core.Extensions
|
||||||
|
@using AyCode.Core.Helpers
|
||||||
@using AyCode.Core.Loggers
|
@using AyCode.Core.Loggers
|
||||||
@using AyCode.Services.Loggers
|
@using AyCode.Services.Loggers
|
||||||
|
@using AyCode.Services.SignalRs
|
||||||
@using TIAM.Core.Loggers
|
@using TIAM.Core.Loggers
|
||||||
@using TIAM.Entities.Products
|
@using TIAM.Entities.Products
|
||||||
@using TIAM.Entities.Transfers
|
@using TIAM.Entities.Transfers
|
||||||
|
|
@ -79,7 +81,7 @@
|
||||||
|
|
||||||
[Parameter] public Guid? ProductId { get; set; }
|
[Parameter] public Guid? ProductId { get; set; }
|
||||||
|
|
||||||
public List<TransferDestination> Destinations = new List<TransferDestination>();
|
public List<TransferDestination> Destinations = [];
|
||||||
|
|
||||||
public DxTextBox TextField;
|
public DxTextBox TextField;
|
||||||
|
|
||||||
|
|
@ -87,22 +89,21 @@
|
||||||
|
|
||||||
ILogger _logger;
|
ILogger _logger;
|
||||||
|
|
||||||
IEnumerable<TransferDestination> Data { get; set; }
|
List<TransferDestination> Data { get; set; } = [];
|
||||||
|
|
||||||
private string Address { get; set; }
|
private string Address { get; set; }
|
||||||
private string ValidationMessage { get; set; }
|
private string ValidationMessage { get; set; }
|
||||||
|
|
||||||
private TransferDestination _selectedDestination;
|
private TransferDestination? _selectedDestination;
|
||||||
public TransferDestination SelectedDestination
|
public TransferDestination? SelectedDestination
|
||||||
{
|
{
|
||||||
get => _selectedDestination;
|
get => _selectedDestination;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_selectedDestination != value)
|
if (_selectedDestination == value) return;
|
||||||
{
|
|
||||||
_selectedDestination = value;
|
_selectedDestination = value;
|
||||||
SetNewDestination(value.AddressString!);
|
SetNewDestination(value?.AddressString ?? string.Empty);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,8 +116,6 @@
|
||||||
{
|
{
|
||||||
_logger = new LoggerClient<ComboboxItemSelector>(LogWriters.ToArray());
|
_logger = new LoggerClient<ComboboxItemSelector>(LogWriters.ToArray());
|
||||||
|
|
||||||
Data = await _adminSignalRClient.GetAllAsync<List<TransferDestination>>(SignalRTags.GetAllTransferDestinations);
|
|
||||||
|
|
||||||
Guid? productAddressId = Guid.Empty;
|
Guid? productAddressId = Guid.Empty;
|
||||||
if (!ProductId.IsNullOrEmpty())
|
if (!ProductId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -130,16 +129,28 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug($"List length: {Data.Count().ToString()}");
|
_adminSignalRClient.GetAllAsync<List<TransferDestination>>(SignalRTags.GetAllTransferDestinations, response =>
|
||||||
if (Data.Any(x => x.AddressId == (Guid)productAddressId))
|
|
||||||
{
|
{
|
||||||
SelectedDestination = Data.Where(x => x.AddressId == (Guid)productAddressId).FirstOrDefault()!;
|
Data.Clear();
|
||||||
}
|
SelectedDestination = null;
|
||||||
else
|
|
||||||
{
|
if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
|
||||||
SelectedDestination = Data.FirstOrDefault();
|
{
|
||||||
}
|
_logger.Error($"OnInitializedAsync->GetAllTransferDestinations; response.Status: {response.Status}");
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
Data.AddRange(response.ResponseData);
|
||||||
|
|
||||||
|
_logger.Debug($"TransferDestinations Data length: {Data.Count}");
|
||||||
|
SelectedDestination = productAddressId.IsNullOrEmpty() ? Data.FirstOrDefault() : Data.FirstOrDefault(x => x.AddressId == productAddressId);
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}).Forget();
|
||||||
|
|
||||||
|
//await _adminSignalRClient.GetAllIntoAsync(Data, SignalRTags.GetAllTransferDestinations);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderFragment GetSelectedItemDescription()
|
// RenderFragment GetSelectedItemDescription()
|
||||||
// {
|
// {
|
||||||
// if (SelectedDestination != null)
|
// if (SelectedDestination != null)
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,9 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
//TODO: AdminSignalRClient.GetAllIntoAsync<Car>(_cars, SignalRTags.GetAllCarsByProductId, [productId]) - J.
|
//TODO: AdminSignalRClient.GetAllIntoAsync<Car>(_cars, SignalRTags.GetAllCarsByProductId, [productId]) - J.
|
||||||
return GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, response =>
|
return GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, response =>
|
||||||
{
|
{
|
||||||
|
intoCars.Clear();
|
||||||
if (response is { Status: SignalResponseStatus.Success, ResponseData: not null })
|
if (response is { Status: SignalResponseStatus.Success, ResponseData: not null })
|
||||||
{
|
{
|
||||||
intoCars.Clear();
|
|
||||||
intoCars.AddRange(response.ResponseData);
|
intoCars.AddRange(response.ResponseData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue