120 lines
3.7 KiB
Plaintext
120 lines
3.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
|
|
@inject IServiceProviderDataService ServiceProviderDataService
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
|
|
<div class="mb-2">
|
|
UserProductMapping
|
|
</div>
|
|
<DxGrid Data="_detailGridData"
|
|
PageSize="5"
|
|
AutoExpandAllGroupRows="true"
|
|
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
|
|
KeyFieldName="Id"
|
|
ValidationEnabled="false"
|
|
CustomizeEditModel="CustomizeEditModel"
|
|
EditModelSaving="EditModelSaving"
|
|
DataItemDeleting="DataItemDeleting"
|
|
EditMode="GridEditMode.EditForm"
|
|
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
|
ShowFilterRow="true">
|
|
<Columns>
|
|
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
|
|
<DxGridDataColumn FieldName="Id" GroupIndex="0" />
|
|
<DxGridDataColumn FieldName="UserId" />
|
|
<DxGridDataColumn FieldName="ProductId" Width="40%" />
|
|
<DxGridDataColumn FieldName="Permissions" />
|
|
</Columns>
|
|
<EditFormTemplate Context="EditFormContext">
|
|
@{
|
|
var transfer2 = (UserProductMapping)EditFormContext.EditModel;
|
|
}
|
|
<DxFormLayout CssClass="w-100">
|
|
<DxFormLayoutItem Caption="UserId" ColSpanMd="4">
|
|
@EditFormContext.GetEditor("UserId")
|
|
</DxFormLayoutItem>
|
|
<DxFormLayoutItem Caption="Product:" ColSpanMd="4">
|
|
<DxComboBox Data="@_availableServices" TextFieldName="Name" @bind-Value="((UserProductMapping)EditFormContext.EditModel).ProductId" />
|
|
</DxFormLayoutItem>
|
|
<DxFormLayoutItem Caption="Permissions" ColSpanMd="4">
|
|
@EditFormContext.GetEditor("Permissions")
|
|
</DxFormLayoutItem>
|
|
|
|
|
|
|
|
</DxFormLayout>
|
|
</EditFormTemplate>
|
|
|
|
</DxGrid>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public bool KeyboardNavigationEnabled { get; set; }
|
|
[Parameter]
|
|
public UserModelDtoDetail UserModelDtoDetail { get; set; }
|
|
|
|
List<Company> _detailGridData;
|
|
|
|
List<Company> _availableServices;
|
|
|
|
public UserModelDtoDetail UserInfo;
|
|
|
|
ILogger _logger;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_logger = new LoggerClient<UserGrid_MasterDetail_NestedGrid_ServiceProviders>(LogWriters.ToArray());
|
|
|
|
_detailGridData = UserModelDtoDetail.ServiceProviders ?? new List<Company>();
|
|
_availableServices = await ServiceProviderDataService.GetServiceProvidersAsync();
|
|
|
|
_logger.Info($"DetailGridData: {_detailGridData.Count}");
|
|
}
|
|
|
|
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
|
{
|
|
if (!e.IsNew) return;
|
|
|
|
var newProductMapping = new UserProductMapping
|
|
{
|
|
ProductId = Guid.NewGuid(),
|
|
UserId = UserModelDtoDetail.Id,
|
|
Permissions = 1
|
|
};
|
|
|
|
e.EditModel = newProductMapping;
|
|
}
|
|
|
|
async Task EditModelSaving(GridEditModelSavingEventArgs e)
|
|
{
|
|
if (e.IsNew)
|
|
//add new orderData to orderData array
|
|
_logger.Info("New orderData added");
|
|
else
|
|
_logger.Info("orderData updated");
|
|
|
|
await UpdateDataAsync();
|
|
}
|
|
|
|
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
|
|
{
|
|
//remove orderData from orderData array
|
|
_logger.Info("orderData deleted");
|
|
//await UpdateDataAsync();
|
|
}
|
|
|
|
async Task UpdateDataAsync()
|
|
{
|
|
//refresh grid
|
|
_logger.Info("orderData grid refreshed");
|
|
}
|
|
|
|
} |