Add FileSubPath to Files; improve PDF rendering logic

Added FileSubPath property to Files entity and IFiles interface for sub-path storage. Updated IFiles to include FileHash and IsCompressed. Refactored GridShippingDocumentInfoPanel.razor to select and render PDFs only when associated files exist, with improved type checks and null handling. Performed minor code cleanup.
This commit is contained in:
Loretta 2026-01-24 10:19:36 +01:00
parent d918ffaae4
commit 328f906a30
3 changed files with 22 additions and 8 deletions

View File

@ -9,6 +9,7 @@ namespace FruitBank.Common.Entities;
public class Files : MgEntityBase, IFiles
{
public string FileName { get; set; }
public string FileSubPath { get; set; }
public string FileExtension { get; set; }
public string RawText { get; set; }
public string FileHash { get; set; }

View File

@ -6,6 +6,9 @@ namespace FruitBank.Common.Interfaces;
public interface IFiles: IEntityInt, ITimeStampInfo
{
public string FileName { get; set; }
public string FileSubPath { get; set; }
public string FileExtension { get; set; }
public string RawText { get; set; }
public string FileHash { get; set; }
public bool IsCompressed { get; set; }
}

View File

@ -94,7 +94,7 @@
{
private readonly string[] _pdfFiles =
[
"1_Albaran_AH25007715.pdf",
"1_Albaran_AH25007715.pdf",
"2_BANK FRA.pdf",
"3_BP-30M35_20251113_163816.pdf"
];
@ -110,16 +110,26 @@
private async Task OnDataItemChangedAsync(object? dataItem)
{
@if (dataItem is not ShippingDocument && dataItem is not ShippingItem) return;
if (dataItem is not ShippingDocument && dataItem is not ShippingItem) return;
// Store the PDF to render
_randomPdf = _pdfFiles[Random.Shared.Next(_pdfFiles.Length)];
_currentPdfToRender = $"_content/FruitBankHybrid.Shared/uploads/{_randomPdf}";
ShippingDocument? shippingDocument = null;
// If MgLazyLoadContent is already visible, render the PDF immediately
if (_lazyContentRef is { IsVisible: true })
if (dataItem is ShippingItem shippingItem) shippingDocument = shippingItem.ShippingDocument;
else shippingDocument = dataItem as ShippingDocument;
if (shippingDocument == null) return;
if (shippingDocument.ShippingDocumentToFiles?.Count > 0)
{
await _lazyContentRef.TriggerContentVisibleAsync();
// 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();
}
}
}