Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions AudioCuesheetEditor/Shared/Cuesheet/CuesheetData.razor
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ along with Foobar. If not, see

@if (Cuesheet != null)
{
<MudForm Model="Cuesheet">
<MudForm @ref="form" Model="Cuesheet">
<MudTextField @bind-Value="Cuesheet.Artist" For="(() => Cuesheet.Artist)" Validation="_validationService.ValidateProperty" Label="@_localizer["Cuesheet artist"]" Placeholder="@_localizer["Enter the cuesheet artist here"]" Variant="Variant.Outlined" />
<MudTextField @bind-Value="Cuesheet.Title" For="(() => Cuesheet.Title)" Validation="_validationService.ValidateProperty" Label="@_localizer["Cuesheet title"]" Placeholder="@_localizer["Enter the cuesheet title here"]" Variant="Variant.Outlined" />
@switch(CurrentViewMode)
Expand All @@ -51,6 +51,7 @@ along with Foobar. If not, see
string? fileInputAudiofileId;
string? fileInputAudiofileErrorText;
string? fileInputCDTextfileErrorText;
MudForm? form;

protected override void OnInitialized()
{
Expand All @@ -61,6 +62,16 @@ along with Foobar. If not, see
}
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (form != null)
{
await form.Validate();
SetAudiofileValidationText();
}
}

async Task OnAudiofileSelected(IBrowserFile? browserFile)
{
if (Cuesheet == null)
Expand All @@ -83,15 +94,24 @@ along with Foobar. If not, see
// Just validate the cuesheet if there is no error already
if (fileInputAudiofileErrorText == null)
{
var validationMessages = _validationService.Validate(Cuesheet, nameof(Cuesheet.Audiofile));
if (validationMessages.Count() > 0)
{
fileInputAudiofileErrorText = String.Join(Environment.NewLine, validationMessages);
}
else
{
fileInputAudiofileErrorText = null;
}
SetAudiofileValidationText();
}
}

void SetAudiofileValidationText()
{
if (Cuesheet == null)
{
return;
}
var validationMessages = _validationService.Validate(Cuesheet, nameof(Cuesheet.Audiofile));
if (validationMessages.Count() > 0)
{
fileInputAudiofileErrorText = String.Join(Environment.NewLine, validationMessages);
}
else
{
fileInputAudiofileErrorText = null;
}
}

Expand Down