162 lines
5.7 KiB
Plaintext
162 lines
5.7 KiB
Plaintext
@using TIAM.Entities.Products
|
|
@using TIAM.Entities.ServiceProviders
|
|
@using TIAM.Entities.Transfers
|
|
@using TIAM.Entities.Drivers
|
|
@using TIAM.Entities.Users
|
|
@using TIAM.Models.Dtos.Users
|
|
@using TIAMWebApp.Shared.Application.Interfaces
|
|
@using TIAMWebApp.Shared.Application.Utility
|
|
@using AyCode.Services.Loggers
|
|
@using TIAM.Core.Loggers
|
|
@using TIAM.Entities.Addresses
|
|
@using TIAMSharedUI.Shared.Components.Grids
|
|
@using TIAMSharedUI.Pages.Components.EditComponents
|
|
@using AyCode.Core
|
|
@inject IServiceProviderDataService serviceProviderDataService
|
|
@inject IUserDataService userDataService
|
|
@inject ITransferDataService transferDataService
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
|
|
|
|
<AddressGrid @ref="Grid" Data="_detailGridData"
|
|
PageSize="5"
|
|
AutoExpandAllGroupRows="true"
|
|
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
|
|
KeyFieldName="Id"
|
|
ValidationEnabled="false"
|
|
CustomizeEditModel="CustomizeEditModel"
|
|
EditMode="GridEditMode.EditForm"
|
|
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
|
ShowFilterRow="true">
|
|
<Columns>
|
|
<DxGridCommandColumn NewButtonVisible="false" DeleteButtonVisible="false" Width="70" MinWidth="70" FixedPosition="GridColumnFixedPosition.Left" />
|
|
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
|
|
<DxGridDataColumn FieldName="AddressText" />
|
|
<DxGridDataColumn FieldName="IsValid" Width="40" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
|
|
<DxGridDataColumn FieldName="IsHelper" Width="40" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
|
|
<DxGridDataColumn FieldName="Latitude" Width="40"/>
|
|
<DxGridDataColumn FieldName="Longitude" Width="40"/>
|
|
<DxGridDataColumn FieldName="Created" Width="40"/>
|
|
<DxGridDataColumn FieldName="Modified" Width="40"/>
|
|
</Columns>
|
|
<EditFormTemplate>
|
|
@{
|
|
Address bleh = (Address)context.EditModel;
|
|
}
|
|
@* <EditAddressComponent TModel="Address" Model="@bleh" OnAddressChanged="@((Address model) => SaveAddress(model))" /> *@
|
|
<EditAddressComponent Model="@((Address)context.EditModel)" OnAddressChanged="@((Address model) => SaveAddress(model))" />
|
|
</EditFormTemplate>
|
|
|
|
</AddressGrid>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public bool KeyboardNavigationEnabled { get; set; }
|
|
[Parameter]
|
|
public object AddressContext { get; set; }
|
|
[Parameter]
|
|
public string ContextIdType { get; set; }
|
|
IGrid Grid { get; set; }
|
|
|
|
List<TIAM.Entities.Addresses.Address> _detailGridData = new List<Address>();
|
|
|
|
List<TIAM.Entities.Addresses.Address> _availableProfiles;
|
|
|
|
ILogger _logger;
|
|
|
|
public void SaveAddress(object addressOwnerToSave)
|
|
{
|
|
|
|
Grid.SaveChangesAsync();
|
|
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
Address myAddress = new Address();
|
|
|
|
|
|
_logger = new LoggerClient<AddressGridComponent>(LogWriters.ToArray());
|
|
if(ContextIdType == null)
|
|
{
|
|
//get all profiles from DB
|
|
}
|
|
else
|
|
{
|
|
switch (ContextIdType)
|
|
{
|
|
case ("userprofile"):
|
|
//get profile for user
|
|
UserModelDto resultData = (UserModelDto)AddressContext;
|
|
if (resultData.ProfileDto.Address != null)
|
|
_detailGridData.Add(resultData.ProfileDto.Address);
|
|
break;
|
|
case ("userdetailprofile"):
|
|
//get profile for user
|
|
UserModelDtoDetail resultData2 = (UserModelDtoDetail)AddressContext;
|
|
if (resultData2.ProfileDto.Address != null)
|
|
_detailGridData.Add(resultData2.ProfileDto.Address);
|
|
break;
|
|
case ("productprofile"):
|
|
//get profile for user
|
|
Product resultData3 = (Product)AddressContext;
|
|
if (resultData3.Profile.Address != null)
|
|
_detailGridData.Add(resultData3.Profile.Address);
|
|
break;
|
|
case ("companyprofile"):
|
|
//get profile for user
|
|
var resultData4 = (Company)AddressContext;
|
|
if (resultData4.Profile.Address != null)
|
|
_detailGridData.Add(resultData4.Profile.Address);
|
|
break;
|
|
case ("transferdestination"):
|
|
//get address for transferDestination
|
|
TransferDestination resultData5 = (TransferDestination)AddressContext;
|
|
if (resultData5.Address != null)
|
|
_detailGridData.Add(resultData5.Address);
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
_logger.Info($"DetailGridData: {_detailGridData.Count}");
|
|
}
|
|
|
|
|
|
|
|
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
|
{
|
|
if (!e.IsNew) return;
|
|
|
|
//editmodel customize
|
|
|
|
|
|
}
|
|
|
|
async Task EditModelSaving(GridEditModelSavingEventArgs e)
|
|
{
|
|
if (e.IsNew)
|
|
//add new orderData to orderData array
|
|
_logger.Info("Data added");
|
|
else
|
|
_logger.Info("Data updated: " + ((Address)e.EditModel).IsValid);
|
|
|
|
await UpdateDataAsync();
|
|
}
|
|
|
|
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
|
|
{
|
|
|
|
_logger.Info("orderData deleted");
|
|
|
|
}
|
|
|
|
async Task UpdateDataAsync()
|
|
{
|
|
//refresh grid
|
|
_logger.Info("orderData grid refreshed");
|
|
StateHasChanged();
|
|
}
|
|
|
|
}
|