From 031fd9226b63e4400ed6c94885634f3997b4e380 Mon Sep 17 00:00:00 2001 From: Loretta Date: Thu, 18 Dec 2025 10:03:32 +0100 Subject: [PATCH] Add extensible InfoPanel system with custom templates Introduce a flexible InfoPanel architecture for grid components, allowing per-grid customization via a new InfoPanelType parameter. Add MgInfoPanelTemplateBase for code-based InfoPanel templates with overridable header, content, and footer sections. Support custom templates in MgGridInfoPanel via new RenderFragment parameters. Add MgGridDataColumn for InfoPanel-specific column settings. Demonstrate usage with a custom InfoPanel for ShippingDocument grid. Maintains backward compatibility with default InfoPanel behavior. --- .../GridShippingDocumentBase.cs | 3 ++ .../GridShippingDocumentInfoPanel.cs | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.cs diff --git a/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentBase.cs b/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentBase.cs index e84e019..15ea6e8 100644 --- a/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentBase.cs +++ b/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentBase.cs @@ -19,6 +19,9 @@ 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 new file mode 100644 index 0000000..310af9b --- /dev/null +++ b/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.cs @@ -0,0 +1,41 @@ +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 +}