169 lines
7.5 KiB
Plaintext
169 lines
7.5 KiB
Plaintext
@using TIAM.Entities.Products
|
|
@using TIAM.Entities.Transfers
|
|
@using TIAM.Entities.Drivers
|
|
@using TIAM.Entities.Users
|
|
@using TIAM.Models.Dtos.Users
|
|
@using TIAM.Services
|
|
@using TIAMSharedUI.Shared.Components.Grids
|
|
@using TIAMWebApp.Shared.Application.Interfaces
|
|
@using TIAMWebApp.Shared.Application.Services
|
|
@using TIAMWebApp.Shared.Application.Utility
|
|
@using TIAM.Core.Loggers
|
|
@using AyCode.Core.Loggers
|
|
@using AyCode.Services.Loggers
|
|
@using AyCode.Core
|
|
@using AyCode.Core.Enums
|
|
@using AyCode.Core.Helpers
|
|
@using AyCode.Models.Users
|
|
@using AyCode.Services.SignalRs
|
|
@using TIAM.Core.Consts
|
|
@inject IServiceProviderDataService ServiceProviderDataService
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
@inject AdminSignalRClient AdminSignalRClient
|
|
|
|
|
|
<UserProductMappingGrid Logger="_logger"
|
|
ContextIds="ContextIds?.Cast<object>().ToArray()"
|
|
GetAllMessageTag="GetAllTag"
|
|
SignalRClient="AdminSignalRClient"
|
|
PageSize="10"
|
|
ValidationEnabled="false"
|
|
CustomizeEditModel="CustomizeEditModel"
|
|
EditMode="GridEditMode.EditRow"
|
|
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
|
OnGridEditModelSaving="OnGridEditModelSaving"
|
|
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
|
|
OnGridItemChanged="OnGridItemChanged">
|
|
<Columns>
|
|
<DxGridCommandColumn Width="150" MinWidth="150" Visible="CommandColumnVisible" NewButtonVisible="NewButtonVisible" EditButtonVisible="EditButtonVisible" DeleteButtonVisible="DeleteButtonVisible" FixedPosition="GridColumnFixedPosition.Left" />
|
|
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
|
|
<DxGridDataColumn FieldName="ProductId" Caption="ServiceId" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
|
|
@{
|
|
var productNameFieldName = $"{nameof(UserProductMapping.Product)}.{nameof(Product.Name)}";
|
|
}
|
|
<DxGridDataColumn FieldName="@productNameFieldName" Caption="Service name">
|
|
<CellEditTemplate>
|
|
@{
|
|
var userProductMappingEditModel = (UserProductMapping)context.EditModel;
|
|
}
|
|
|
|
<DxComboBox Data="@_products" TextFieldName="Name" ValueFieldName="Id" @bind-Value="userProductMappingEditModel.ProductId" ReadOnly="@(!_isNewState!.Value)"
|
|
SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch">
|
|
</DxComboBox>
|
|
</CellEditTemplate>
|
|
</DxGridDataColumn>
|
|
<DxGridDataColumn FieldName="UserId" Caption="UserId" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
|
|
@{
|
|
var userEmailFieldName = $"{nameof(UserProductMapping.User)}.{nameof(User.EmailAddress)}";
|
|
}
|
|
<DxGridDataColumn FieldName="@userEmailFieldName" Caption="User email" SortIndex="0">
|
|
<CellEditTemplate>
|
|
@{
|
|
var userProductMappingEditModel = (UserProductMapping)context.EditModel;
|
|
}
|
|
|
|
<DxComboBox Data="@_users" TextFieldName="EmailAddress" ValueFieldName="Id" @bind-Value="userProductMappingEditModel.UserId" ReadOnly="@(!_isNewState!.Value)"
|
|
SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch">
|
|
</DxComboBox>
|
|
</CellEditTemplate>
|
|
</DxGridDataColumn>
|
|
|
|
<DxGridDataColumn FieldName="Permissions" />
|
|
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
|
|
<DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
|
|
</Columns>
|
|
<DetailRowTemplate>
|
|
@{
|
|
<DxTabs>
|
|
<DxTabPage Text="Products">
|
|
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsById" ContextId="((UserProductMapping)context.DataItem).ProductId" />
|
|
</DxTabPage>
|
|
</DxTabs>
|
|
}
|
|
</DetailRowTemplate>
|
|
</UserProductMappingGrid>
|
|
|
|
@code {
|
|
[Parameter] public bool CommandColumnVisible { get; set; } = true;
|
|
[Parameter] public bool NewButtonVisible { get; set; } = true;
|
|
[Parameter] public bool EditButtonVisible { get; set; } = true;
|
|
[Parameter] public bool DeleteButtonVisible { get; set; } = true;
|
|
[Parameter] public IProductRelation ParentData { get; set; } = null!;
|
|
|
|
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings;
|
|
|
|
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
|
|
|
|
[Parameter] public Guid[]? ContextIds { get; set; }
|
|
|
|
private bool? _isNewState = null;
|
|
private LoggerClient<UserProductMappingGridComponent> _logger;
|
|
|
|
private List<User> _users = [];
|
|
private List<Product> _products = [];
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_logger = new LoggerClient<UserProductMappingGridComponent>(LogWriters.ToArray());
|
|
|
|
//_products = (await AdminSignalRClient.GetAllAsync<List<Product>>(SignalRTags.GetAllProducts)) ?? [];
|
|
|
|
AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget();
|
|
AdminSignalRClient.GetAllIntoAsync(_users, SignalRTags.GetAllUsers).Forget();
|
|
|
|
// AdminSignalRClient.GetAllAsync<List<Product>>(SignalRTags.GetAllProducts, response =>
|
|
// {
|
|
// if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
|
|
// {
|
|
// _logger.Error($"GetAllAsync<List<Car>>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}");
|
|
// return Task.CompletedTask;
|
|
// }
|
|
|
|
// _products.AddRange(response.ResponseData);
|
|
// return Task.CompletedTask;
|
|
// }).Forget();
|
|
|
|
// AdminSignalRClient.GetAllAsync<List<User>>(SignalRTags.getal, response =>
|
|
// {
|
|
// if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
|
|
// {
|
|
// _logger.Error($"GetAllAsync<List<Car>>(); status: {response.Status}; dataCount: {response.ResponseData?.Count}");
|
|
// return Task.CompletedTask;
|
|
// }
|
|
|
|
// _products.AddRange(response.ResponseData);
|
|
// return Task.CompletedTask;
|
|
// }).Forget();
|
|
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
|
{
|
|
_isNewState = e.IsNew;
|
|
if (!e.IsNew) return;
|
|
|
|
// var newProductMapping = new UserProductMapping
|
|
// {
|
|
// ProductId = Guid.NewGuid(),
|
|
// UserId = UserModelDtoDetail.Id,
|
|
// Permissions = 1
|
|
// };
|
|
|
|
//e.EditModel = newProductMapping;
|
|
}
|
|
|
|
private void OnGridEditModelSaving(GridEditModelSavingEventArgs e)
|
|
{
|
|
_isNewState = e.IsNew;
|
|
}
|
|
|
|
private void OnGridItemChanged(GridDataItemChangedEventArgs<UserProductMapping> args)
|
|
{
|
|
// if (args.TrackingState != TrackingState.Add) return;
|
|
|
|
// args.CancelStateChangeInvoke = true;
|
|
// StateHasChanged();
|
|
}
|
|
|
|
} |