improvements, fixes
This commit is contained in:
parent
2253f0f534
commit
b6248d68f3
|
|
@ -0,0 +1,8 @@
|
|||
using Mango.Nop.Core.Dtos;
|
||||
|
||||
namespace FruitBank.Common.Dtos;
|
||||
|
||||
public class GenericAttributeDto : MgGenericAttributeDto
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -22,12 +22,12 @@ namespace FruitBank.Common.Dtos;
|
|||
public class OrderDto : MgOrderDto<OrderItemDto, ProductDto>, IOrderDto
|
||||
{
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
private static Expression<Func<OrderDto, GenericAttribute, bool>> RelationWithGenericAttribute => (orderDto, genericAttribute) =>
|
||||
orderDto.Id == genericAttribute.EntityId && genericAttribute.KeyGroup == nameof(Order);
|
||||
private static Expression<Func<OrderDto, GenericAttributeDto, bool>> RelationWithGenericAttribute => (orderDto, genericAttributeDto) =>
|
||||
orderDto.Id == genericAttributeDto.EntityId && genericAttributeDto.KeyGroup == nameof(Order);
|
||||
|
||||
|
||||
[Association(ThisKey = nameof(Id), OtherKey = nameof(GenericAttribute.EntityId), ExpressionPredicate = nameof(RelationWithGenericAttribute), CanBeNull = true)]
|
||||
public List<GenericAttribute> GenericAttributes { get; set; }
|
||||
public List<GenericAttributeDto> GenericAttributes { get; set; }
|
||||
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
public bool IsMeasured
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ namespace FruitBank.Common.Dtos;
|
|||
public class OrderItemDto : MgOrderItemDto<ProductDto>, IOrderItemDto
|
||||
{
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
private static Expression<Func<OrderItemDto, GenericAttribute, bool>> RelationWithGenericAttribute => (orderItemDto, genericAttribute) =>
|
||||
orderItemDto.Id == genericAttribute.EntityId && genericAttribute.KeyGroup == nameof(OrderItem);
|
||||
private static Expression<Func<OrderItemDto, GenericAttributeDto, bool>> RelationWithGenericAttribute => (orderItemDto, genericAttributeDto) =>
|
||||
orderItemDto.Id == genericAttributeDto.EntityId && genericAttributeDto.KeyGroup == nameof(OrderItem);
|
||||
|
||||
|
||||
[Association(ThisKey = nameof(Id), OtherKey = nameof(GenericAttribute.EntityId), ExpressionPredicate = nameof(RelationWithGenericAttribute), CanBeNull = true)]
|
||||
public List<GenericAttribute> GenericAttributes { get; set; }
|
||||
public List<GenericAttributeDto> GenericAttributes { get; set; }
|
||||
|
||||
[Association(ThisKey = nameof(Id), OtherKey = nameof(OrderItemPallet.OrderItemId), CanBeNull = true)]
|
||||
public List<OrderItemPallet> OrderItemPallets { get; set; }
|
||||
|
|
|
|||
|
|
@ -6,18 +6,19 @@ using Newtonsoft.Json;
|
|||
//using Nop.Core.Domain.Catalog;
|
||||
using Nop.Core.Domain.Common;
|
||||
using System.Linq.Expressions;
|
||||
using Mango.Nop.Core.Interfaces.ForeignKeys;
|
||||
|
||||
namespace FruitBank.Common.Dtos;
|
||||
|
||||
public class ProductDto : MgProductDto, IProductDto
|
||||
{
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
private static Expression<Func<ProductDto, GenericAttribute, bool>> RelationWithGenericAttribute => (orderItemDto, genericAttribute) =>
|
||||
orderItemDto.Id == genericAttribute.EntityId && genericAttribute.KeyGroup == "Product";// nameof(Product);
|
||||
private static Expression<Func<ProductDto, GenericAttributeDto, bool>> RelationWithGenericAttribute => (orderItemDto, genericAttributeDto) =>
|
||||
orderItemDto.Id == genericAttributeDto.EntityId && genericAttributeDto.KeyGroup == "Product";// nameof(Product);
|
||||
|
||||
|
||||
[Association(ThisKey = nameof(Id), OtherKey = nameof(GenericAttribute.EntityId), ExpressionPredicate = nameof(RelationWithGenericAttribute), CanBeNull = false)]
|
||||
public List<GenericAttribute> GenericAttributes { get; set; }
|
||||
[Association(ThisKey = nameof(Id), OtherKey = nameof(GenericAttributeDto.EntityId), ExpressionPredicate = nameof(RelationWithGenericAttribute), CanBeNull = false)]
|
||||
public List<GenericAttributeDto> GenericAttributes { get; set; }
|
||||
|
||||
public ProductDto() :base()
|
||||
{ }
|
||||
|
|
@ -52,7 +53,6 @@ public class ProductDto : MgProductDto, IProductDto
|
|||
public double NetWeight
|
||||
{
|
||||
get => GenericAttributes.GetValueOrDefault<double>(nameof(IMeasuringNetWeight.NetWeight));
|
||||
//get => CommonHelper.To<double>(GenericAttributes.SingleOrDefault(x => x.Key == nameof(IMeasuringNetWeight.NetWeight))?.Value ?? "0");
|
||||
set => throw new Exception($"ProductDto.NetWeight not set");
|
||||
}
|
||||
|
||||
|
|
@ -60,8 +60,14 @@ public class ProductDto : MgProductDto, IProductDto
|
|||
public int IncomingQuantity
|
||||
{
|
||||
get => GenericAttributes.GetValueOrDefault<int>(nameof(IIncomingQuantity.IncomingQuantity));
|
||||
//get => CommonHelper.To<int>(GenericAttributes.SingleOrDefault(x => x.Key == nameof(IIncomingQuantity.IncomingQuantity))?.Value ?? "0");
|
||||
set => throw new Exception($"ProductDto.IncomingQuantity not set");
|
||||
//set
|
||||
//{
|
||||
// var ga = GenericAttributes.FirstOrDefault(ga => ga.Key == nameof(IIncomingQuantity.IncomingQuantity)) ??
|
||||
// GenericAttributes.AddNewGenericAttribute("Product", nameof(IIncomingQuantity.IncomingQuantity), value.ToString(), Id);
|
||||
|
||||
// ga.Value = value.ToString();
|
||||
//}
|
||||
}
|
||||
|
||||
[NotColumn, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ public static class FruitBankConstClient
|
|||
{
|
||||
public static string DefaultLocale = "en-US";
|
||||
|
||||
public static string BaseUrl = "https://localhost:59579"; //FrutiBank nop
|
||||
|
||||
//public static string BaseUrl = "https://localhost:59579"; //FrutiBank nop
|
||||
public static string BaseUrl = "https://shop.fruitbank.hu"; //FrutiBank nop
|
||||
#if RELEASE
|
||||
//public static string BaseUrl = "https://shop.fruitbank.hu"; //FrutiBank nop
|
||||
#endif
|
||||
|
|
@ -22,7 +22,7 @@ public static class FruitBankConstClient
|
|||
public static string LoggerHubName = "loggerHub";
|
||||
|
||||
public static long SignalRKeepAliveIntervalSecond = 60;
|
||||
public static long SignarlRTimeoutIntervalSecond = 120;
|
||||
public static long SignarlRTimeoutIntervalSecond = 180;
|
||||
|
||||
public const string PalletDbTableName = "fbPallet";
|
||||
public const string FilesDbTableName = "fbFiles";
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
using FruitBank.Common.Enums;
|
||||
using Mango.Nop.Core.Dtos;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Mango.Nop.Core.Interfaces.ForeignKeys;
|
||||
|
||||
namespace FruitBank.Common.Interfaces;
|
||||
|
||||
public interface IOrderDto : IMgOrderDto<OrderItemDto, ProductDto>, IMeasured, IMeasurable, IMeasurableStatus
|
||||
public interface IOrderDto : IMgOrderDto<OrderItemDto, ProductDto>, IMeasured, IMeasurable, IMeasurableStatus, IGenericAttributeForeignCollection<List<GenericAttributeDto>>
|
||||
{
|
||||
DateTime? DateOfReceipt { get; }
|
||||
DateTime DateOfReceiptOrCreated { get; }
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@ using FruitBank.Common.Entities;
|
|||
using FruitBank.Common.Enums;
|
||||
using Mango.Nop.Core.Dtos;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Mango.Nop.Core.Interfaces.ForeignKeys;
|
||||
//using Nop.Core.Domain.Catalog;
|
||||
|
||||
namespace FruitBank.Common.Interfaces;
|
||||
|
||||
public interface IOrderItemDto : IMgOrderItemDto<ProductDto>, IMeasuringValues, IMeasured, IMeasurable, IMeasurableStatus
|
||||
public interface IOrderItemDto : IMgOrderItemDto<ProductDto>, IMeasuringValues, IMeasured, IMeasurable, IMeasurableStatus, IGenericAttributeForeignCollection<List<GenericAttributeDto>>
|
||||
{
|
||||
OrderDto OrderDto { get; set; }
|
||||
List<OrderItemPallet> OrderItemPallets { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
using Mango.Nop.Core.Interfaces;
|
||||
using FruitBank.Common.Dtos;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Mango.Nop.Core.Interfaces.ForeignKeys;
|
||||
|
||||
namespace FruitBank.Common.Interfaces;
|
||||
|
||||
public interface IProductDto : IMgProductDto, ITare, IIncomingQuantity, IAvailableQuantity, IMeasuringAttributeValues
|
||||
public interface IProductDto : IMgProductDto, ITare, IIncomingQuantity, IAvailableQuantity, IMeasuringAttributeValues, IGenericAttributeForeignCollection<List<GenericAttributeDto>>
|
||||
{
|
||||
public double AverageWeight { get; }
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,15 @@ public class SignalRTags : AcSignalRTags
|
|||
|
||||
public const int GetStockQuantityHistoryDtos = 150;
|
||||
public const int GetStockQuantityHistoryDtosByProductId = 151;
|
||||
|
||||
|
||||
public const int GetGenericAttributeDtos = 160;
|
||||
/// <summary>
|
||||
/// Params: int EntityId, string KeyGroup, int StoreId
|
||||
/// </summary>
|
||||
public const int GetGenericAttributeDtosByEntityIdAndKeyGroup = 161;
|
||||
public const int AddGenericAttributeDto = 168;
|
||||
public const int UpdateGenericAttributeDto = 169;
|
||||
|
||||
public const int AuthenticateUser = 195;
|
||||
public const int RefreshToken = 200;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
@using AyCode.Utils.Extensions
|
||||
@using AyCode.Core.Helpers
|
||||
@using AyCode.Utils.Extensions
|
||||
@using FruitBank.Common.Dtos
|
||||
@using FruitBank.Common.Models
|
||||
@using FruitBankHybrid.Shared.Components.Grids.GenericAttributes
|
||||
@using FruitBankHybrid.Shared.Components.Toolbars
|
||||
@using FruitBankHybrid.Shared.Databases
|
||||
@using FruitBankHybrid.Shared.Services.SignalRs
|
||||
|
|
@ -54,6 +56,13 @@
|
|||
// <GridDetailOrderItemPallets OrderItemPallets="orderItemPalletDtos" IsMasterGrid="false" />
|
||||
}
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Speciális jellemzők">
|
||||
@{
|
||||
var genericAttributeDtos = new AcObservableCollection<GenericAttributeDto>(orderDto.GenericAttributes);
|
||||
<GridGenericAttribute ParentDataItem="@orderDto" GenericAttributes="@genericAttributeDtos" />
|
||||
}
|
||||
</DxTabPage>
|
||||
|
||||
</DxTabs>
|
||||
}
|
||||
</DetailRowTemplate>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
@using AyCode.Utils.Extensions
|
||||
@using FruitBank.Common.Dtos
|
||||
@using FruitBank.Common.Models
|
||||
@using FruitBankHybrid.Shared.Components.Grids.GenericAttributes
|
||||
@using FruitBankHybrid.Shared.Components.Toolbars
|
||||
@using FruitBankHybrid.Shared.Databases
|
||||
@using FruitBankHybrid.Shared.Services.SignalRs
|
||||
|
|
@ -36,11 +37,11 @@
|
|||
|
||||
<DxGridDataColumn FieldName="Quantity" />
|
||||
<DxGridDataColumn FieldName="NetWeight" />
|
||||
|
||||
|
||||
<DxGridDataColumn FieldName="IsMeasurable" ReadOnly="true" />
|
||||
<DxGridDataColumn FieldName="MeasuringStatus" ReadOnly="true" />
|
||||
@* <DxGridDataColumn FieldName="IsMeasured" ReadOnly="true" /> *@
|
||||
|
||||
|
||||
<DxGridDataColumn FieldName="UnitPriceInclTax" Caption="Egységár (br.)" />
|
||||
<DxGridDataColumn FieldName="PriceInclTax" Caption="Végösszeg (br.)" />
|
||||
|
||||
|
|
@ -54,13 +55,26 @@
|
|||
<DetailRowTemplate>
|
||||
@if (IsMasterGrid && LoggedInModel.IsDeveloper)
|
||||
{
|
||||
<GridDetailOrderItemPallets OrderItemPallets="((OrderItemDto)context.DataItem).OrderItemPallets" />
|
||||
var orderItemDto = ((OrderItemDto)context.DataItem);
|
||||
<DxTabs>
|
||||
<DxTabPage Text="Mérések">
|
||||
@{
|
||||
<GridDetailOrderItemPallets OrderItemPallets="orderItemDto.OrderItemPallets" />
|
||||
}
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Speciális jellemzők">
|
||||
@{
|
||||
var genericAttributeDtos = new AcObservableCollection<GenericAttributeDto>(orderItemDto.GenericAttributes);
|
||||
<GridGenericAttribute ParentDataItem="@orderItemDto" GenericAttributes="@genericAttributeDtos" />
|
||||
}
|
||||
</DxTabPage>
|
||||
</DxTabs>
|
||||
}
|
||||
</DetailRowTemplate>
|
||||
<ToolbarTemplate>
|
||||
@if (IsMasterGrid)
|
||||
{
|
||||
<FruitBankToolbarTemplate Grid="Grid" OnReloadDataClick="() => ReloadDataFromDb(true)"/>
|
||||
<FruitBankToolbarTemplate Grid="Grid" OnReloadDataClick="() => ReloadDataFromDb(true)" />
|
||||
}
|
||||
</ToolbarTemplate>
|
||||
<GroupSummary>
|
||||
|
|
@ -96,7 +110,7 @@
|
|||
private async Task ReloadDataFromDb(bool forceReload = false)
|
||||
{
|
||||
LoadingPanelVisibility.Visible = true;
|
||||
|
||||
|
||||
using (await ObjectLock.GetSemaphore<ProductDto>().UseWaitAsync())
|
||||
{
|
||||
if (ProductDtos == null || !ProductDtos.Any() || forceReload) ProductDtos = await Database.ProductDtoTable.LoadDataAsync(!forceReload);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
@using DevExpress.Internal.About
|
||||
@using FruitBank.Common.Dtos
|
||||
@using FruitBank.Common.Models
|
||||
@using FruitBankHybrid.Shared.Components.Grids.GenericAttributes
|
||||
@using FruitBankHybrid.Shared.Components.Grids.Products
|
||||
@using FruitBankHybrid.Shared.Components.Toolbars
|
||||
@using FruitBankHybrid.Shared.Databases
|
||||
|
|
@ -31,7 +32,9 @@
|
|||
<DetailRowTemplate>
|
||||
@if (IsMasterGrid)
|
||||
{
|
||||
var productId = ((ProductDto)context.DataItem).Id;
|
||||
var productDto = ((ProductDto)(context.DataItem));
|
||||
var productId = productDto.Id;
|
||||
|
||||
|
||||
<DxTabs ActiveTabIndexChanged="(i) => OnActiveTabChanged(i, productId)">
|
||||
<DxTabPage Text="Rendelések melyben megtalálható" Visible="@LoggedInModel.IsDeveloper">
|
||||
|
|
@ -53,8 +56,14 @@
|
|||
//GetOrderItemDtosFromDbAsync(productId).Forget();
|
||||
//var orderItemDtos = _orderItemDtos?.Where(oi => oi.ProductId == productId).ToList() ?? [];
|
||||
|
||||
var contextIds = new[] { (object)((ProductDto)(context.DataItem)).Id };
|
||||
<GridStockQuantityHistoryDtoTemplate ContextIds="@(contextIds)" ParentDataItem="@((ProductDto)(context.DataItem))" />
|
||||
var contextIds = new[] { (object)productDto.Id };
|
||||
<GridStockQuantityHistoryDtoTemplate ContextIds="@(contextIds)" ParentDataItem="@productDto" />
|
||||
}
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Speciális jellemzők">
|
||||
@{
|
||||
var genericAttributeDtos = new AcObservableCollection<GenericAttributeDto>(productDto.GenericAttributes);
|
||||
<GridGenericAttribute ParentDataItem="@productDto" GenericAttributes="@genericAttributeDtos" />
|
||||
}
|
||||
</DxTabPage>
|
||||
</DxTabs>
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject FruitBankSignalRClient FruitBankSignalRClient
|
||||
|
||||
<GridShippingItemBase @ref="Grid" ParentDataItem="ParentDataItem" KeyFieldNameToParentId="@nameof(ShippingItem.ShippingDocumentId)"
|
||||
DataSource="ShippingItems" AutoSaveLayoutName="GridShippingItem" SignalRClient="FruitBankSignalRClient" Logger="_logger"
|
||||
<GridShippingItemBase @ref="Grid" ParentDataItem="ParentDataItem" DataSource="ShippingItems" AutoSaveLayoutName="GridShippingItem"
|
||||
SignalRClient="FruitBankSignalRClient" Logger="_logger"
|
||||
CssClass="@GridCss" ValidationEnabled="false"
|
||||
FocusedRowChanged="Grid_FocusedRowChanged">
|
||||
<Columns>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
@using System.Collections.ObjectModel
|
||||
@using AyCode.Core.Helpers
|
||||
@using AyCode.Core.Interfaces
|
||||
@using AyCode.Core.Loggers
|
||||
@using AyCode.Utils.Extensions
|
||||
@using FruitBank.Common.Dtos
|
||||
@using FruitBank.Common.Entities
|
||||
@using FruitBankHybrid.Shared.Components.Grids.Shippings
|
||||
@using FruitBankHybrid.Shared.Components.Toolbars
|
||||
@using FruitBankHybrid.Shared.Databases
|
||||
@using FruitBankHybrid.Shared.Services.Loggers
|
||||
@using FruitBankHybrid.Shared.Services.SignalRs
|
||||
@using Nop.Core.Domain.Common
|
||||
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject FruitBankSignalRClient FruitBankSignalRClient
|
||||
|
||||
<GridGenericAttributeBase @ref="Grid" DataSource="GenericAttributes" AutoSaveLayoutName="GridGenericAttribute" SignalRClient="FruitBankSignalRClient" Logger="_logger"
|
||||
ParentDataItem="@ParentDataItem" CssClass="@GridCss" ValidationEnabled="false" FocusedRowChanged="Grid_FocusedRowChanged">
|
||||
<Columns>
|
||||
<DxGridDataColumn FieldName="@nameof(GenericAttribute.Id)" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" ReadOnly="true" />
|
||||
|
||||
<DxGridDataColumn FieldName="@nameof(GenericAttribute.KeyGroup)" ReadOnly="true" />
|
||||
<DxGridDataColumn FieldName="@nameof(GenericAttribute.Key)" />
|
||||
<DxGridDataColumn FieldName="@nameof(GenericAttribute.Value)" />
|
||||
<DxGridDataColumn FieldName="@nameof(GenericAttribute.EntityId)" ReadOnly="true" />
|
||||
<DxGridDataColumn FieldName="@nameof(GenericAttribute.StoreId)" ReadOnly="true" />
|
||||
<DxGridDataColumn FieldName="@nameof(GenericAttribute.CreatedOrUpdatedDateUTC)" ReadOnly="true" />
|
||||
|
||||
<DxGridCommandColumn Visible="!IsMasterGrid" Width="120"></DxGridCommandColumn>
|
||||
</Columns>
|
||||
<ToolbarTemplate>
|
||||
@if (IsMasterGrid)
|
||||
{
|
||||
<FruitBankToolbarTemplate Grid="Grid" OnReloadDataClick="() => ReloadDataFromDb(true)" />
|
||||
}
|
||||
</ToolbarTemplate>
|
||||
</GridGenericAttributeBase>
|
||||
|
||||
@code {
|
||||
[Inject] public required DatabaseClient Database { get; set; }
|
||||
|
||||
[Parameter] public AcObservableCollection<GenericAttributeDto>? GenericAttributes{ get; set; }
|
||||
|
||||
//[Parameter] public object[]? ContextIds { get; set; }
|
||||
[Parameter] public IId<int>? ParentDataItem { get; set; }
|
||||
public bool IsMasterGrid => ParentDataItem == null;
|
||||
|
||||
const string ExportFileName = "ExportResult";
|
||||
string GridSearchText = "";
|
||||
bool EditItemsEnabled { get; set; }
|
||||
int FocusedRowVisibleIndex { get; set; }
|
||||
|
||||
public GridGenericAttributeBase Grid { get; set; }
|
||||
string GridCss => !IsMasterGrid ? "hide-toolbar" : string.Empty;
|
||||
|
||||
private LoggerClient<GridGenericAttribute> _logger;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_logger = new LoggerClient<GridGenericAttribute>(LogWriters.ToArray());
|
||||
await ReloadDataFromDb(false);
|
||||
}
|
||||
|
||||
private async Task ReloadDataFromDb(bool forceReload = false)
|
||||
{
|
||||
if (!IsMasterGrid) return;
|
||||
|
||||
if (forceReload) Grid?.Reload();
|
||||
}
|
||||
|
||||
async Task Grid_FocusedRowChanged(GridFocusedRowChangedEventArgs args)
|
||||
{
|
||||
if (Grid == null) return;
|
||||
|
||||
if (Grid.IsEditing() && !Grid.IsEditingNewRow())
|
||||
await Grid.SaveChangesAsync();
|
||||
|
||||
FocusedRowVisibleIndex = args.VisibleIndex;
|
||||
EditItemsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
using AyCode.Core.Interfaces;
|
||||
using AyCode.Utils.Extensions;
|
||||
using DevExpress.Blazor;
|
||||
using FruitBank.Common.Dtos;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.SignalRs;
|
||||
using FruitBankHybrid.Shared.Pages;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Nop.Core.Domain.Common;
|
||||
using Nop.Core.Domain.Orders;
|
||||
|
||||
namespace FruitBankHybrid.Shared.Components.Grids.GenericAttributes;
|
||||
|
||||
public class GridGenericAttributeBase: FruitBankGridBase<GenericAttributeDto>, IGrid
|
||||
{
|
||||
protected const int ContextEntityIdIndex = 0;
|
||||
protected const int ContextKeyGroupIndex = 1;
|
||||
protected const int ContextStoreIdIndex = 2;
|
||||
|
||||
private bool _isFirstInitializeParameterCore;
|
||||
private bool _isFirstInitializeParameters;
|
||||
|
||||
public GridGenericAttributeBase() : base()
|
||||
{
|
||||
AddMessageTag = SignalRTags.AddGenericAttributeDto;
|
||||
UpdateMessageTag = SignalRTags.UpdateGenericAttributeDto;
|
||||
|
||||
//RemoveMessageTag = SignalRTags.;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (GetAllMessageTag > 0) return;
|
||||
|
||||
if (IsMasterGrid) GetAllMessageTag = SignalRTags.GetGenericAttributeDtos;
|
||||
else
|
||||
{
|
||||
var hasContextIdParameter = ContextIds is { Length: > 0 };
|
||||
|
||||
if (!hasContextIdParameter)
|
||||
{
|
||||
ContextIds = new object[3];
|
||||
ContextIds[ContextEntityIdIndex] = ParentDataItem!.Id;
|
||||
ContextIds[ContextStoreIdIndex] = LoggedInModel.CustomerDto!.RegisteredInStoreId;
|
||||
}
|
||||
|
||||
GetAllMessageTag = SignalRTags.GetGenericAttributeDtosByEntityIdAndKeyGroup;
|
||||
if (KeyFieldNameToParentId.IsNullOrWhiteSpace()) KeyFieldNameToParentId = nameof(GenericAttribute.EntityId);
|
||||
|
||||
switch (ParentDataItem)
|
||||
{
|
||||
case IProductDto:
|
||||
if (!hasContextIdParameter) ContextIds![ContextKeyGroupIndex] = "Product";
|
||||
|
||||
break;
|
||||
case IOrderDto:
|
||||
if (!hasContextIdParameter) ContextIds![ContextKeyGroupIndex] = nameof(Order);
|
||||
|
||||
break;
|
||||
case IOrderItemDto:
|
||||
if (!hasContextIdParameter) ContextIds![ContextKeyGroupIndex] = nameof(OrderItem);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected override async Task OnCustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||
{
|
||||
if (e.IsNew && ParentDataItem != null && ContextIds != null)
|
||||
{
|
||||
var editModel = (e.EditModel as GenericAttributeDto)!;
|
||||
|
||||
editModel.KeyGroup = (string)ContextIds![ContextKeyGroupIndex];
|
||||
editModel.StoreId = (int)ContextIds![ContextStoreIdIndex];
|
||||
editModel.CreatedOrUpdatedDateUTC = DateTime.UtcNow;
|
||||
|
||||
e.EditModel = editModel;
|
||||
}
|
||||
|
||||
await base.OnCustomizeEditModel(e);
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
base.OnParametersSet();
|
||||
|
||||
if (!_isFirstInitializeParameters)
|
||||
{
|
||||
//if (!IsMasterGrid && (ContextIds == null || ContextIds.Length == 0))
|
||||
//{
|
||||
// ContextIds = [ParentDataItem!.Id];
|
||||
// GetAllMessageTag = SignalRTags.GetShippingItemsByDocumentId;
|
||||
//}
|
||||
|
||||
_isFirstInitializeParameters = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task SetParametersAsyncCore(ParameterView parameters)
|
||||
{
|
||||
await base.SetParametersAsyncCore(parameters);
|
||||
|
||||
if (!_isFirstInitializeParameterCore)
|
||||
{
|
||||
//if (!IsMasterGrid && (ContextIds == null || ContextIds.Length == 0))
|
||||
//{
|
||||
// ContextIds = [ParentDataItem!.Id];
|
||||
// GetAllMessageTag = SignalRTags.GetShippingItemsByDocumentId;
|
||||
//}
|
||||
|
||||
//ShowFilterRow = true;
|
||||
//ShowGroupPanel = true;
|
||||
//AllowSort = false;
|
||||
|
||||
//etc...
|
||||
|
||||
_isFirstInitializeParameterCore = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ using FruitBank.Common.SignalRs;
|
|||
using FruitBankHybrid.Shared.Pages;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace FruitBankHybrid.Shared.Components.Grids.OrderItem;
|
||||
namespace FruitBankHybrid.Shared.Components.Grids.OrderItems;
|
||||
|
||||
//public class GridOrderItem : FruitBankGrid<OrderItem>
|
||||
//{
|
||||
|
|
|
|||
|
|
@ -79,11 +79,11 @@
|
|||
string GridCss => !IsMasterGrid ? "hide-toolbar" : string.Empty;
|
||||
|
||||
private int _activeTabIndex;
|
||||
private LoggerClient<GridPartnerBase> _logger;
|
||||
private LoggerClient<GridPartner> _logger;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_logger = new LoggerClient<GridPartnerBase>(LogWriters.ToArray());
|
||||
_logger = new LoggerClient<GridPartner>(LogWriters.ToArray());
|
||||
await ReloadDataFromDb(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,19 +35,19 @@ public class GridShippingItemBase : FruitBankGridBase<ShippingItem>, IGrid
|
|||
{
|
||||
case IShippingDocument:
|
||||
GetAllMessageTag = SignalRTags.GetShippingItemsByDocumentId;
|
||||
if (KeyFieldNameToParentId.IsNullOrWhiteSpace()) KeyFieldNameToParentId = nameof(ShippingItem.ShippingDocumentId);
|
||||
|
||||
break;
|
||||
case IShipping:
|
||||
AddMessageTag = 0;//SignalRTags.None;
|
||||
GetAllMessageTag = SignalRTags.GetShippingItemsByShippingId;
|
||||
|
||||
|
||||
break;
|
||||
case IPartner:
|
||||
AddMessageTag = 0;//SignalRTags.None;
|
||||
GetAllMessageTag = SignalRTags.GetShippingItemsByPartnerId;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using FruitBankHybrid.Shared.Services.SignalRs;
|
|||
using FruitBankHybrid.Web.Client.Services;
|
||||
using FruitBankHybrid.Web.Client.Services.Loggers;
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue