191 lines
5.9 KiB
Plaintext
191 lines
5.9 KiB
Plaintext
@using System.Linq.Expressions
|
|
@using AyCode.Core.Extensions
|
|
@using AyCode.Core.Helpers
|
|
@using AyCode.Core.Loggers
|
|
@using AyCode.Services.Loggers
|
|
@using AyCode.Services.SignalRs
|
|
@using TIAM.Core.Loggers
|
|
@using TIAM.Entities.Products
|
|
@using TIAM.Entities.Transfers
|
|
@using TIAM.Services
|
|
@using TIAMSharedUI.Pages
|
|
@using TIAMSharedUI.Pages.Components
|
|
@using TIAMSharedUI.Pages.User.SysAdmins
|
|
@using TIAMWebApp.Shared.Application.Interfaces
|
|
@using TIAMWebApp.Shared.Application.Services
|
|
@using TIAMWebApp.Shared.Application.Utility
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
@inject AdminSignalRClient _adminSignalRClient
|
|
@inject ITransferDataService TransferDataService
|
|
@using TIAMWebApp.Shared.Application.Services
|
|
@inject GooglePlacesService GooglePlacesService
|
|
|
|
|
|
<DxTabs SizeMode="SizeMode.Small" CssClass="bg-light">
|
|
<DxTabPage Text="Preset addresses">
|
|
|
|
|
|
<DxComboBox Data="@Data"
|
|
CssClass="p-3"
|
|
InputCssClass="@CssClass"
|
|
@bind-Value="@SelectedDestination"
|
|
SearchMode="@ListSearchMode.AutoSearch"
|
|
SearchFilterCondition="@ListSearchFilterCondition.Contains"
|
|
ListRenderMode="ListRenderMode.Virtual"
|
|
TextFieldName="@nameof(TransferDestination.Name)"
|
|
InputId="cbOverview"
|
|
SizeMode="SizeMode.Small" />
|
|
|
|
|
|
</DxTabPage>
|
|
<DxTabPage Text="Custom address">
|
|
|
|
<AddressSearchAndSelectComponent AddressChanged="@OnSelectedAddressChanged" CssClass="@CssClass">
|
|
|
|
</AddressSearchAndSelectComponent>
|
|
@* <DxFormLayoutItem Caption="Type a custom address">
|
|
<DxTextBox @bind-Text="Address" />
|
|
</DxFormLayoutItem>
|
|
<DxFormLayoutItem>
|
|
<DxButton Context="ButtonContext" Click="ValidateAddress">Validate Address</DxButton>
|
|
</DxFormLayoutItem>
|
|
<DxFormLayoutItem>
|
|
<p>@ValidationMessage</p>
|
|
</DxFormLayoutItem> *@
|
|
|
|
</DxTabPage>
|
|
</DxTabs>
|
|
|
|
<p>Selected address: @Address</p>
|
|
|
|
|
|
@* <p class="demo-text cw-480 mt-3">
|
|
@GetSelectedItemDescription()
|
|
</p> *@
|
|
|
|
@*
|
|
<DxComboBox Data="@Data"
|
|
ValueExpression="@valueExpression"
|
|
TextFieldName="@nameof(TransferDestination.Name)"
|
|
CssClass="cw-480"
|
|
InputId="cbOverview"
|
|
ValueChanged="@((TransferDestination destination) => SetNewDestination(destination))" /> *@
|
|
|
|
|
|
@code {
|
|
[Parameter] public EventCallback<string> OnSliderChanged { get; set; }
|
|
|
|
[Parameter] public string TextValue { get; set; } = "";
|
|
|
|
[Parameter] public string CssClass { get; set; } = "";
|
|
|
|
[Parameter] public Guid? ProductId { get; set; }
|
|
|
|
public List<TransferDestination> Destinations = [];
|
|
|
|
public DxTextBox TextField;
|
|
|
|
TransferDestination Result;
|
|
|
|
ILogger _logger;
|
|
|
|
List<TransferDestination> Data { get; set; } = [];
|
|
|
|
private string Address { get; set; }
|
|
private string ValidationMessage { get; set; }
|
|
|
|
private TransferDestination? _selectedDestination;
|
|
public TransferDestination? SelectedDestination
|
|
{
|
|
get => _selectedDestination;
|
|
set
|
|
{
|
|
if (_selectedDestination == value) return;
|
|
|
|
_selectedDestination = value;
|
|
SetNewDestination(value?.AddressString ?? string.Empty);
|
|
}
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
// StateHasChanged();
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_logger = new LoggerClient<ComboboxItemSelector>(LogWriters.ToArray());
|
|
|
|
Guid? productAddressId = Guid.Empty;
|
|
if (!ProductId.IsNullOrEmpty())
|
|
{
|
|
var currentProduct = await _adminSignalRClient.GetByIdAsync<Product>(SignalRTags.GetProductById, ProductId);
|
|
if (currentProduct != null)
|
|
{
|
|
if (!currentProduct.Profile.AddressId.IsNullOrEmpty())
|
|
{
|
|
productAddressId = currentProduct.Profile.AddressId;
|
|
}
|
|
}
|
|
}
|
|
|
|
_adminSignalRClient.GetAllAsync<List<TransferDestination>>(SignalRTags.GetAllTransferDestinations, response =>
|
|
{
|
|
Data.Clear();
|
|
SelectedDestination = null;
|
|
|
|
if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
|
|
{
|
|
_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()
|
|
// {
|
|
// if (SelectedDestination != null)
|
|
// {
|
|
// SetNewDestination(SelectedDestination);
|
|
// return @<text>
|
|
// Selected Item: (
|
|
// @GetFieldDescription(nameof(TransferDestination.Name), SelectedDestination.Name),
|
|
// @GetFieldDescription(nameof(TransferDestination.AddressString), SelectedDestination.AddressString),
|
|
// @GetFieldDescription(nameof(TransferDestination.Description), SelectedDestination.Description)
|
|
// )
|
|
// </text>;
|
|
// }
|
|
// return @<text>Selected Item: <b>null</b></text>;
|
|
|
|
// }
|
|
|
|
public void OnSelectedAddressChanged(string address)
|
|
{
|
|
Address = address;
|
|
OnSliderChanged.InvokeAsync(address);
|
|
}
|
|
|
|
public void SetNewDestination(string address)
|
|
{
|
|
Address = address;
|
|
OnSliderChanged.InvokeAsync(address);
|
|
}
|
|
|
|
// RenderFragment GetFieldDescription(string fieldName, object value)
|
|
// {
|
|
// return @<text>@fieldName: <b>@value</b></text>;
|
|
// }
|
|
|
|
|
|
}
|
|
|