Fixed bug where deletes of artifact groupings would not cascade
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
@page
|
||||
@model OpenArchival.Blazor.ArtifactGroupingDisplay.MyFeature.Pages.Page1Model
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>Page1</title>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace OpenArchival.Blazor.ArtifactGroupingDisplay.MyFeature.Pages
|
||||
{
|
||||
public class Page1Model : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,20 +6,22 @@
|
||||
|
||||
@page "/sr/{StringId}"
|
||||
|
||||
<MudCard Style="@($"cursor: pointer; height: {Height}px; display: flex; flex-direction: column;")" onclick="@NavigateToArchive" >
|
||||
@if (_displayImageId >= 0)
|
||||
{
|
||||
<MudCardMedia Image="@($"/api/files/{_displayImageId}")" Height="150" />
|
||||
}
|
||||
|
||||
<MudCardContent Style="flex-grow: 1; overflow-y: clip;">
|
||||
@if (ArtifactGrouping is not null)
|
||||
<MudLink Href="@($"/archive/{Id}")" Target="_blank" Style="text-decoration: none; color: inherit;">
|
||||
<MudCard Style="@($"cursor: pointer; height: {Height}px; display: flex; flex-direction: column;")">
|
||||
@if (_displayImageId >= 0)
|
||||
{
|
||||
<MudText Typo="Typo.h5">@ArtifactGrouping.Title</MudText>
|
||||
<MudText Typo="Typo.body2">@ArtifactGrouping.Description</MudText>
|
||||
<MudCardMedia Image="@($"/api/files/{_displayImageId}")" Height="150" />
|
||||
}
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
|
||||
<MudCardContent Style="flex-grow: 1; overflow-y: clip;">
|
||||
@if (ArtifactGrouping is not null)
|
||||
{
|
||||
<MudText Typo="Typo.h5">@ArtifactGrouping.Title</MudText>
|
||||
<MudText Typo="Typo.body2">@ArtifactGrouping.Description</MudText>
|
||||
}
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
</MudLink>
|
||||
@inject IArtifactGroupingProvider GroupingProvider;
|
||||
@inject NavigationManager NavigationManager;
|
||||
@code {
|
||||
@@ -71,18 +73,9 @@
|
||||
{
|
||||
_displayImageId = ArtifactGrouping.ChildArtifactEntries[0].Files[0].Id;
|
||||
}
|
||||
Id = ArtifactGrouping.Id;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task NavigateToArchive()
|
||||
{
|
||||
await Task.Delay(4);
|
||||
if (ArtifactGrouping is not null)
|
||||
{
|
||||
NavigationManager.NavigateTo($"/archive/{ArtifactGrouping.Id}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
@namespace OpenArchival.Blazor.ArtifactGroupingDisplay
|
||||
<h3>FileDisplayBase</h3>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
@using OpenArchival.DataAccess
|
||||
@using MudBlazor
|
||||
|
||||
@if (File is not null)
|
||||
{
|
||||
<MudImage Fluid="true" Src="@File.Path" Alt="Swedish Farm House" Class="rounded-lg"/>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public required FilePathListing File { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the width of the image box while it loads
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public int Width { get; set; } = 600;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the height of the image box while it loads
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public int Height { get; set; } = 400;
|
||||
|
||||
[Parameter]
|
||||
public string AltText { get; set; } = "";
|
||||
|
||||
protected override Task OnParametersSetAsync()
|
||||
{
|
||||
if (File is not null || !string.IsNullOrEmpty(AltText))
|
||||
{
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
return base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using OpenArchival.Blazor.ArtifactGroupingDisplay;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace OpenArchival.Blazor;
|
||||
|
||||
public class FileDisplayComponentFactory
|
||||
{
|
||||
private Dictionary<string, Type> _extensionToComponents { get; set; } = [];
|
||||
|
||||
public FileDisplayComponentFactory()
|
||||
{
|
||||
// Supported image file types taken from https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types
|
||||
RegisterComponent<FileDisplayImage>(".apng");
|
||||
RegisterComponent<FileDisplayImage>(".png");
|
||||
RegisterComponent<FileDisplayImage>(".avif");
|
||||
RegisterComponent<FileDisplayImage>(".gif");
|
||||
RegisterComponent<FileDisplayImage>(".jpg");
|
||||
RegisterComponent<FileDisplayImage>(".jpeg");
|
||||
RegisterComponent<FileDisplayImage>(".jfif");
|
||||
RegisterComponent<FileDisplayImage>(".pjpeg");
|
||||
RegisterComponent<FileDisplayImage>(".pjg");
|
||||
RegisterComponent<FileDisplayImage>(".png");
|
||||
RegisterComponent<FileDisplayImage>(".svg");
|
||||
RegisterComponent<FileDisplayImage>(".webp");
|
||||
}
|
||||
|
||||
private string GetExtensionKey(string pathOrExtension)
|
||||
{
|
||||
return Path.GetExtension(pathOrExtension).ToUpperInvariant();
|
||||
}
|
||||
|
||||
public bool RegisterComponent<ComponentType>(string filenameOrExtension) where ComponentType : IFileDisplayComponent
|
||||
{
|
||||
string extensionString = GetExtensionKey(filenameOrExtension);
|
||||
|
||||
_extensionToComponents.Add(extensionString, typeof(ComponentType));
|
||||
return true;
|
||||
}
|
||||
|
||||
public Type? GetDisplayComponentType(string filenameOrExtension) {
|
||||
var result = _extensionToComponents.TryGetValue(GetExtensionKey(filenameOrExtension), out var component);
|
||||
|
||||
return (result) ? component : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
@using OpenArchival.DataAccess
|
||||
|
||||
@implements IFileDisplayComponent
|
||||
|
||||
<h3>FileDisplayImage</h3>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public required FilePathListing FilePath { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using OpenArchival.DataAccess;
|
||||
|
||||
namespace OpenArchival.Blazor;
|
||||
|
||||
public interface IFileDisplayComponent
|
||||
{
|
||||
public FilePathListing FilePath { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user