diff --git a/FruitBankHybrid.Shared/Components/Grids/FruitBankGridBase.cs b/FruitBankHybrid.Shared/Components/Grids/FruitBankGridBase.cs index 8edae39..ea901f9 100644 --- a/FruitBankHybrid.Shared/Components/Grids/FruitBankGridBase.cs +++ b/FruitBankHybrid.Shared/Components/Grids/FruitBankGridBase.cs @@ -1,40 +1,28 @@ using AyCode.Blazor.Components.Components.Grids; -using AyCode.Core.Extensions; using AyCode.Core.Interfaces; -using AyCode.Interfaces.Entities; -using AyCode.Utils.Extensions; using DevExpress.Blazor; using FruitBank.Common.Models; using FruitBankHybrid.Shared.Services.Loggers; using FruitBankHybrid.Shared.Services.SignalRs; using Microsoft.AspNetCore.Components; -using Microsoft.JSInterop; namespace FruitBankHybrid.Shared.Components.Grids; -//var a = new GridDevExtremeDataSource(DataSource.AsQueryable().Where(x=>x.IsMeasurable)); - public class FruitBankGridBase : MgGridBase, TDataItem, int, LoggerClient> where TDataItem : class, IId { [Inject] public required LoggedInModel LoggedInModel { get; set; } - [Inject] public required IJSRuntime JSRuntime { get; set; } - - //[Parameter] public bool IsMasterGrid { get; set; } = false; - [Parameter] public string AutoSaveLayoutName { get; set; } private bool _isFirstInitializeParameterCore; private bool _isFirstInitializeParameters; public bool PreRendered { get; set; } - //public virtual Task ReloadDataFromDb(bool forceReload = false) - //{ - // throw new NotImplementedException(); - //} + /// + /// Override to provide the logged-in user's ID for layout storage + /// + protected override int GetLayoutUserId() => LoggedInModel.CustomerDto?.Id ?? 0; protected void OnCustomizeElement(GridCustomizeElementEventArgs e) { - //if (!IsMasterGrid) e.CssClass = "hideDetailButton"; - if (IsMasterGrid && e.ElementType == GridElementType.DataRow && e.VisibleIndex % 2 == 1 && !e.Grid.IsRowSelected(e.VisibleIndex) && !e.Grid.IsRowFocused(e.VisibleIndex)) { e.CssClass = " alt-item"; @@ -48,28 +36,21 @@ public class FruitBankGridBase : MgGridBase || typeof(TDataItem) is IId) KeyFieldName = "Id"; - - //base.DataItemDeleting = EventCallback.Factory.Create(this, OnItemDeleting); - //base.EditModelSaving = EventCallback.Factory.Create(this, OnItemSaving); - CustomizeElement += OnCustomizeElement; - _isFirstInitializeParameterCore = true; } } - protected override void OnParametersSet() { base.OnParametersSet(); @@ -102,14 +83,8 @@ public class FruitBankGridBase : MgGridBase : MgGridBase LoadLayoutFromLocalStorageAsync(string localStorageKey) - { - try - { - var json = await JSRuntime.InvokeAsync("localStorage.getItem", localStorageKey); - - if (!json.IsNullOrWhiteSpace()) return json.JsonTo(); - } - catch - { - // Mute exceptions for the server prerender stage - } - - return null; - } - async Task SaveLayoutToLocalStorageAsync(GridPersistentLayout layout, string localStorageKey) - { - try - { - var json = layout.ToJson(); - await JSRuntime.InvokeVoidAsync("localStorage.setItem", localStorageKey, json); - } - catch - { - // Mute exceptions for the server prerender stage - } - } -} - -//public abstract class FruitBankObservableGridBase : MgGridBase, TDataItem, int, LoggerClient> where TDataItem : class, IId -//{ } \ No newline at end of file +} \ No newline at end of file diff --git a/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.razor b/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.razor index 447bd09..7389368 100644 --- a/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.razor +++ b/FruitBankHybrid.Shared/Components/Grids/ShippingDocuments/GridShippingDocumentInfoPanel.razor @@ -1,4 +1,5 @@ @using AyCode.Blazor.Components.Components.Grids +@using AyCode.Blazor.Components.Components @using DevExpress.Blazor @using FruitBank.Common.Entities @using System.IO @@ -37,7 +38,7 @@ Név a dokumentumon Termék neve - Rakl. + Rakl. Menny. Net.súly Br.súly @@ -68,8 +69,14 @@ -
-
+ +
+
+
} @@ -90,11 +97,35 @@ "3_BP-30M35_20251113_163816.pdf" ]; + private MgLazyLoadContent? _lazyContentRef; + private string? _currentPdfToRender; + private string _randomPdf; + + protected override void OnInitialized() + { + base.OnInitialized(); + } + private async Task OnDataItemChangedAsync(object? dataItem) { - // Véletlenszerű PDF kiválasztása minden sor váltáskor - var randomPdf = _pdfFiles[Random.Shared.Next(_pdfFiles.Length)]; - var pdfUrls = new[] { $"_content/FruitBankHybrid.Shared/uploads/{randomPdf}" }; - await JS.InvokeVoidAsync("pdfViewer.renderPdfs", "pdfContainer", pdfUrls); + // Store the PDF to render + _randomPdf = _pdfFiles[Random.Shared.Next(_pdfFiles.Length)]; + _currentPdfToRender = $"_content/FruitBankHybrid.Shared/uploads/{_randomPdf}"; + + // If MgLazyLoadContent is already visible, render the PDF immediately + if (_lazyContentRef is { IsVisible: true }) + { + await _lazyContentRef.TriggerContentVisibleAsync(); + } + } + + private async Task OnPdfContainerVisibleAsync() + { + // Render PDF when container becomes visible OR when data changes + if (!string.IsNullOrEmpty(_currentPdfToRender)) + { + var pdfUrls = new[] { _currentPdfToRender }; + await JS.InvokeVoidAsync("pdfViewer.renderPdfs", "pdfContainer", pdfUrls); + } } } diff --git a/FruitBankHybrid.Web/Components/App.razor b/FruitBankHybrid.Web/Components/App.razor index 36d54e7..354fe3a 100644 --- a/FruitBankHybrid.Web/Components/App.razor +++ b/FruitBankHybrid.Web/Components/App.razor @@ -26,6 +26,7 @@ + +