This commit is contained in:
Loretta 2024-06-26 17:26:58 +02:00
commit 20f81dd3a4
12 changed files with 432 additions and 66 deletions

View File

@ -70,6 +70,7 @@ namespace TIAM.Database.DataLayers.Admins
#endregion Transfer
#region TransferDestination
public List<TransferDestination>? GetTransferDestinations() => Session(ctx=>ctx.GetTransferDestinations().ToList());
public TransferDestination? GetTransferDestinationById(Guid transferDestinationId) => Session(ctx=>ctx.GetTransferDestinationById(transferDestinationId));
public Task<TransferDestination?> GetTransferDestinationByIdAsync(Guid transferDestinationId) => SessionAsync(ctx=>ctx.GetTransferDestinationById(transferDestinationId));
public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)?.ToJson());

View File

@ -1,6 +1,7 @@
@page "/user/destinations"
@page "/sysadmin/destinations"
@using BlazorAnimation
@using TIAM.Resources
@using TIAM.Services
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using AyCode.Services.Loggers
@ -27,66 +28,7 @@
IconCssClass="btn-column-chooser"
Click="ColumnChooserButton_Click" />
</div>
<DxGrid @ref="Grid"
Data="_transferDestinationWizardModels"
PageSize="8"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeElement="Grid_CustomizeElement"
CustomizeEditModel="Grid_CustomizeEditModel"
EditModelSaving="Grid_EditModelSaving"
DataItemDeleting="Grid_DataItemDeleting"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.ColumnsContainer"
KeyboardNavigationEnabled="true"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" MinWidth="80" Width="20%" Visible="false" />
<DxGridDataColumn FieldName="Name" FixedPosition="GridColumnFixedPosition.Left" MinWidth="80" Width="20%">
<CellDisplayTemplate>
@{
var keyField = context.Value;
<a class="d-block text-left" href="transferdetails">@context.Value</a>
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="Description" FixedPosition="GridColumnFixedPosition.Left" MinWidth="80" Width="20%" />
<DxGridDataColumn FieldName="AddressString" MinWidth="80" Width="20%" />
<DxGridDataColumn FieldName="PriceType" MinWidth="80" Width="20%" />
<DxGridDataColumn FieldName="Price" MinWidth="80" />
<DxGridDataColumn FieldName="Price2" MinWidth="80" />
<DxGridDataColumn FieldName="Price3" MinWidth="80" />
</Columns>
<EditFormTemplate Context="EditFormContext">
@{
var transfer = (TransferDestinationWizardModel)EditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationName) ColSpanMd="6">
@EditFormContext.GetEditor("Name")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Destination) ColSpanMd="6">
@EditFormContext.GetEditor("Description")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationAddress) ColSpanMd="6">
@EditFormContext.GetEditor("AddressString")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Price) ColSpanMd="6">
@EditFormContext.GetEditor("PriceType")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Price) ColSpanMd="6">
@EditFormContext.GetEditor("Price")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</DxGrid>
<TransferDestinationGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetAllTransferDestinations"></TransferDestinationGridComponent>
</div>

View File

@ -2,6 +2,7 @@
@using BlazorAnimation
@using TIAM.Models.Dtos.Users
@using TIAM.Resources
@using TIAM.Services
@using TIAMSharedUI.Pages.Components
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Interfaces
@ -108,7 +109,7 @@
<ServiceProviderGridComponent ContextId="((UserModelDtoDetail)context.DataItem).Id" />
</DxTabPage>
<DxTabPage Text="Roles in services">
<UserProductMappingGridComponent UserModelDtoDetail="(UserModelDtoDetail)context.DataItem" KeyboardNavigationEnabled="true" />
<UserProductMappingGridComponent GetAllTag="SignalRTags.GetUserProductMappingsByUserId" ContextIds="new [] {((UserModelDtoDetail)context.DataItem).Id}" KeyboardNavigationEnabled="true" />
</DxTabPage>
</DxTabs>

View File

@ -49,6 +49,9 @@
</Columns>
<DetailRowTemplate>
<DxTabs>
<DxTabPage Text="Prices">
<TransferDestinationToProductDetailGridComponent GetAllTag="SignalRTags.GetTransferDestinationToProductByProductId" ContextIds="new [] {((Product)context.DataItem).Id}" KeyboardNavigationEnabled="true" />
</DxTabPage>
<DxTabPage Text="Permissions">
<UserProductMappingGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Never" ContextIds="new[] { ((Product)context.DataItem).Id }" GetAllTag="SignalRTags.GetUserProductMappingsByProductId">
</UserProductMappingGridComponent>

View File

