address search fix
This commit is contained in:
parent
97c6cb3009
commit
7e9bb7939a
|
|
@ -2,15 +2,12 @@
|
|||
@using TIAMWebApp.Shared.Application.Services
|
||||
@inject GooglePlacesService GooglePlacesService
|
||||
|
||||
<h4>
|
||||
@NullText
|
||||
</h4>
|
||||
|
||||
|
||||
<DxTextBox @bind-Text="Address"
|
||||
CssClass="form-field"
|
||||
@oninput="OnInputChanged"
|
||||
BindValueMode="BindValueMode.OnDelayedInput"
|
||||
InputDelay="500">
|
||||
InputDelay="700">
|
||||
</DxTextBox>
|
||||
|
||||
@if (Predictions.Count > 0)
|
||||
|
|
@ -21,6 +18,10 @@
|
|||
@bind-Value="SelectedPrediction">
|
||||
</DxComboBox>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>No address found</p>
|
||||
}
|
||||
|
||||
|
||||
@code {
|
||||
|
|
@ -31,7 +32,21 @@
|
|||
|
||||
private string Address { get; set; }
|
||||
private List<PredictionItem> Predictions { get; set; } = new();
|
||||
private PredictionItem SelectedPrediction { get; set; }
|
||||
private PredictionItem selectedPrediction { get; set; }
|
||||
public PredictionItem SelectedPrediction
|
||||
{
|
||||
get => selectedPrediction;
|
||||
set
|
||||
{
|
||||
SetNewDestination(value.Description);
|
||||
selectedPrediction = value;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetNewDestination(string address)
|
||||
{
|
||||
await AddressChanged.InvokeAsync(address);
|
||||
}
|
||||
|
||||
private async Task OnInputChanged(ChangeEventArgs e)
|
||||
{
|
||||
|
|
@ -48,7 +63,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
private class PredictionItem
|
||||
public class PredictionItem
|
||||
{
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,14 @@
|
|||
@using AyCode.Services.Loggers
|
||||
@using System.Reflection
|
||||
@using AyCode.Blazor.Components.Components
|
||||
@using TIAM.Entities.Products
|
||||
@using TIAM.Entities.Transfers
|
||||
@using TIAM.Models.Dtos.Users
|
||||
@using TIAMSharedUI.Shared
|
||||
@using TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject ISessionService _sessionService
|
||||
|
||||
@if (isEditing)
|
||||
{
|
||||
|
|
@ -47,6 +51,9 @@ else
|
|||
[Parameter] public List<string> IgnoreReflection { get; set; }
|
||||
[Parameter] public EventCallback<object> OnSubmit { get; set; }
|
||||
[Parameter] public bool isEditing { get; set; } = false;
|
||||
[Parameter] public bool userAvailable { get; set; }
|
||||
[Parameter] public UserModelDtoDetail userModelDtodetail { get; set; }
|
||||
[Parameter] public Product CurrentProduct { get; set; }
|
||||
|
||||
string _formSubmitResult = "";
|
||||
private string _spinnerClass = "";
|
||||
|
|
@ -62,6 +69,12 @@ else
|
|||
base.OnInitialized();
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
StateHasChanged();
|
||||
base.OnParametersSet();
|
||||
}
|
||||
|
||||
// void HandleValidSubmit()
|
||||
// {
|
||||
// FormSubmitResult = "You have been registered successfully.";
|
||||
|
|
@ -238,9 +251,14 @@ else
|
|||
}
|
||||
else if (property.PropertyType == typeof(string) && string.Compare(attrList.CustomDataType, "TransferDestination", true) == 0)
|
||||
{
|
||||
|
||||
editor.OpenComponent<ComboboxItemSelector>(j);
|
||||
editor.AddAttribute(j++, "TextValue", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
if (CurrentProduct != null)
|
||||
{
|
||||
editor.AddAttribute(j++, "ProductId", CurrentProduct.Id);
|
||||
}
|
||||
// editor.AddAttribute(j++, "ValExpression", lambda);
|
||||
editor.AddAttribute(j++, "OnSliderChanged", EventCallback.Factory.Create<string>(this, result =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<AuthComponent />
|
||||
|
||||
<HeroSlider SliderItems="@sliders" PBottom="50px" Height="50vh"></HeroSlider>
|
||||
<div class="container" style="position: relative; z-index: 2;">
|
||||
<div class="container-fluid" style="position: relative; z-index: 2;">
|
||||
<div class="row d-flex justify-content-center">
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="card bg-white p-3">
|
||||
|
|
@ -35,8 +35,6 @@
|
|||
SubmitButtonText="ButtonSend"
|
||||
TitleResourceString="TransferTitle"
|
||||
SubtitleResourceString="TransferSubtitle"></InputWizard>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
<div class="row py-3">
|
||||
|
||||
<DynamicEditForm Data="Data" isEditing="true" IgnoreReflection="TransferIgnorList" OnSubmit="SubmitForm"></DynamicEditForm>
|
||||
<DynamicEditForm Data="Data" CurrentProduct="@SelectedHotel" isEditing="true" IgnoreReflection="TransferIgnorList" OnSubmit="SubmitForm"></DynamicEditForm>
|
||||
</div>
|
||||
|
||||
<div class="row py-3">
|
||||
|
|
@ -68,7 +68,20 @@
|
|||
private LoggerClient<CreateAndManageTransfer> _logger;
|
||||
private TransferWizardModel Data = new();
|
||||
private List<Product> Hotels = new List<Product>();
|
||||
private Product SelectedHotel;
|
||||
private Product selectedHotel { get; set; }
|
||||
public Product SelectedHotel
|
||||
{
|
||||
get
|
||||
{
|
||||
return selectedHotel;
|
||||
}
|
||||
set
|
||||
{
|
||||
selectedHotel = value;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> TransferIgnorList = new List<string>
|
||||
{
|
||||
nameof(TransferWizardModel.Id),
|
||||
|
|
@ -82,6 +95,7 @@
|
|||
nameof(TransferWizardModel.Price)
|
||||
};
|
||||
private bool isReloadVisible = false;
|
||||
private bool SelectedHotelInitialized = false;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
|
|
@ -92,7 +106,11 @@
|
|||
if (SessionService.User.UserModelDto.Products.Any(x => x.ProductType == TIAM.Core.Enums.ProductType.Hotel))
|
||||
{
|
||||
Hotels = SessionService.GetHotels();
|
||||
if(!SelectedHotelInitialized)
|
||||
{
|
||||
SelectedHotel = Hotels[0];
|
||||
SelectedHotelInitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -157,6 +175,7 @@
|
|||
{
|
||||
Data = new TransferWizardModel();
|
||||
isReloadVisible = false;
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<div class="card-body card-admin-body py-2 px-4">
|
||||
<div class="d-flex flex-column mb-4 pb-2">
|
||||
|
||||
|
||||
<p>@userId.ToString()</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
@using System.Linq.Expressions
|
||||
@using AyCode.Core.Extensions
|
||||
@using AyCode.Core.Loggers
|
||||
@using AyCode.Services.Loggers
|
||||
@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
|
||||
|
|
@ -12,10 +15,16 @@
|
|||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject AdminSignalRClient _adminSignalRClient
|
||||
@inject ITransferDataService TransferDataService
|
||||
@using TIAMWebApp.Shared.Application.Services
|
||||
@inject GooglePlacesService GooglePlacesService
|
||||
|
||||
<label for="cbOverview" class="demo-text cw-480 mb-1">
|
||||
Select a destination
|
||||
</label>
|
||||
<DxTabs>
|
||||
<DxTabPage Text="Preset addresses">
|
||||
|
||||
|
||||
<DxComboBox Data="@Data"
|
||||
InputCssClass="@CssClass"
|
||||
@bind-Value="@SelectedDestination"
|
||||
|
|
@ -23,9 +32,31 @@
|
|||
SearchFilterCondition="@ListSearchFilterCondition.Contains"
|
||||
ListRenderMode="ListRenderMode.Virtual"
|
||||
TextFieldName="@nameof(TransferDestination.Name)"
|
||||
CssClass="cw-480"
|
||||
InputId="cbOverview" />
|
||||
|
||||
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Address locator">
|
||||
|
||||
<AddressSearchAndSelectComponent AddressChanged="@OnSelectedAddressChanged">
|
||||
|
||||
</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> *@
|
||||
|
|
@ -46,6 +77,8 @@
|
|||
|
||||
[Parameter] public string CssClass { get; set; } = "";
|
||||
|
||||
[Parameter] public Guid? ProductId { get; set; }
|
||||
|
||||
public List<TransferDestination> Destinations = new List<TransferDestination>();
|
||||
|
||||
public DxTextBox TextField;
|
||||
|
|
@ -56,6 +89,9 @@
|
|||
|
||||
IEnumerable<TransferDestination> Data { get; set; }
|
||||
|
||||
private string Address { get; set; }
|
||||
private string ValidationMessage { get; set; }
|
||||
|
||||
private TransferDestination _selectedDestination;
|
||||
public TransferDestination SelectedDestination
|
||||
{
|
||||
|
|
@ -65,14 +101,14 @@
|
|||
if (_selectedDestination != value)
|
||||
{
|
||||
_selectedDestination = value;
|
||||
SetNewDestination(value);
|
||||
SetNewDestination(value.AddressString!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
|
||||
// StateHasChanged();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
|
|
@ -80,9 +116,30 @@
|
|||
_logger = new LoggerClient<ComboboxItemSelector>(LogWriters.ToArray());
|
||||
|
||||
Data = await _adminSignalRClient.GetAllAsync<List<TransferDestination>>(SignalRTags.GetAllTransferDestinations);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Debug($"List length: {Data.Count().ToString()}");
|
||||
if (Data.Any(x => x.AddressId == (Guid)productAddressId))
|
||||
{
|
||||
SelectedDestination = Data.Where(x => x.AddressId == (Guid)productAddressId).FirstOrDefault()!;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedDestination = Data.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
// RenderFragment GetSelectedItemDescription()
|
||||
// {
|
||||
// if (SelectedDestination != null)
|
||||
|
|
@ -100,9 +157,16 @@
|
|||
|
||||
// }
|
||||
|
||||
public void SetNewDestination(TransferDestination destination)
|
||||
public void OnSelectedAddressChanged(string address)
|
||||
{
|
||||
OnSliderChanged.InvokeAsync(destination.AddressString);
|
||||
Address = address;
|
||||
OnSliderChanged.InvokeAsync(address);
|
||||
}
|
||||
|
||||
public void SetNewDestination(string address)
|
||||
{
|
||||
Address = address;
|
||||
OnSliderChanged.InvokeAsync(address);
|
||||
}
|
||||
|
||||
// RenderFragment GetFieldDescription(string fieldName, object value)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@using BlazorAnimation
|
||||
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI
|
||||
<header style="padding-bottom: @PBottom;">
|
||||
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
|
||||
<div id="owl-demo" class="owl-carousel owl-theme" style="position:absolute; z-index: 1;">
|
||||
|
||||
@{
|
||||
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
</div>
|
||||
|
||||
</Animation>
|
||||
|
||||
|
||||
</header>
|
||||
|
|
|
|||
Loading…
Reference in New Issue