Extracted some pages to their own assembly and finished the artifact display page code

This commit is contained in:
Vincent Allen
2025-10-08 13:08:12 -04:00
parent fd0e6290fe
commit 02c2660b09
626 changed files with 39989 additions and 1553 deletions

View File

@@ -0,0 +1,25 @@
namespace OpenArchival.Blazor;
public class ArtifactGroupingRowElement
{
public required int Id { get; set; }
public required string ArtifactGroupingIdentifier { get; set; }
public required string CategoryName { get; set; }
public required string Title { get; set; }
public bool IsPublicallyVisible { get; set; }
public bool Equals(ArtifactGroupingRowElement? other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return Id == other.Id; // Compare based on the unique Id
}
public override bool Equals(object? obj) => Equals(obj as ArtifactGroupingRowElement);
public override int GetHashCode() => Id.GetHashCode();
}

View File

@@ -0,0 +1,74 @@
namespace OpenArchival.Blazor;
using Microsoft.IdentityModel.Abstractions;
using Microsoft.IdentityModel.Tokens;
using OpenArchival.DataAccess;
using System.ComponentModel.DataAnnotations;
public class CategoryValidationModel
{
public int? DatabaseId { get; set; }
[Required(ErrorMessage = "Category name is required.")]
public string? Name { get; set; }
public string? Description { get; set; }
[Required(ErrorMessage = "Field separator is required.")]
[StringLength(1, ErrorMessage = "Separator must be a single character.")]
public string FieldSeparator { get; set; } = "-";
[Required(ErrorMessage = "At least one field is needed")]
[Range(1, int.MaxValue, ErrorMessage = "At least one field must be created.")]
public int NumFields { get; set; } = 1;
public List<string> FieldNames { get; set; } = [""];
public List<string> FieldDescriptions { get; set; } = [""];
public IEnumerable<ValidationResult> Validate(ValidationContext context)
{
if ((FieldNames is null || FieldNames.Count == 0) || (FieldDescriptions is null || FieldDescriptions.Count > 0))
{
yield return new ValidationResult(
"Either the FieldNames or FieldDescriptions were null or empty. At least one is required",
new[] { nameof(FieldNames), nameof(FieldDescriptions) }
);
}
}
public static CategoryValidationModel FromArchiveCategory(ArchiveCategory category)
{
return new CategoryValidationModel()
{
Name = category.Name,
Description = category.Description,
DatabaseId = category.Id,
FieldSeparator = category.FieldSeparator,
FieldNames = category.FieldNames,
FieldDescriptions = category.FieldDescriptions,
};
}
public static ArchiveCategory ToArchiveCategory(CategoryValidationModel model)
{
return new ArchiveCategory()
{
Name = model.Name,
FieldSeparator = model.FieldSeparator,
Description = model.Description,
FieldNames = model.FieldNames,
FieldDescriptions = model.FieldDescriptions
};
}
public static void UpdateArchiveValidationModel(CategoryValidationModel model, ArchiveCategory category)
{
category.Name = model.Name ?? throw new ArgumentNullException(nameof(model.Name), "The model name was null.");
category.Description = model.Description;
category.FieldSeparator = model.FieldSeparator;
category.FieldNames = model.FieldNames;
category.FieldDescriptions = model.FieldDescriptions;
}
}