@ -0,0 +1,127 @@
@using TIAM.Entities.Transfers
@using TIAM.Entities.Drivers
@using TIAM.Models.Dtos.Users
@using TIAM.Resources
@using TIAMSharedUI.Shared.Components.Grids
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Utility
@using TIAM.Core.Loggers
@using AyCode.Core.Loggers
@using AyCode.Services.Loggers
@using TIAMWebApp.Shared.Application.Services
@using AyCode.Core.Enums
@using AyCode.Core.Extensions
@using AyCode.Core
@inject IUserDataService UserDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient;
@inject IStringLocalizer<TIAMResources> localizer
<TransferDestinationGrid @ref="_transferToDriversGrid"
Logger="_logger"
SignalRClient="AdminSignalRClient"
PageSize="8"
GetAllMessageTag="GetAllTag"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeEditModel="CustomizeEditModel"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.ColumnsContainer"
KeyboardNavigationEnabled="true"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" MinWidth="80" Width="20%" Visible="false" />
<DxGridDataColumn FieldName="Name" FixedPosition="GridColumnFixedPosition.Left" MinWidth="80" Width="20%">
<CellDisplayTemplate>
@{
var keyField = context.Value;
<a class="d-block text-left" href="transferdetails">@context.Value</a>
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="Name" FixedPosition="GridColumnFixedPosition.Left" MinWidth="80" Width="20%" />
<DxGridDataColumn FieldName="Description" MinWidth="80" Width="20%" />
<DxGridDataColumn FieldName="AddressString" MinWidth="80" Width="20%" />
<DxGridDataColumn FieldName="Price" MinWidth="80" />
<DxGridDataColumn FieldName="Price2" MinWidth="80" />
<DxGridDataColumn FieldName="Price3" MinWidth="80" />
<DxGridDataColumn FieldName="ProductCommis" MinWidth="80" />
<DxGridDataColumn FieldName="ExtraPrice" MinWidth="80" />
</Columns>
<EditFormTemplate Context="EditFormContext">
@{
var transfer = (TransferDestination)EditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationName) ColSpanMd="6">
@EditFormContext.GetEditor("Name")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Destination) ColSpanMd="6">
@EditFormContext.GetEditor("Description")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationAddress) ColSpanMd="6">
@EditFormContext.GetEditor("AddressString")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Price) ColSpanMd="6">
@EditFormContext.GetEditor("Price")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Price) ColSpanMd="6">
@EditFormContext.GetEditor("Price2")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Price) ColSpanMd="6">
@EditFormContext.GetEditor("Price3")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Price) ColSpanMd="6">
@EditFormContext.GetEditor("ProductCommis")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Price) ColSpanMd="6">
@EditFormContext.GetEditor("ExtraPrice")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</TransferDestinationGrid>
@code {
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public Guid? ContextId { get; set; }
[Parameter] public int GetAllTag { get; set; }
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private TransferDestinationGrid _transferToDriversGrid = null!;
private LoggerClient<TransferDestinationGridComponent> _logger = null!;
protected override void OnInitialized()
{
_logger = new LoggerClient<TransferDestinationGridComponent>(LogWriters.ToArray());
}
private void DataItemChanged(GridDataItemChangedEventArgs<TransferToDriver> args)
{
}
private void DataItemSaving(GridEditModelSavingEventArgs obj)
{
_logger.Debug($"DataItemSaving");
}
private void DataItemDeleting(GridDataItemDeletingEventArgs obj)
{
_logger.Debug($"DataItemDeleting");
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (!e.IsNew) return;
}
}

View File

@ -0,0 +1,146 @@
@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.Services
@using TIAMWebApp.Shared.Application.Utility
@using AyCode.Services.Loggers
@using TIAM.Core.Loggers
@using AyCode.Core
@using TIAMSharedUI.Shared.Components.Grids
@inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient;
<TransferDestinationToProductDetailGrid
Logger="_logger"
SignalRClient="AdminSignalRClient"
ContextIds="ContextIds"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
<DxGridDataColumn FieldName="ProductId" />
<DxGridDataColumn FieldName="TransferDestinationId"/>
<DxGridDataColumn FieldName="Price" />
<DxGridDataColumn FieldName="Price2" />
<DxGridDataColumn FieldName="Price3" />
<DxGridDataColumn FieldName="ProductCommis" />
</Columns>
<DetailRowTemplate>
<DxTabs>
<DxTabPage Text="Partner">
</DxTabPage>
</DxTabs>
</DetailRowTemplate>
<EditFormTemplate Context="EditFormContext">
@{
var serviceProvider = (Company)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>
</DxFormLayout>
</EditFormTemplate>
</TransferDestinationToProductDetailGrid>
@code {
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
[Parameter] public Guid? ContextId { get; set; }
[Parameter] public Guid[]? ContextIds { get; set; } = new Guid[0];
[Parameter] public int GetAllTag { get; set; }
private LoggerClient<TransferDestinationToProductGridComponent> _logger = null!;
protected override async Task OnInitializedAsync()
{
_logger = new LoggerClient<TransferDestinationToProductGridComponent>(LogWriters.ToArray());
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
//_detailGridData = UserModelDtoDetail.ServiceProviders ?? [];
//_availableServices = await ServiceProviderDataService.GetServiceProvidersAsync();
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
}
protected override void OnParametersSet()
{
if(ContextId.HasValue)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId!;
}
base.OnParametersSet();
}
// 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");
// }
}

View File

