122 lines
3.5 KiB
Plaintext
122 lines
3.5 KiB
Plaintext
@using TIAM.Entities.Products
|
|
@using TIAM.Entities.ServiceProviders
|
|
@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 IUserDataService userDataService
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
|
|
<div class="mb-2">
|
|
<h3>Profile</h3>
|
|
</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>
|
|
|
|
|
|
</DxGrid>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public bool KeyboardNavigationEnabled { get; set; }
|
|
[Parameter]
|
|
public object ProfileContext { get; set; }
|
|
[Parameter]
|
|
public string ContextIdType { get; set; }
|
|
|
|
List<TIAM.Entities.Profiles.Profile> _detailGridData;
|
|
|
|
List<TIAM.Entities.Profiles.Profile> _availableProfiles;
|
|
|
|
ILogger _logger;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_logger = new LoggerClient<ProfileGridComponent>(LogWriters.ToArray());
|
|
if(ContextIdType == null)
|
|
{
|
|
//get all profiles from DB
|
|
}
|
|
else
|
|
{
|
|
switch (ContextIdType)
|
|
{
|
|
case ("user"):
|
|
//get profile for user
|
|
UserModelDto resultData = (UserModelDto)ProfileContext;
|
|
_detailGridData.Add(resultData.UserDto.Profile);
|
|
break;
|
|
case ("product"):
|
|
//get profile for product
|
|
//var resultData2 = await serviceProviderDataService.GetProductById(ContextId); //todo
|
|
Product resultData2 = (Product)ProfileContext;
|
|
_detailGridData.Add(resultData2.Profile);
|
|
break;
|
|
case ("company"):
|
|
//get profile for company
|
|
Company resultData3 = (Company)ProfileContext;
|
|
_detailGridData.Add(resultData3.Profile);
|
|
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");
|
|
|
|
await UpdateDataAsync();
|
|
}
|
|
|
|
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
|
|
{
|
|
|
|
_logger.Info("orderData deleted");
|
|
|
|
}
|
|
|
|
async Task UpdateDataAsync()
|
|
{
|
|
//refresh grid
|
|
_logger.Info("orderData grid refreshed");
|
|
StateHasChanged();
|
|
}
|
|
|
|
}
|