ba#&#@#@#ába commit

This commit is contained in:
Adam 2024-07-05 11:20:14 +02:00
parent e3c4239c87
commit 5a52545071
8 changed files with 161 additions and 95 deletions

View File

@ -20,8 +20,8 @@
<PageTitle>User permissions</PageTitle>
<div class="text-center m-5">
<h1>Drivers</h1>
<h2 style="font-size:small">Manage drivers here!</h2>
<h1>My companies</h1>
<h2 style="font-size:small">Manage your companies here!</h2>
</div>

View File

@ -108,7 +108,7 @@
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="UserId" ColSpanLg="6" ColSpanMd="12">
<DxFormLayoutItem Caption="UserId" ColSpanLg="12" ColSpanMd="12">
@transfer2.UserId
@{
var a = UserEditFormContext.GetEditor("UserId");
@ -117,7 +117,7 @@
<DxButton Click="@(async (MouseEventArgs e) => await ShowPopup((UserProductMapping)UserEditFormContext.EditModel))" Context="ButtonContext">Select user</DxButton>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Permissions" ColSpanMd="4">
<DxFormLayoutItem Caption="Permissions" ColSpanLg="12">
@UserEditFormContext.GetEditor("Permissions")
</DxFormLayoutItem>

View File

@ -46,7 +46,7 @@
</div>
@code {
private LoggerClient<ManageUserProductMappings> _logger;
private LoggerClient<ManageTransferDestinationToProducts> _logger;
//public UserModelDtoDetail UserModelDtoDetail = new();
@ -135,7 +135,7 @@
protected override void OnInitialized()
{
_logger = new LoggerClient<ManageUserProductMappings>(LogWriters.ToArray());
_logger = new LoggerClient<ManageTransferDestinationToProducts>(LogWriters.ToArray());
base.OnInitialized();
}

View File

@ -48,7 +48,7 @@
<DetailRowTemplate>
<DxTabs>
<DxTabPage Text="Prices">
<TransferDestinationToProductDetailGridComponent GetAllTag="SignalRTags.GetTransferDestinationToProductsByProductId" ContextIds="new [] {((Product)context.DataItem).Id}" />
<TransferDestinationToProductDetailGridComponent IsProductIdReadonly="true" GetAllTag="SignalRTags.GetTransferDestinationToProductsByProductId" ContextIds="new [] {((Product)context.DataItem).Id}" />
</DxTabPage>
<DxTabPage Text="Permissions">
<UserProductMappingGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Never" ContextIds="new[] { ((Product)context.DataItem).Id }" GetAllTag="SignalRTags.GetUserProductMappingsByProductId">
@ -76,8 +76,6 @@
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductDescription) ColSpanMd="4">
@editFormContext.GetEditor("Description")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>

View File

@ -55,7 +55,7 @@
<DetailRowTemplate>
<DxTabs>
<DxTabPage Text="Prices">
<TransferDestinationToProductDetailGridComponent GetAllTag="SignalRTags.GetTransferDestinationToProductsByTransferDestinationId" ContextIds="new [] {((TransferDestination)context.DataItem).Id}" />
<TransferDestinationToProductDetailGridComponent IsDestinationIdReadonly="true" GetAllTag="SignalRTags.GetTransferDestinationToProductsByTransferDestinationId" ContextIds="new [] {((TransferDestination)context.DataItem).Id}" />
</DxTabPage>
</DxTabs>
</DetailRowTemplate>

View File

@ -1,4 +1,5 @@
@using TIAM.Entities.Products
@using AyCode.Core.Helpers
@using TIAM.Entities.Products
@using TIAM.Entities.ServiceProviders
@using TIAM.Entities.Transfers
@using TIAM.Entities.Drivers
@ -18,19 +19,42 @@
<TransferDestinationToProductDetailGrid Logger="_logger"
SignalRClient="AdminSignalRClient"
CustomizeEditModel="CustomizeEditModel"
OnGridEditModelSaving="OnGridEditModelSaving"
EditCanceling="EditCanceling"
ContextIds="ContextIds?.Cast<object>().ToArray()"
GetAllMessageTag="GetAllTag"
PageSize="10"
ValidationEnabled="false"
EditMode="GridEditMode.EditForm"
EditMode="GridEditMode.EditRow"
DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode"
ColumnResizeMode="GridColumnResizeMode.NextColumn">
<Columns>
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="ProductId" />
<DxGridDataColumn FieldName="TransferDestinationId" />
<DxGridDataColumn FieldName="ProductId" Caption="ServiceId">
<CellEditTemplate>
@{
var TransferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel;
}
<DxComboBox Data="@_products" TextFieldName="Name" ValueFieldName="Id" @bind-Value="TransferDestinationToProductEditModel.ProductId" ReadOnly="@ProductIdReadOnly"
SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch">
</DxComboBox>
</CellEditTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="TransferDestinationId">
<CellEditTemplate>
@{
var TransferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel;
}
<DxComboBox Data="@_transferDestinations" TextFieldName="Name" ValueFieldName="Id" @bind-Value="TransferDestinationToProductEditModel.TransferDestinationId" ReadOnly="@DestinationIdReadOnly"
SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch">
</DxComboBox>
</CellEditTemplate>
</DxGridDataColumn>
@*<DxGridDataColumn FieldName="TransferDestinationId" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
@{
var destinationNameFieldName = $"{nameof(TransferDestinationToProduct.TransferDestination.Name)}.{nameof(TransferDestination.Name)}";
@ -54,29 +78,29 @@
</DetailRowTemplate>
<EditFormTemplate Context="editFormContext">
@{
var transferDestinationToProduct = (TransferDestinationToProduct)editFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="Price" ColSpanMd="4">
@editFormContext.GetEditor("Price")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Price2" ColSpanMd="4">
@editFormContext.GetEditor("Price2")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Price3" ColSpanMd="4">
@editFormContext.GetEditor("Price3")
</DxFormLayoutItem>
@* <EditFormTemplate Context="editFormContext">
@{
var transferDestinationToProduct = (TransferDestinationToProduct)editFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="Price" ColSpanMd="4">
@editFormContext.GetEditor("Price")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Price2" ColSpanMd="4">
@editFormContext.GetEditor("Price2")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Price3" ColSpanMd="4">
@editFormContext.GetEditor("Price3")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Commission rate" ColSpanMd="4">
@editFormContext.GetEditor("ProductCommis")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Commission rate" ColSpanMd="4">
@editFormContext.GetEditor("ProductCommis")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</DxFormLayout>
</EditFormTemplate> *@
</TransferDestinationToProductDetailGrid>
@ -84,13 +108,64 @@
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
[Parameter] public Guid[]? ContextIds { get; set; } = null!;
[Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllTransferDestinationToProducts;
[Parameter] public bool IsProductIdReadonly { get; set; } = false;
[Parameter] public bool IsDestinationIdReadonly { get; set; } = false;
private bool ProductIdReadOnly = false;
private bool DestinationIdReadOnly = false;
//private bool? _isNewState = null;
private List<TransferDestination> _transferDestinations = [];
private List<Product> _products = [];
private LoggerClient<TransferDestinationToProductGridComponent> _logger = null!;
protected override void OnInitialized()
{
_logger = new LoggerClient<TransferDestinationToProductGridComponent>(LogWriters.ToArray());
AdminSignalRClient.GetAllIntoAsync(_transferDestinations, SignalRTags.GetAllTransferDestinations).Forget();
AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget();
base.OnInitialized();
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (!e.IsNew)
{
DestinationIdReadOnly = true;
ProductIdReadOnly = true;
}
else
{
if(IsDestinationIdReadonly)
{
((TransferDestinationToProduct)(e.EditModel)).TransferDestinationId = (Guid)ContextIds[0];
}
DestinationIdReadOnly = IsDestinationIdReadonly;
if (IsProductIdReadonly)
{
((TransferDestinationToProduct)(e.EditModel)).ProductId = (Guid)ContextIds[0];
}
ProductIdReadOnly = IsProductIdReadonly;
}
if (!e.IsNew) return;
}
private void OnGridEditModelSaving(GridEditModelSavingEventArgs e)
{
DestinationIdReadOnly = false;
ProductIdReadOnly = false;
}
private void EditCanceling(GridEditCancelingEventArgs e)
{
DestinationIdReadOnly = false;
ProductIdReadOnly = false;
}
}

View File

@ -1,4 +1,5 @@
@using TIAM.Entities.Products
@using AyCode.Core.Helpers
@using TIAM.Entities.Products
@using TIAM.Entities.ServiceProviders
@using TIAM.Entities.Transfers
@using TIAM.Entities.Drivers
@ -19,16 +20,38 @@
<TransferDestinationToProductGrid Logger="_logger"
SignalRClient="AdminSignalRClient"
CustomizeEditModel="CustomizeEditModel"
OnGridEditModelSaving="OnGridEditModelSaving"
Context="TransferDestinationToProductContext"
PageSize="10"
ValidationEnabled="false"
EditMode="GridEditMode.EditForm"
EditMode="GridEditMode.EditRow"
ColumnResizeMode="GridColumnResizeMode.NextColumn">
<Columns>
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="ProductId" />
<DxGridDataColumn FieldName="TransferDestinationId" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="ProductId" Caption="Service id">
<CellEditTemplate>
@{
var TransferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel;
}
<DxComboBox Data="@_products" TextFieldName="Name" ValueFieldName="Id" @bind-Value="TransferDestinationToProductEditModel.ProductId" ReadOnly="@(!_isNewState!.Value)"
SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch">
</DxComboBox>
</CellEditTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="TransferDestinationId">
<CellEditTemplate>
@{
var TransferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel;
}
<DxComboBox Data="@_transferDestinations" TextFieldName="Name" ValueFieldName="Id" @bind-Value="TransferDestinationToProductEditModel.TransferDestinationId" ReadOnly="@(!_isNewState!.Value)"
SearchFilterCondition="ListSearchFilterCondition.Contains" SearchMode="ListSearchMode.AutoSearch">
</DxComboBox>
</CellEditTemplate>
</DxGridDataColumn>
@*<DxGridDataColumn FieldName="TransferDestinationId" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
@{
var destinationNameFieldName = $"{nameof(TransferDestinationToProduct.TransferDestination.Name)}.{nameof(TransferDestination.Name)}";
@ -48,7 +71,7 @@
</DxTabPage>
</DxTabs>
</DetailRowTemplate>
<EditFormTemplate Context="editFormContext">
@* <EditFormTemplate Context="editFormContext">
@{
var transferDestinationToProduct = (TransferDestinationToProduct)editFormContext.EditModel;
}
@ -63,38 +86,13 @@
@editFormContext.GetEditor("Price3")
</DxFormLayoutItem>
<DxFormLayoutItem Context="FormLayoutContext" Caption="TransferDestination" ColSpanMd="4">
@{
var contextId = ((TransferDestinationToProduct)editFormContext.EditModel).Id;
TransferDestinationToProduct thisItem = (TransferDestinationToProduct)editFormContext.EditModel;
if (Value != null)
{
thisItem.TransferDestinationId = ((TransferDestination)Value).Id;
}
}
<DxDropDownBox @bind-Value="Value"
QueryDisplayText="QueryText"
DropDownWidthMode="DropDownWidthMode.ContentWidth"
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto"
NullText="Select a destination..."
InputId="ddbSearchLookup"
CssClass="cw-480">
<DropDownBodyTemplate>
<TransferDestinationGrid Logger="_logger"
SignalRClient="AdminSignalRClient"
GetAllMessageTag="@SignalRTags.GetAllTransferDestinations"
ShowSearchBox="true"
SelectedDataItem="@Value"
SelectedDataItemChanged="item => GridSelectedDataItemChanged(item, context.DropDownBox)"/>
</DropDownBodyTemplate>
</DxDropDownBox>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Commission rate" ColSpanMd="4">
@editFormContext.GetEditor("ProductCommis")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</EditFormTemplate> *@
</TransferDestinationToProductGrid>
@ -102,41 +100,30 @@
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private LoggerClient<TransferDestinationToProductGridComponent> _logger = null!;
private bool? _isNewState = null;
private List<TransferDestination> _transferDestinations = [];
private List<Product> _products = [];
object Value { get; set; }
string QueryText(DropDownBoxQueryDisplayTextContext arg)
{
if (arg.Value is TransferDestination value)
return value.Id.ToString();
return string.Empty;
}
void GridSelectedDataItemChanged(object item, IDropDownBox dropDownBox)
{
Value = item as TransferDestination;
dropDownBox.HideDropDown();
}
protected override void OnInitialized()
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<TransferDestinationToProductGridComponent>(LogWriters.ToArray());
base.OnInitialized();
AdminSignalRClient.GetAllIntoAsync(_transferDestinations, SignalRTags.GetAllTransferDestinations).Forget();
AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget();
await base.OnInitializedAsync();
}
// void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
// {
// if (!e.IsNew) return;
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 = false;
}
// async Task EditModelSaving(GridEditModelSavingEventArgs e)
// {

View File

@ -28,6 +28,7 @@
PageSize="10"
ValidationEnabled="false"
CustomizeEditModel="CustomizeEditModel"
EditCanceling="EditCanceling"
EditMode="GridEditMode.EditRow"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
OnGridEditModelSaving="OnGridEditModelSaving"
@ -175,4 +176,9 @@
_isNewState = false;
}
private void EditCanceling(GridEditCancelingEventArgs e)
{
_isNewState = false;
}
}