Split quick parse layout from input control
This commit is contained in:
@@ -41,9 +41,9 @@
|
||||
else if (Model is null)
|
||||
{
|
||||
<div class="critical-editor-body">
|
||||
@if (!string.IsNullOrWhiteSpace(ErrorMessage))
|
||||
@if (!string.IsNullOrWhiteSpace(GetVisibleErrorMessage()))
|
||||
{
|
||||
<p class="error-text critical-editor-error">@ErrorMessage</p>
|
||||
<p class="error-text critical-editor-error">@GetVisibleErrorMessage()</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -60,22 +60,15 @@
|
||||
}
|
||||
|
||||
<div class="critical-curation-grid">
|
||||
<div class="critical-editor-card critical-curation-preview-card">
|
||||
<div class="critical-editor-card critical-curation-preview-card @(IsQuickParseMode ? "is-quick-parse" : null)">
|
||||
@if (IsQuickParseMode)
|
||||
{
|
||||
<CriticalCellQuickParseEditor
|
||||
@ref="quickParseEditor"
|
||||
Model="Model"
|
||||
IsBusy="IsReparsing"
|
||||
IsDisabled="IsSaving"
|
||||
ShowActionButton="false"
|
||||
ShowSectionHeader="false"
|
||||
ShowSourcePreview="false"
|
||||
ShowExampleHint="false"
|
||||
ShowDescriptionEditor="false"
|
||||
ShowValidationSummary="false"
|
||||
ShowLegend="false"
|
||||
ErrorMessage="@QuickParseErrorMessage"
|
||||
SectionClass="critical-editor-section critical-curation-quick-parse-section" />
|
||||
IsDisabled="@(IsSaving || IsReparsing)"
|
||||
TextAreaCssClass="input-shell critical-editor-textarea critical-curation-quick-parse-textarea"
|
||||
OnReparse="OnReparse" />
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -197,6 +190,7 @@
|
||||
|
||||
private IJSObjectReference? jsModule;
|
||||
private bool isBackdropPointerDown;
|
||||
private CriticalCellQuickParseEditor? quickParseEditor;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
@@ -292,6 +286,17 @@
|
||||
|
||||
private async Task HandleReparseClickAsync(MouseEventArgs _)
|
||||
{
|
||||
if (quickParseEditor is not null)
|
||||
{
|
||||
await quickParseEditor.ReparseAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
await OnReparse.InvokeAsync();
|
||||
}
|
||||
|
||||
private string? GetVisibleErrorMessage() =>
|
||||
IsQuickParseMode && !string.IsNullOrWhiteSpace(QuickParseErrorMessage)
|
||||
? QuickParseErrorMessage
|
||||
: ErrorMessage;
|
||||
}
|
||||
|
||||
@@ -57,19 +57,90 @@
|
||||
{
|
||||
<EditForm @key="Model" Model="Model" OnSubmit="HandleSubmitAsync" class="critical-editor-form">
|
||||
<div class="critical-editor-body">
|
||||
@if (!string.IsNullOrWhiteSpace(ReparseErrorMessage))
|
||||
{
|
||||
<p class="error-text critical-editor-error">@ReparseErrorMessage</p>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(SaveErrorMessage))
|
||||
{
|
||||
<p class="error-text critical-editor-error">@SaveErrorMessage</p>
|
||||
}
|
||||
|
||||
<section class="critical-editor-section">
|
||||
<div class="critical-editor-section-header">
|
||||
<div>
|
||||
<h4>Quick Parse Input</h4>
|
||||
<p class="muted">First line is the result prose. Later lines are base affixes or <code>condition: ...</code> lines with comma-separated shorthand.</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ritual"
|
||||
@onclick="HandleQuickParseReparseClickAsync"
|
||||
@onclick:stopPropagation="true"
|
||||
@onclick:preventDefault="true"
|
||||
disabled="@(IsSaving || IsReparsing)">
|
||||
@(IsReparsing ? "Generating..." : "Generate From Quick Input")
|
||||
</button>
|
||||
</div>
|
||||
<div class="critical-editor-quick-parse-grid">
|
||||
<div class="field-shell">
|
||||
<label>Quick Parse Input</label>
|
||||
<CriticalCellQuickParseEditor
|
||||
@ref="quickParseEditor"
|
||||
Model="Model"
|
||||
IsBusy="IsReparsing"
|
||||
IsDisabled="IsSaving"
|
||||
ShowDescriptionEditor="true"
|
||||
ErrorMessage="@ReparseErrorMessage"
|
||||
ComparisonHintText="@(HasComparisonDifferences(Model, ComparisonBaseline) ? "Fresh generation differs from the current edited card. Review Generated Compare before saving if you want to keep the overrides." : null)"
|
||||
IsDisabled="@(IsSaving || IsReparsing)"
|
||||
OnReparse="OnReparse" />
|
||||
</div>
|
||||
|
||||
<div class="critical-editor-quick-parse-source">
|
||||
<div class="critical-editor-quick-parse-source-header">
|
||||
<label>Source Cell</label>
|
||||
@if (Model.SourcePageNumber is not null)
|
||||
{
|
||||
<span class="chip">Page @Model.SourcePageNumber</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="critical-editor-quick-parse-source-frame">
|
||||
@if (!string.IsNullOrWhiteSpace(Model.SourceImageUrl))
|
||||
{
|
||||
<img
|
||||
class="critical-editor-source-image is-inline"
|
||||
src="@Model.SourceImageUrl"
|
||||
alt="@CriticalCellPresentation.BuildSourceImageAltText(Model)" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="muted critical-editor-inline-copy">No source image is available for this cell yet.</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="muted critical-editor-advanced-hint">Example: <code>Foe brings his guard up, frightened by your display.</code> then <code>+5, 1mp</code> or <code>w/o shield: glancing blow, +15, 3s, 3np</code>.</p>
|
||||
<div class="critical-editor-quick-legend">
|
||||
@foreach (var entry in QuickParseLegendEntries)
|
||||
{
|
||||
<div class="critical-editor-quick-legend-item">
|
||||
<code>@entry.Token</code>
|
||||
<span class="critical-editor-quick-legend-equals">=</span>
|
||||
<AffixBadgeList Effects="@entry.Effects" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@if (Model.ValidationMessages.Count > 0)
|
||||
{
|
||||
<p class="muted critical-editor-advanced-hint">@GetParserNoteSummary(Model.ValidationMessages.Count)</p>
|
||||
}
|
||||
@if (HasComparisonDifferences(Model, ComparisonBaseline))
|
||||
{
|
||||
<p class="muted critical-editor-advanced-hint">Fresh generation differs from the current edited card. Review Generated Compare before saving if you want to keep the overrides.</p>
|
||||
}
|
||||
<div class="field-shell">
|
||||
<label>Result Text</label>
|
||||
<InputTextArea class="input-shell critical-editor-textarea compact" @bind-Value="Model.DescriptionText" @bind-Value:after="MarkDescriptionOverridden" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="critical-editor-section">
|
||||
<div class="critical-editor-section-header">
|
||||
@@ -287,8 +358,20 @@
|
||||
[Parameter, EditorRequired]
|
||||
public EventCallback OnSave { get; set; }
|
||||
|
||||
private static readonly IReadOnlyList<(string Token, IReadOnlyList<CriticalEffectLookupResponse> Effects)> QuickParseLegendEntries =
|
||||
[
|
||||
("+15", [CreateQuickLegendEffect(CriticalEffectCodes.DirectHits, valueInteger: 15)]),
|
||||
("3s", [CreateQuickLegendEffect(CriticalEffectCodes.StunnedRounds, durationRounds: 3)]),
|
||||
("1mp", [CreateQuickLegendEffect(CriticalEffectCodes.MustParryRounds, durationRounds: 1)]),
|
||||
("3np", [CreateQuickLegendEffect(CriticalEffectCodes.NoParryRounds, durationRounds: 3)]),
|
||||
("1hpr", [CreateQuickLegendEffect(CriticalEffectCodes.BleedPerRound, perRound: 1)]),
|
||||
("-20", [CreateQuickLegendEffect(CriticalEffectCodes.FoePenalty, modifier: -20)]),
|
||||
("+20b", [CreateQuickLegendEffect(CriticalEffectCodes.AttackerBonusNextRound, modifier: 20)]),
|
||||
("+2d10-3pp", [CreateQuickLegendEffect(CriticalEffectCodes.PowerPointModifier, valueExpression: "2d10-3")])
|
||||
];
|
||||
private IJSObjectReference? jsModule;
|
||||
private bool isBackdropPointerDown;
|
||||
private CriticalCellQuickParseEditor? quickParseEditor;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
@@ -362,6 +445,17 @@
|
||||
await OnSave.InvokeAsync();
|
||||
}
|
||||
|
||||
private async Task HandleQuickParseReparseClickAsync(MouseEventArgs _)
|
||||
{
|
||||
if (quickParseEditor is not null)
|
||||
{
|
||||
await quickParseEditor.ReparseAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
await OnReparse.InvokeAsync();
|
||||
}
|
||||
|
||||
private void AddBaseEffect()
|
||||
{
|
||||
if (Model is null)
|
||||
@@ -516,6 +610,39 @@
|
||||
return segments.Count == 0 ? "Generated compare" : string.Join(" · ", segments);
|
||||
}
|
||||
|
||||
private void MarkDescriptionOverridden()
|
||||
{
|
||||
if (Model is not null)
|
||||
{
|
||||
Model.IsDescriptionOverridden = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetParserNoteSummary(int noteCount) =>
|
||||
noteCount == 1
|
||||
? "1 parser note is available under Advanced Review."
|
||||
: $"{noteCount} parser notes are available under Advanced Review.";
|
||||
|
||||
private static CriticalEffectLookupResponse CreateQuickLegendEffect(
|
||||
string effectCode,
|
||||
int? valueInteger = null,
|
||||
string? valueExpression = null,
|
||||
int? durationRounds = null,
|
||||
int? perRound = null,
|
||||
int? modifier = null) =>
|
||||
new(
|
||||
effectCode,
|
||||
"foe",
|
||||
valueInteger,
|
||||
valueExpression,
|
||||
durationRounds,
|
||||
perRound,
|
||||
modifier,
|
||||
null,
|
||||
false,
|
||||
"legend",
|
||||
null);
|
||||
|
||||
private static IReadOnlyList<string> GetComparisonSummaryItems(CriticalCellEditorModel model, CriticalCellEditorModel? comparisonBaseline)
|
||||
{
|
||||
if (model.GeneratedState is null)
|
||||
|
||||
@@ -1,221 +1,28 @@
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using RolemasterDb.App.Domain
|
||||
@using RolemasterDb.App.Features
|
||||
|
||||
<section class="@SectionClass">
|
||||
@if (!string.IsNullOrWhiteSpace(ErrorMessage))
|
||||
{
|
||||
<p class="error-text critical-editor-error">@ErrorMessage</p>
|
||||
}
|
||||
|
||||
@if (ShowSectionHeader)
|
||||
{
|
||||
<div class="critical-editor-section-header">
|
||||
<div>
|
||||
<h4>Quick Parse Input</h4>
|
||||
<p class="muted">First line is the result prose. Later lines are base affixes or <code>condition: ...</code> lines with comma-separated shorthand.</p>
|
||||
</div>
|
||||
@if (ShowActionButton)
|
||||
{
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ritual"
|
||||
@onclick="HandleReparseClickAsync"
|
||||
@onclick:stopPropagation="true"
|
||||
@onclick:preventDefault="true"
|
||||
disabled="@(IsBusy || IsDisabled)">
|
||||
@(IsBusy ? BusyActionButtonText : ActionButtonText)
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="@GetQuickParseGridCssClass()">
|
||||
<div class="field-shell">
|
||||
<label>Quick Parse Input</label>
|
||||
<textarea
|
||||
class="@GetTextAreaCssClass()"
|
||||
<textarea
|
||||
class="@TextAreaCssClass"
|
||||
value="@Model.QuickParseInput"
|
||||
@oninput="HandleQuickParseInputChanged"></textarea>
|
||||
</div>
|
||||
|
||||
@if (ShowSourcePreview)
|
||||
{
|
||||
<div class="critical-editor-quick-parse-source">
|
||||
<div class="critical-editor-quick-parse-source-header">
|
||||
<label>Source Cell</label>
|
||||
@if (Model.SourcePageNumber is not null)
|
||||
{
|
||||
<span class="chip">Page @Model.SourcePageNumber</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="critical-editor-quick-parse-source-frame">
|
||||
@if (!string.IsNullOrWhiteSpace(Model.SourceImageUrl))
|
||||
{
|
||||
<img
|
||||
class="critical-editor-source-image is-inline"
|
||||
src="@Model.SourceImageUrl"
|
||||
alt="@CriticalCellPresentation.BuildSourceImageAltText(Model)" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="muted critical-editor-inline-copy">No source image is available for this cell yet.</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (ShowExampleHint)
|
||||
{
|
||||
<p class="muted critical-editor-advanced-hint">Example: <code>Foe brings his guard up, frightened by your display.</code> then <code>+5, 1mp</code> or <code>w/o shield: glancing blow, +15, 3s, 3np</code>.</p>
|
||||
}
|
||||
|
||||
@if (ShowLegend)
|
||||
{
|
||||
<div class="critical-editor-quick-legend">
|
||||
@foreach (var entry in QuickParseLegendEntries)
|
||||
{
|
||||
<div class="critical-editor-quick-legend-item">
|
||||
<code>@entry.Token</code>
|
||||
<span class="critical-editor-quick-legend-equals">=</span>
|
||||
<AffixBadgeList Effects="@entry.Effects" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (ShowValidationSummary && Model.ValidationMessages.Count > 0)
|
||||
{
|
||||
<p class="muted critical-editor-advanced-hint">@GetParserNoteSummary(Model.ValidationMessages.Count)</p>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(ComparisonHintText))
|
||||
{
|
||||
<p class="muted critical-editor-advanced-hint">@ComparisonHintText</p>
|
||||
}
|
||||
|
||||
@if (ShowDescriptionEditor)
|
||||
{
|
||||
<div class="field-shell">
|
||||
<label>Result Text</label>
|
||||
<InputTextArea class="input-shell critical-editor-textarea compact" @bind-Value="Model.DescriptionText" @bind-Value:after="MarkDescriptionOverridden" />
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
@oninput="HandleQuickParseInputChanged"
|
||||
disabled="@IsDisabled"></textarea>
|
||||
|
||||
@code {
|
||||
[Parameter, EditorRequired]
|
||||
public CriticalCellEditorModel Model { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
public bool IsBusy { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool IsDisabled { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool ShowActionButton { get; set; } = true;
|
||||
|
||||
[Parameter]
|
||||
public bool ShowSectionHeader { get; set; } = true;
|
||||
|
||||
[Parameter]
|
||||
public bool ShowSourcePreview { get; set; } = true;
|
||||
|
||||
[Parameter]
|
||||
public bool ShowExampleHint { get; set; } = true;
|
||||
|
||||
[Parameter]
|
||||
public bool ShowLegend { get; set; } = true;
|
||||
|
||||
[Parameter]
|
||||
public bool ShowValidationSummary { get; set; } = true;
|
||||
|
||||
[Parameter]
|
||||
public bool ShowDescriptionEditor { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string SectionClass { get; set; } = "critical-editor-section";
|
||||
|
||||
[Parameter]
|
||||
public string TextAreaSizeCssClass { get; set; } = "tall";
|
||||
|
||||
[Parameter]
|
||||
public string? GridCssClass { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string ActionButtonText { get; set; } = "Generate From Quick Input";
|
||||
|
||||
[Parameter]
|
||||
public string BusyActionButtonText { get; set; } = "Generating...";
|
||||
|
||||
[Parameter]
|
||||
public string? ComparisonHintText { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string? ErrorMessage { get; set; }
|
||||
public string TextAreaCssClass { get; set; } = "input-shell critical-editor-textarea tall";
|
||||
|
||||
[Parameter]
|
||||
public EventCallback OnReparse { get; set; }
|
||||
|
||||
private static readonly IReadOnlyList<(string Token, IReadOnlyList<CriticalEffectLookupResponse> Effects)> QuickParseLegendEntries =
|
||||
[
|
||||
("+15", [CreateQuickLegendEffect(CriticalEffectCodes.DirectHits, valueInteger: 15)]),
|
||||
("3s", [CreateQuickLegendEffect(CriticalEffectCodes.StunnedRounds, durationRounds: 3)]),
|
||||
("1mp", [CreateQuickLegendEffect(CriticalEffectCodes.MustParryRounds, durationRounds: 1)]),
|
||||
("3np", [CreateQuickLegendEffect(CriticalEffectCodes.NoParryRounds, durationRounds: 3)]),
|
||||
("1hpr", [CreateQuickLegendEffect(CriticalEffectCodes.BleedPerRound, perRound: 1)]),
|
||||
("-20", [CreateQuickLegendEffect(CriticalEffectCodes.FoePenalty, modifier: -20)]),
|
||||
("+20b", [CreateQuickLegendEffect(CriticalEffectCodes.AttackerBonusNextRound, modifier: 20)]),
|
||||
("+2d10-3pp", [CreateQuickLegendEffect(CriticalEffectCodes.PowerPointModifier, valueExpression: "2d10-3")])
|
||||
];
|
||||
|
||||
private async Task HandleReparseClickAsync(MouseEventArgs _)
|
||||
{
|
||||
await OnReparse.InvokeAsync();
|
||||
}
|
||||
public Task ReparseAsync() => OnReparse.InvokeAsync();
|
||||
|
||||
private void HandleQuickParseInputChanged(ChangeEventArgs args)
|
||||
{
|
||||
Model.QuickParseInput = args.Value?.ToString() ?? string.Empty;
|
||||
}
|
||||
|
||||
private void MarkDescriptionOverridden()
|
||||
{
|
||||
Model.IsDescriptionOverridden = true;
|
||||
}
|
||||
|
||||
private string GetQuickParseGridCssClass() =>
|
||||
string.IsNullOrWhiteSpace(GridCssClass)
|
||||
? "critical-editor-quick-parse-grid"
|
||||
: $"critical-editor-quick-parse-grid {GridCssClass}";
|
||||
|
||||
private string GetTextAreaCssClass() => $"input-shell critical-editor-textarea {TextAreaSizeCssClass}";
|
||||
|
||||
private static string GetParserNoteSummary(int noteCount) =>
|
||||
noteCount == 1
|
||||
? "1 parser note is available under Advanced Review."
|
||||
: $"{noteCount} parser notes are available under Advanced Review.";
|
||||
|
||||
private static CriticalEffectLookupResponse CreateQuickLegendEffect(
|
||||
string effectCode,
|
||||
int? valueInteger = null,
|
||||
string? valueExpression = null,
|
||||
int? durationRounds = null,
|
||||
int? perRound = null,
|
||||
int? modifier = null) =>
|
||||
new(
|
||||
effectCode,
|
||||
"foe",
|
||||
valueInteger,
|
||||
valueExpression,
|
||||
durationRounds,
|
||||
perRound,
|
||||
modifier,
|
||||
null,
|
||||
false,
|
||||
"legend",
|
||||
null);
|
||||
}
|
||||
|
||||
@@ -1419,6 +1419,12 @@ textarea {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.critical-curation-preview-card.is-quick-parse {
|
||||
padding: 0;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.critical-curation-preview-button {
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
@@ -1444,12 +1450,20 @@ textarea {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.critical-curation-quick-parse-section {
|
||||
.critical-curation-quick-parse-textarea {
|
||||
display: block;
|
||||
flex: 1 1 auto;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.critical-curation-quick-parse-section .critical-editor-quick-parse-grid {
|
||||
grid-template-columns: minmax(0, 1.45fr) minmax(260px, 1fr);
|
||||
padding: 0.75rem;
|
||||
border: none;
|
||||
border-radius: inherit;
|
||||
background: transparent;
|
||||
box-sizing: border-box;
|
||||
box-shadow: none;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.critical-curation-source-card {
|
||||
|
||||
Reference in New Issue
Block a user