From 7f4052faa26ed6f58a7de53ad3b28a6cf0222887 Mon Sep 17 00:00:00 2001 From: Loretta Date: Thu, 18 Dec 2025 11:02:53 +0100 Subject: [PATCH] Refactor: decouple InfoPanel using MgGridWithInfoPanel Major refactor to decouple InfoPanel logic from grid base. Introduces MgGridWithInfoPanel wrapper component to manage grid and InfoPanel layout and communication. InfoPanels are now customizable via Razor templates with named slots (header, footer, etc.), and grid-to-InfoPanel communication is routed through the wrapper. Removes legacy C#-only InfoPanel base classes and parameters from grid base. This improves flexibility, composability, and maintainability of grid+InfoPanel UIs. --- .../Components/GridShippingDocument.razor | 238 ++++++++---------- .../GridShippingDocumentBase.cs | 3 - .../GridShippingDocumentInfoPanel.cs | 41 --- .../GridShippingDocumentInfoPanel.razor | 28 +++ 4 files changed, 132 insertions(+), 178 deletions(-) delete mode 100644 FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.cs create mode 100644 FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.razor diff --git a/FruitBankHybrid.Shared/Components/GridShippingDocument.razor b/FruitBankHybrid.Shared/Components/GridShippingDocument.razor index 3740237..b415e9f 100644 --- a/FruitBankHybrid.Shared/Components/GridShippingDocument.razor +++ b/FruitBankHybrid.Shared/Components/GridShippingDocument.razor @@ -16,127 +16,116 @@ @inject IEnumerable LogWriters @inject FruitBankSignalRClient FruitBankSignalRClient - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - @if (IsMasterGrid) - { - var shippingDocument = ((ShippingDocument)context.DataItem); + + + + + + + + + + @if (IsMasterGrid) + { + var shippingDocument = ((ShippingDocument)context.DataItem); - - - @{ - var observableShippingItem = new AcObservableCollection(shippingDocument?.ShippingItems ?? []); - - } - - - @{ - var shippingItemPallets = shippingDocument?.ShippingItems?.SelectMany(oi => oi.ShippingItemPallets ?? []).ToList() ?? []; - - } - + + + @{ + var observableShippingItem = new AcObservableCollection(shippingDocument?.ShippingItems ?? []); + + } + + + @{ + var shippingItemPallets = shippingDocument?.ShippingItems?.SelectMany(oi => oi.ShippingItemPallets ?? []).ToList() ?? []; + + } + - - } - - - @if (IsMasterGrid) - { - - - - - - @* - - *@ - - - } - - - - - - - + + } + + + @if (IsMasterGrid) + { + + + + + + + + } + + + + + + + + + + + + @code { - //EditRow dblClick - //https://supportcenter.devexpress.com/ticket/details/t1097648/datagrid-for-blazor-how-to-start-editing-a-row-and-save-changes-without-the-command-column - - //[Inject] public required ObjectLock ObjectLock { get; set; } [Inject] public required DatabaseClient Database { get; set; } [Inject] public required LoggedInModel LoggedInModel { get; set; } @@ -152,7 +141,6 @@ public bool ParentDataItemIsPartner => (ParentDataItem is Partner); string GridCss => !IsMasterGrid ? "hide-toolbar" : string.Empty; - const string ExportFileName = "ExportResult"; string _localStorageKey = "GridShippingDocument_"; @@ -229,7 +217,6 @@ if (OnUploadedFileParsed != null) await OnUploadedFileParsed(result); - //await InvokeAsync(StateHasChanged); } async Task Grid_FocusedRowChanged(GridFocusedRowChangedEventArgs args) @@ -244,22 +231,5 @@ protected async Task OnActiveTabChanged(int activeTabIndex) { _activeTabIndex = activeTabIndex; - return; - - // switch (_activeTabIndex) - // { - // case 0: - // if(ProductDtos == null) - // ProductDtos = (await FruitBankSignalRClient.GetProductDtos() ?? []); //.Where(o => o.HasMeasuringAccess(LoggedInModel.CustomerDto?.Id, LoggedInModel.IsRevisor)).OrderBy(o => o.DateOfReceipt).ToList(); - // break; - // case 1: - // if(OrderDtos == null) - // OrderDtos = (await FruitBankSignalRClient.GetAllOrderDtos() ?? []).OrderByDescending(o => o.Id).ToList(); //.Where(o => o.HasMeasuringAccess(LoggedInModel.CustomerDto?.Id, LoggedInModel.IsRevisor)).OrderBy(o => o.DateOfReceipt).ToList(); - // break; - // case 2: - // if (OrderItemDtos == null) - // OrderItemDtos = (await FruitBankSignalRClient.GetAllOrderItemDtos() ?? []).OrderByDescending(o => o.Id).ToList(); //.Where(o => o.HasMeasuringAccess(LoggedInModel.CustomerDto?.Id, LoggedInModel.IsRevisor)).OrderBy(o => o.DateOfReceipt).ToList(); - // break; - // } } } \ No newline at end of file diff --git a/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentBase.cs b/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentBase.cs index 15ea6e8..e84e019 100644 --- a/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentBase.cs +++ b/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentBase.cs @@ -19,9 +19,6 @@ public class GridShippingDocumentBase : FruitBankGridBase, IGr AddMessageTag = SignalRTags.AddShippingDocument; UpdateMessageTag = SignalRTags.UpdateShippingDocument; - // Set custom InfoPanel type - InfoPanelType = typeof(GridShippingDocumentInfoPanel); - //RemoveMessageTag = SignalRTags.; } diff --git a/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.cs b/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.cs deleted file mode 100644 index 310af9b..0000000 --- a/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.cs +++ /dev/null @@ -1,41 +0,0 @@ -using AyCode.Blazor.Components.Components.Grids; -using Microsoft.AspNetCore.Components; - -namespace FruitBankHybrid.Shared.Components.Grids.ShippingDocuments; - -/// -/// Custom InfoPanel for ShippingDocument grid with customized header and footer -/// -public class GridShippingDocumentInfoPanel : MgInfoPanelTemplateBase -{ - protected override RenderFragment? GetHeaderTemplate() => builder => - { - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", "p-2 border-bottom"); - builder.OpenElement(2, "h5"); - builder.AddAttribute(3, "class", "mb-0"); - builder.AddContent(4, "?? Szállítólevél részletei"); - builder.CloseElement(); - builder.CloseElement(); - }; - - protected override RenderFragment? GetFooterTemplate() => builder => - { - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", "p-2 border-top d-flex gap-2"); - - builder.OpenElement(2, "button"); - builder.AddAttribute(3, "class", "btn btn-sm btn-outline-primary"); - builder.AddContent(4, "??? Nyomtatás"); - builder.CloseElement(); - - builder.OpenElement(5, "button"); - builder.AddAttribute(6, "class", "btn btn-sm btn-outline-secondary"); - builder.AddContent(7, "?? Export"); - builder.CloseElement(); - - builder.CloseElement(); - }; - - // GetColumnsTemplate() returns null by default ? uses auto-generated columns -} diff --git a/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.razor b/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.razor new file mode 100644 index 0000000..ce829b7 --- /dev/null +++ b/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.razor @@ -0,0 +1,28 @@ +@using AyCode.Blazor.Components.Components.Grids +@using DevExpress.Blazor +@using FruitBank.Common.Entities + + + +
+ ?? + Szállítólevél részletei +
+
+ + + @if (dataItem is ShippingDocument doc) + { +
+ Partner: @doc.Partner?.Name +
+ } +
+ + +
+ + +
+
+