@ -68,9 +68,10 @@
@code {
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
[Parameter] public Guid? ContextId { get; set; }
private Guid[] ContextIds = new Guid[0];
private LoggerClient<TransferDestinationToProductGridComponent> _logger = null!;
protected override void OnInitialized()
@ -79,4 +80,54 @@
base.OnInitialized();
}
protected override void OnParametersSet()
{
if(ContextId.HasValue)
{
ContextIds = new Guid[1];
ContextIds[0] = (Guid)ContextId!;
}
base.OnParametersSet();
}
// 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");
// }
}

View File

@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Components;
using TIAM.Entities.Profiles;
using TIAM.Services;
namespace TIAMSharedUI.Shared.Components.Grids;
public class TransferDestinationDetailGrid : TransferDestinationGrid
{
public TransferDestinationDetailGrid() : base()
{
GetAllMessageTag = SignalRTags.GetAllTransferDestinations;
AddMessageTag = SignalRTags.CreateTransferDestination;
UpdateMessageTag = SignalRTags.UpdateTransferDestination;
RemoveMessageTag = SignalRTags.RemoveTransferDestination;
}
protected override Task SetParametersAsyncCore(ParameterView parameters)
{
if (!IsFirstInitializeParameters)
{
//ShowFilterRow = true;
//ShowGroupPanel = true;
//AllowSort = false;
//etc...
}
return base.SetParametersAsyncCore(parameters);
}
}

View File

@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Components;
using TIAM.Entities.Profiles;
using TIAM.Entities.Transfers;
using TIAM.Services;
namespace TIAMSharedUI.Shared.Components.Grids;
public class TransferDestinationGrid : TiamGrid<TransferDestination>
{
public TransferDestinationGrid() : base()
{
GetAllMessageTag = SignalRTags.GetAllTransferDestinations;
AddMessageTag = SignalRTags.CreateTransferDestination;
UpdateMessageTag = SignalRTags.UpdateTransferDestination;
RemoveMessageTag = SignalRTags.RemoveTransferDestination;
}
protected override Task SetParametersAsyncCore(ParameterView parameters)
{
if (!IsFirstInitializeParameters)
{
//ShowFilterRow = true;
//ShowGroupPanel = true;
//AllowSort = false;
//etc...
}
return base.SetParametersAsyncCore(parameters);
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Components;
using TIAM.Entities.Products;
using TIAM.Entities.Transfers;
using TIAM.Services;
namespace TIAMSharedUI.Shared.Components.Grids;
public class TransferDestinationToProductDetailGrid : TransferDestinationToProductGrid
{
public TransferDestinationToProductDetailGrid() : base()
{
GetAllMessageTag = SignalRTags.GetAllTransferDestinationToProducts;
AddMessageTag = SignalRTags.CreateTransferDestinationToProduct;
UpdateMessageTag = SignalRTags.UpdateTransferDestinationToProduct;
RemoveMessageTag = SignalRTags.RemoveTransferDestinationToProduct;
}
protected override Task SetParametersAsyncCore(ParameterView parameters)
{
if (!IsFirstInitializeParameters)
{
//ShowFilterRow = true;
//ShowGroupPanel = true;
//AllowSort = false;
//etc...
}
return base.SetParametersAsyncCore(parameters);
}
}

View File

@ -17,6 +17,7 @@
<Items>
<DxMenuItem NavigateUrl="user/sysadmin" Text="Dashboard" />
<DxMenuItem NavigateUrl="sysadmin/transfers" Text="Transfers" />
<DxMenuItem NavigateUrl="sysadmin/destinations" Text="Destinations" />
<DxMenuItem NavigateUrl="sysadmin/companies" Text="Companies" />
<DxMenuItem NavigateUrl="sysadmin/prices" Text="Partner prices" />
<DxMenuItem NavigateUrl="sysadmin/products" Text="Services" />
@ -25,7 +26,6 @@
<DxMenuItem NavigateUrl="sysadmin/userproductmappings" Text="Permissions" />
<DxMenuItem NavigateUrl="sysadmin/users" Text="Users" />
<DxMenuItem NavigateUrl="user/destinations" Text="Destinations" />
</Items>
</DxMenuItem>
<DxMenuItem Text="HotelAdmin" IconCssClass="menu-icon-support menu-icon">

View File

@ -20,6 +20,7 @@ using TIAMWebApp.Server.Services;
using TIAMWebApp.Shared.Application.Models.ClientSide;
using AyCode.Core.Extensions;
using TIAM.Entities.Users;
using TIAMSharedUI.Shared.Components.Grids;
namespace TIAMWebApp.Server.Controllers
{
@ -48,9 +49,10 @@ namespace TIAMWebApp.Server.Controllers
[AllowAnonymous]
[HttpGet]
[Route(APIUrls.GetTransferDestinationsRouteName)]
public async Task<IEnumerable<TransferDestination>> GetTransferDestinations()
[SignalR(SignalRTags.GetAllTransferDestinations)]
public List<TransferDestination> GetTransferDestinations()
{
return await _adminDal.Context.TransferDestinations.ToListAsync();
return _adminDal.GetTransferDestinations();
}
//[Authorize]