mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-13 20:53:37 +00:00
Merged the two validation systems of the visual briefing editor into one
This commit is contained in:
parent
dc71c2ba0b
commit
c238a80764
@ -79,7 +79,6 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
<MudForm @ref="@(this.visualBriefingForm)"
|
<MudForm @ref="@(this.visualBriefingForm)"
|
||||||
@bind-IsValid="@(this.formIsValid)"
|
|
||||||
@bind-Errors="@(this.formIssues)">
|
@bind-Errors="@(this.formIssues)">
|
||||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Wrap="Wrap.Wrap" Class="mb-3">
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Wrap="Wrap.Wrap" Class="mb-3">
|
||||||
<MudText Typo="Typo.h3">@this.editor.Name</MudText>
|
<MudText Typo="Typo.h3">@this.editor.Name</MudText>
|
||||||
|
|||||||
@ -23,20 +23,23 @@ public partial class VisualBriefingAssistant
|
|||||||
private bool CannotRecompile => this.IsCurrentBusy || this.selectedBriefing is null || this.selectedRevisionId == Guid.Empty || !this.SelectedVersionSupportsEdits;
|
private bool CannotRecompile => this.IsCurrentBusy || this.selectedBriefing is null || this.selectedRevisionId == Guid.Empty || !this.SelectedVersionSupportsEdits;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines <c>CannotGenerate</c> for the visual briefing feature.
|
/// Gets whether one edit mode is currently blocked.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// A mode is blocked by the very issues listed below the buttons, minus the ones that do not apply
|
||||||
|
/// to it. Changing only the design rebuilds the presentation from the validated content of a stored
|
||||||
|
/// version, so it neither needs source material nor cares whether a source file moved away in the
|
||||||
|
/// meantime. The two modes that edit a stored version instead require that version to still carry
|
||||||
|
/// its semantic artifacts.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="mode">The edit mode the user asked for.</param>
|
||||||
|
/// <returns><c>true</c> when the mode must stay disabled.</returns>
|
||||||
private bool CannotGenerate(VisualBriefingEditMode mode) =>
|
private bool CannotGenerate(VisualBriefingEditMode mode) =>
|
||||||
this.IsCurrentBusy ||
|
this.IsCurrentBusy ||
|
||||||
this.editor.Provider == ProviderSettings.NONE ||
|
this.selectedBriefing is null ||
|
||||||
string.IsNullOrWhiteSpace(this.editor.Name) ||
|
this.FieldIssues.Count > 0 ||
|
||||||
this.editor.TargetLanguage is CommonLanguages.OTHER && string.IsNullOrWhiteSpace(this.editor.CustomTargetLanguage) ||
|
mode is not VisualBriefingEditMode.CHANGE_DESIGN && this.SourceIssues.Count > 0 ||
|
||||||
this.editor.ProtectionLevel is VisualBriefingProtectionLevel.OTHER && string.IsNullOrWhiteSpace(this.editor.CustomProtectionLevel) ||
|
mode is VisualBriefingEditMode.CHANGE_DESIGN or VisualBriefingEditMode.UPDATE_CONTENT && !this.SelectedVersionSupportsEdits;
|
||||||
mode is not VisualBriefingEditMode.CHANGE_DESIGN && !this.HasSourceMaterial ||
|
|
||||||
mode is VisualBriefingEditMode.CHANGE_DESIGN or VisualBriefingEditMode.UPDATE_CONTENT &&
|
|
||||||
!this.SelectedVersionSupportsEdits ||
|
|
||||||
mode is not VisualBriefingEditMode.CHANGE_DESIGN &&
|
|
||||||
this.selectedBriefing?.Sources.Any(source =>
|
|
||||||
source.Status is VisualBriefingSourceStatus.UNREACHABLE or VisualBriefingSourceStatus.TRANSCRIPT_OUTDATED) == true;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs one long-running briefing operation inside the shared session, progress, and error envelope.
|
/// Runs one long-running briefing operation inside the shared session, progress, and error envelope.
|
||||||
|
|||||||
@ -269,7 +269,6 @@ public partial class VisualBriefingAssistant
|
|||||||
|
|
||||||
this.lastPersistedState = this.BuildPersistenceFingerprint();
|
this.lastPersistedState = this.BuildPersistenceFingerprint();
|
||||||
this.formIssues = [];
|
this.formIssues = [];
|
||||||
this.formIsValid = false;
|
|
||||||
this.formValidationPending = true;
|
this.formValidationPending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +303,6 @@ public partial class VisualBriefingAssistant
|
|||||||
this.reusableContentBuildId = null;
|
this.reusableContentBuildId = null;
|
||||||
this.lastPersistedState = string.Empty;
|
this.lastPersistedState = string.Empty;
|
||||||
this.formIssues = [];
|
this.formIssues = [];
|
||||||
this.formIsValid = false;
|
|
||||||
this.formValidationPending = false;
|
this.formValidationPending = false;
|
||||||
this.visualBriefingForm?.ResetValidation();
|
this.visualBriefingForm?.ResetValidation();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,19 +16,51 @@ public partial class VisualBriefingAssistant
|
|||||||
private bool HasSourceMaterial => this.selectedBriefing?.Sources.Any(source => source.Kind is VisualBriefingSourceKind.SOURCE_MATERIAL) == true;
|
private bool HasSourceMaterial => this.selectedBriefing?.Sources.Any(source => source.Kind is VisualBriefingSourceKind.SOURCE_MATERIAL) == true;
|
||||||
|
|
||||||
/// <summary>Gets all current field, source, and revision issues shown below the actions.</summary>
|
/// <summary>Gets all current field, source, and revision issues shown below the actions.</summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is the complete list for the user. The generate buttons disable themselves from the same
|
||||||
|
/// two building blocks, so a listed issue and a blocked button can no longer contradict each other.
|
||||||
|
/// Only the MudBlazor field messages stay out of that gate: they arrive one validation pass late,
|
||||||
|
/// which would make the buttons flicker, and the validators behind them are evaluated directly by
|
||||||
|
/// FieldIssues anyway.
|
||||||
|
/// </remarks>
|
||||||
private IReadOnlyList<string> ValidationIssues
|
private IReadOnlyList<string> ValidationIssues
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
List<string> issues = [.. this.formIssues];
|
List<string> issues = [.. this.formIssues, .. this.FieldIssues, .. this.SourceIssues];
|
||||||
|
|
||||||
|
if (this.selectedBriefing is { Versions.Count: > 0 } && !this.SelectedVersionSupportsEdits)
|
||||||
|
issues.Add(T("This version has no compatible semantic artifacts. Rebuild the briefing instead."));
|
||||||
|
|
||||||
|
return [.. issues.Where(issue => !string.IsNullOrWhiteSpace(issue)).Distinct(StringComparer.Ordinal)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Gets the field issues that block generation regardless of the edit mode.</summary>
|
||||||
|
private IReadOnlyList<string> FieldIssues
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<string> issues = [];
|
||||||
|
|
||||||
AddIssue(issues, this.ValidateProjectName(this.editor.Name));
|
AddIssue(issues, this.ValidateProjectName(this.editor.Name));
|
||||||
AddIssue(issues, this.ValidateProvider(this.editor.Provider));
|
AddIssue(issues, this.ValidateProvider(this.editor.Provider));
|
||||||
AddIssue(issues, this.ValidateCustomTargetLanguage(this.editor.CustomTargetLanguage));
|
AddIssue(issues, this.ValidateCustomTargetLanguage(this.editor.CustomTargetLanguage));
|
||||||
AddIssue(issues, this.ValidateCustomProtectionLevel(this.editor.CustomProtectionLevel));
|
AddIssue(issues, this.ValidateCustomProtectionLevel(this.editor.CustomProtectionLevel));
|
||||||
|
|
||||||
if (this.selectedBriefing is not null)
|
return issues;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Gets the issues with the stored sources, which block only the modes that read them.</summary>
|
||||||
|
private IReadOnlyList<string> SourceIssues
|
||||||
{
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (this.selectedBriefing is null)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
List<string> issues = [];
|
||||||
if (!this.HasSourceMaterial)
|
if (!this.HasSourceMaterial)
|
||||||
issues.Add(T("Please add at least one source material file."));
|
issues.Add(T("Please add at least one source material file."));
|
||||||
|
|
||||||
@ -47,11 +79,7 @@ public partial class VisualBriefingAssistant
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.selectedBriefing.Versions.Count > 0 && !this.SelectedVersionSupportsEdits)
|
return issues;
|
||||||
issues.Add(T("This version has no compatible semantic artifacts. Rebuild the briefing instead."));
|
|
||||||
}
|
|
||||||
|
|
||||||
return [.. issues.Where(issue => !string.IsNullOrWhiteSpace(issue)).Distinct(StringComparer.Ordinal)];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -123,9 +123,6 @@ public partial class VisualBriefingAssistant : MSGComponentBase
|
|||||||
/// <summary>Owns MudBlazor validation for the selected briefing editor.</summary>
|
/// <summary>Owns MudBlazor validation for the selected briefing editor.</summary>
|
||||||
private MudForm? visualBriefingForm;
|
private MudForm? visualBriefingForm;
|
||||||
|
|
||||||
/// <summary>Stores whether all MudBlazor fields in the editor are currently valid.</summary>
|
|
||||||
private bool formIsValid;
|
|
||||||
|
|
||||||
/// <summary>Stores the current MudBlazor validation messages.</summary>
|
/// <summary>Stores the current MudBlazor validation messages.</summary>
|
||||||
private string[] formIssues = [];
|
private string[] formIssues = [];
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user