122 lines
4.2 KiB
Plaintext
122 lines
4.2 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
|
|
@inject IUserDataService NwindDataService
|
|
@inject IServiceProviderDataService serviceProviderDataService
|
|
@inject LogToBrowserConsole logToBrowserConsole
|
|
|
|
<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 Customer { get; set; }
|
|
|
|
List<TiamServiceProvider> DetailGridData;
|
|
|
|
List<TiamServiceProvider> AvailableServices;
|
|
|
|
public UserModelDtoDetail UserInfo;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
|
|
//get userproductmappings by customer id
|
|
if (Customer.ServiceProviders == null)
|
|
DetailGridData = new List<TiamServiceProvider>();
|
|
else
|
|
DetailGridData = Customer.ServiceProviders;
|
|
|
|
AvailableServices = await serviceProviderDataService.GetServiceProvidersAsync();
|
|
logToBrowserConsole.LogToBC($"DetailGridData: {DetailGridData.Count}");
|
|
}
|
|
|
|
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
|
{
|
|
if (e.IsNew)
|
|
{
|
|
UserProductMapping newProductMapping = new UserProductMapping();
|
|
newProductMapping.ProductId = Guid.NewGuid();
|
|
newProductMapping.UserId = Customer.Id;
|
|
newProductMapping.Permissions = 1;
|
|
|
|
e.EditModel = newProductMapping;
|
|
}
|
|
}
|
|
|
|
async Task EditModelSaving(GridEditModelSavingEventArgs e)
|
|
{
|
|
if (e.IsNew)
|
|
//add new orderData to orderData array
|
|
logToBrowserConsole.LogToBC("New orderData added");
|
|
//await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel);
|
|
else
|
|
logToBrowserConsole.LogToBC("orderData updated");
|
|
|
|
//await NwindDataService.UpdateEmployeeAsync((EditableEmployee)e.DataItem, (EditableEmployee)e.EditModel);
|
|
|
|
await UpdateDataAsync();
|
|
}
|
|
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
|
|
{
|
|
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
|
|
//remove orderData from orderData array
|
|
logToBrowserConsole.LogToBC("orderData deleted");
|
|
//await UpdateDataAsync();
|
|
}
|
|
async Task UpdateDataAsync()
|
|
{
|
|
//DataSource = await NwindDataService.GetEmployeesEditableAsync();
|
|
//refresh grid
|
|
logToBrowserConsole.LogToBC("orderData grid refreshed");
|
|
}
|
|
|
|
} |