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 class Files : MgEntityBase, IFiles
{ {
public string FileName { get; set; } public string FileName { get; set; }
public string FileSubPath { get; set; }
public string FileExtension { get; set; } public string FileExtension { get; set; }
public string RawText { get; set; } public string RawText { get; set; }
public string FileHash { get; set; } public string FileHash { get; set; }

View File

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

View File

@ -110,8 +110,17 @@
private async Task OnDataItemChangedAsync(object? dataItem) 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;
ShippingDocument? shippingDocument = null;
if (dataItem is ShippingItem shippingItem) shippingDocument = shippingItem.ShippingDocument;
else shippingDocument = dataItem as ShippingDocument;
if (shippingDocument == null) return;
if (shippingDocument.ShippingDocumentToFiles?.Count > 0)
{
// Store the PDF to render // Store the PDF to render
_randomPdf = _pdfFiles[Random.Shared.Next(_pdfFiles.Length)]; _randomPdf = _pdfFiles[Random.Shared.Next(_pdfFiles.Length)];
_currentPdfToRender = $"_content/FruitBankHybrid.Shared/uploads/{_randomPdf}"; _currentPdfToRender = $"_content/FruitBankHybrid.Shared/uploads/{_randomPdf}";
@ -122,6 +131,7 @@
await _lazyContentRef.TriggerContentVisibleAsync(); await _lazyContentRef.TriggerContentVisibleAsync();
} }
} }
}
private async Task OnPdfContainerVisibleAsync() private async Task OnPdfContainerVisibleAsync()
{ {