Extracted some pages to their own assembly and finished the artifact display page code
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
if (result is not null && !result.Canceled)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
@using OpenArchival.Blazor.Components.Pages.Administration.Categories
|
||||
@using OpenArchival.DataAccess;
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using MudBlazor
|
||||
|
||||
@inject IDialogService DialogService
|
||||
@inject NavigationManager NavigationManager;
|
||||
@@ -193,6 +194,9 @@
|
||||
{
|
||||
// The data entry should only be shown if a category has been selected
|
||||
_isFormDivVisible = true;
|
||||
} else
|
||||
{
|
||||
_isFormDivVisible = false;
|
||||
}
|
||||
|
||||
if (Model is not null)
|
||||
@@ -223,11 +227,11 @@
|
||||
|
||||
if (IsValid && ClearOnPublish)
|
||||
{
|
||||
Model = new();
|
||||
Model = new();
|
||||
await _uploadComponent.ClearClicked.InvokeAsync();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
|
||||
await GroupingPublished.InvokeAsync(oldModel);
|
||||
}
|
||||
|
||||
@@ -343,10 +347,10 @@
|
||||
return categories;
|
||||
}
|
||||
|
||||
private async void OnDeleteEntryClicked(int index)
|
||||
private async void OnDeleteEntryClicked((int index, string filename) data)
|
||||
{
|
||||
Model.ArtifactEntries.RemoveAt(index);
|
||||
_uploadComponent.Files.RemoveAt(index);
|
||||
Model.ArtifactEntries.RemoveAt(data.index);
|
||||
_uploadComponent.RemoveFile(data.filename);
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
<MudDivider DividerType="DividerType.Middle"></MudDivider>
|
||||
<ChipContainer T="DateTime" @ref="_assocaitedDatesChipContainer" @bind-Items="Model.AssociatedDates" DisplayFunc="date => date.ToShortDateString()">
|
||||
<InputContent>
|
||||
<MudDatePicker @bind-Date=_associatedDateInputValue>
|
||||
<MudDatePicker @bind-Date=_associatedDateInputValue MinDate="new DateTime(1000, 1, 1)">
|
||||
</MudDatePicker>
|
||||
</InputContent>
|
||||
<SubmitButton>
|
||||
@@ -149,7 +149,7 @@
|
||||
For="@(() => Model.FileTextContent)"></MudTextField>
|
||||
|
||||
<MudText Typo=Typo.h6 Color="Color.Primary">Additional files</MudText>
|
||||
<UploadDropBox FilesUploaded="OnFilesUploaded"></UploadDropBox>
|
||||
<UploadDropBox @ref=_uploadDropBox FilesUploaded="OnFilesUploaded"></UploadDropBox>
|
||||
</MudPaper>
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@
|
||||
public required int ArtifactEntryIndex {get; set;}
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> OnEntryDeletedClicked { get; set; }
|
||||
public EventCallback<(int index, string filename)> OnEntryDeletedClicked { get; set; }
|
||||
|
||||
private ChipContainer<string> _tagsChipContainer;
|
||||
|
||||
@@ -198,6 +198,23 @@
|
||||
|
||||
public List<ValidationResult> ValidationResults { get; private set; } = [];
|
||||
|
||||
public UploadDropBox _uploadDropBox = default!;
|
||||
|
||||
protected override Task OnParametersSetAsync()
|
||||
{
|
||||
if (_uploadDropBox is not null && Model is not null && Model.Files is not null)
|
||||
{
|
||||
_uploadDropBox.ExistingFiles = Model.Files.GetRange(1, Model.Files.Count - 1);
|
||||
}
|
||||
|
||||
if (Model.Files is not null && Model.Files.Any())
|
||||
{
|
||||
MainFilePath = Model.Files[0];
|
||||
}
|
||||
|
||||
return base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
public async Task OnInputsChanged()
|
||||
{
|
||||
// 1. Clear previous validation errors
|
||||
@@ -217,12 +234,17 @@
|
||||
{
|
||||
if (MainFilePath is not null)
|
||||
{
|
||||
var oldFiles = Model.Files.GetRange(1, Model.Files.Count - 1);
|
||||
Model.Files = [MainFilePath];
|
||||
Model.Files.AddRange(oldFiles);
|
||||
Model.Files.AddRange(filePathListings);
|
||||
} else
|
||||
{
|
||||
Model.Files = [];
|
||||
}
|
||||
Model.Files.AddRange(filePathListings);
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task OnFilesCleared()
|
||||
@@ -296,6 +318,6 @@
|
||||
}
|
||||
private async Task OnDeleteEntryClicked(MouseEventArgs args)
|
||||
{
|
||||
await OnEntryDeletedClicked.InvokeAsync(ArtifactEntryIndex);
|
||||
await OnEntryDeletedClicked.InvokeAsync((ArtifactEntryIndex, MainFilePath.OriginalName));
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,11 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public class ArtifactEntryValidationModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Used when translating between the validation model and the database model
|
||||
/// </summary>
|
||||
public int? Id { get; set; }
|
||||
|
||||
[Required(AllowEmptyStrings = false, ErrorMessage = "An artifact numbering must be supplied")]
|
||||
public string? ArtifactNumber { get; set; }
|
||||
|
||||
@@ -33,14 +38,8 @@ public class ArtifactEntryValidationModel
|
||||
public string? FileTextContent { get; set; }
|
||||
|
||||
public List<ArtifactEntry> RelatedArtifacts { get; set; } = [];
|
||||
|
||||
/*
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext context)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
public bool IsPublicallyVisible { get; set; }
|
||||
|
||||
public bool IsPublicallyVisible { get; set; } = true;
|
||||
|
||||
public ArtifactEntry ToArtifactEntry(ArtifactGrouping? parent = null)
|
||||
{
|
||||
@@ -59,10 +58,9 @@ public class ArtifactEntryValidationModel
|
||||
defects.Add(new ArtifactDefect() { Description=defect});
|
||||
}
|
||||
|
||||
|
||||
|
||||
var entry = new ArtifactEntry()
|
||||
{
|
||||
Id = Id ?? 0,
|
||||
Files = Files,
|
||||
Type = new DataAccess.ArtifactType() { Name = Type },
|
||||
ArtifactNumber = ArtifactNumber,
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ArtifactGroupingValidationModel : IValidatableObject
|
||||
|
||||
public List<ArtifactEntryValidationModel> ArtifactEntries { get; set; } = new();
|
||||
|
||||
public bool IsPublicallyVisible { get; set; }
|
||||
public bool IsPublicallyVisible { get; set; } = true;
|
||||
|
||||
public ArtifactGrouping ToArtifactGrouping()
|
||||
{
|
||||
@@ -75,6 +75,7 @@ public class ArtifactGroupingValidationModel : IValidatableObject
|
||||
|
||||
var validationModel = new ArtifactEntryValidationModel()
|
||||
{
|
||||
Id = entry.Id,
|
||||
Title = entry.Title,
|
||||
StorageLocation = entry.StorageLocation.Location,
|
||||
ArtifactNumber = entry.ArtifactNumber,
|
||||
@@ -131,7 +132,7 @@ public class ArtifactGroupingValidationModel : IValidatableObject
|
||||
}
|
||||
}
|
||||
|
||||
if (ArtifactEntries.IsNullOrEmpty())
|
||||
if (ArtifactEntries is null || ArtifactEntries.Count == 0)
|
||||
{
|
||||
yield return new ValidationResult("Must upload one or more files");
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class CategoryValidationModel
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext context)
|
||||
{
|
||||
if (FieldNames.IsNullOrEmpty() || FieldDescriptions.IsNullOrEmpty())
|
||||
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",
|
||||
|
||||
Reference in New Issue
Block a user