From 45e8a26d96bcf1fda17a8ad95adb295826f6d2ec Mon Sep 17 00:00:00 2001 From: Frank Tovar Date: Sat, 14 Mar 2026 15:22:43 +0100 Subject: [PATCH] Fix critical cell editor submit flow --- .../Components/Pages/Tables.razor | 2 +- .../Shared/CriticalCellEditorDialog.razor | 291 +++++++++--------- src/RolemasterDb.App/wwwroot/app.css | 12 + 3 files changed, 163 insertions(+), 142 deletions(-) diff --git a/src/RolemasterDb.App/Components/Pages/Tables.razor b/src/RolemasterDb.App/Components/Pages/Tables.razor index a55dfc3..38b9be5 100644 --- a/src/RolemasterDb.App/Components/Pages/Tables.razor +++ b/src/RolemasterDb.App/Components/Pages/Tables.razor @@ -380,8 +380,8 @@ return; } - editorModel = CriticalCellEditorModel.FromResponse(response); await LoadTableDetailAsync(); + await CloseCellEditorAsync(); } catch (Exception exception) { diff --git a/src/RolemasterDb.App/Components/Shared/CriticalCellEditorDialog.razor b/src/RolemasterDb.App/Components/Shared/CriticalCellEditorDialog.razor index d7a3be4..b12d18f 100644 --- a/src/RolemasterDb.App/Components/Shared/CriticalCellEditorDialog.razor +++ b/src/RolemasterDb.App/Components/Shared/CriticalCellEditorDialog.razor @@ -17,166 +17,170 @@ - @if (!string.IsNullOrWhiteSpace(ErrorMessage)) - { -

@ErrorMessage

- } - @if (IsLoading) { -

Loading editor...

+
+

Loading editor...

+
} else { -
-
-

Base Cell

-
- - -
-
- - -
-
- - -
-
-
- - -
-
- - -
-
-
- -
-
-

Base Effects

- -
- @if (Model.Effects.Count == 0) + +
+ @if (!string.IsNullOrWhiteSpace(ErrorMessage)) { -

No normalized base effects for this cell.

+

@ErrorMessage

} - else - { - @for (var index = 0; index < Model.Effects.Count; index++) - { - var effect = Model.Effects[index]; -
-
- Effect @(index + 1) - -
- @EffectFields(effect) + +
+

Base Cell

+
+ + +
+
+ + +
+
+ + +
+
+
+ +
- } - } -
+
+ + +
+
+
-
-
-

Branches

- -
- @if (Model.Branches.Count == 0) - { -

No branch records on this cell.

- } - else - { - @for (var index = 0; index < Model.Branches.Count; index++) +
+
+

Base Effects

+ +
+ @if (Model.Effects.Count == 0) { - var branch = Model.Branches[index]; -
-
- Branch @(index + 1) - -
-
-
- - -
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
- - +

No normalized base effects for this cell.

+ } + else + { + @for (var index = 0; index < Model.Effects.Count; index++) + { + var effect = Model.Effects[index]; +
+
+ Effect @(index + 1) +
+ @EffectFields(effect)
+ } + } +
-
-
-
Branch Effects
- +
+
+

Branches

+ +
+ @if (Model.Branches.Count == 0) + { +

No branch records on this cell.

+ } + else + { + @for (var index = 0; index < Model.Branches.Count; index++) + { + var branch = Model.Branches[index]; +
+
+ Branch @(index + 1) +
- @if (branch.Effects.Count == 0) - { -

No normalized branch effects.

- } - else - { - @for (var effectIndex = 0; effectIndex < branch.Effects.Count; effectIndex++) +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ +
+
+
Branch Effects
+ +
+ @if (branch.Effects.Count == 0) { - var effect = branch.Effects[effectIndex]; -
-
- Branch Effect @(effectIndex + 1) - -
- @EffectFields(effect) -
+

No normalized branch effects.

} - } + else + { + @for (var effectIndex = 0; effectIndex < branch.Effects.Count; effectIndex++) + { + var effect = branch.Effects[effectIndex]; +
+
+ Branch Effect @(effectIndex + 1) + +
+ @EffectFields(effect) +
+ } + } +
-
+ } } - } -
-
- } + + - + + + } } @@ -205,6 +209,11 @@ await OnClose.InvokeAsync(); } + private async Task HandleSubmitAsync(EditContext _) + { + await OnSave.InvokeAsync(); + } + private void AddBaseEffect() { Model?.Effects.Add(new CriticalEffectEditorModel()); diff --git a/src/RolemasterDb.App/wwwroot/app.css b/src/RolemasterDb.App/wwwroot/app.css index eb27736..e17f35f 100644 --- a/src/RolemasterDb.App/wwwroot/app.css +++ b/src/RolemasterDb.App/wwwroot/app.css @@ -710,10 +710,22 @@ textarea { min-height: 4.5rem; } +.critical-editor-textarea.json { + min-height: 12rem; +} + .critical-editor-textarea.tall { min-height: 10rem; } +.critical-editor-error { + margin: 0; + padding: 0.85rem 0.95rem; + border-radius: 14px; + background: rgba(141, 43, 30, 0.08); + border: 1px solid rgba(141, 43, 30, 0.18); +} + .critical-editor-checkbox { display: inline-flex; align-items: center;