diff --git a/WebApp/Components/Shared/Components/NoteViewDialog.razor b/WebApp/Components/Shared/Components/NoteViewDialog.razor
index 81d6623..43b5aa8 100644
--- a/WebApp/Components/Shared/Components/NoteViewDialog.razor
+++ b/WebApp/Components/Shared/Components/NoteViewDialog.razor
@@ -4,7 +4,7 @@
@inject NavigationManager NavigationManager
@implements IAsyncDisposable
-
+
@if (_isLoading)
{
diff --git a/WebApp/Components/Shared/Components/PageNoteButton.razor b/WebApp/Components/Shared/Components/PageNoteButton.razor
index 00bde98..37dffb7 100644
--- a/WebApp/Components/Shared/Components/PageNoteButton.razor
+++ b/WebApp/Components/Shared/Components/PageNoteButton.razor
@@ -8,7 +8,8 @@
Variant="@Variant"
Size="@Size"
Color="@ButtonColor"
- Tooltip="@TooltipText">
+ Tooltip="@TooltipText"
+ Class="@MarkdownHelper.GetNoteColorClass(_noteId)">
@if (!string.IsNullOrEmpty(ButtonText))
{
@ButtonText
@@ -37,6 +38,7 @@
private string IconValue => Icon ?? Icons.Material.Filled.Note;
private string TooltipText => Tooltip ?? $"Page notes for {PageIdentifier}";
private bool _hasContent = false;
+ private int _noteId = 0;
private Color ButtonColor => _hasContent ? Color.Success : (Variant == Variant.Filled ? Color.Primary : Color.Default);
private CancellationTokenSource? _cancellationTokenSource;
private bool _isDisposed = false;
@@ -59,6 +61,7 @@
{
var note = await NotesService.GetPageNoteAsync(PageIdentifier);
_hasContent = note != null && !string.IsNullOrWhiteSpace(note.Content);
+ _noteId = note?.Id ?? 0;
if (!_isDisposed)
{
@@ -100,8 +103,9 @@
var dialog = await DialogService.ShowAsync($"Page Notes: {PageIdentifier}", parameters, options);
var result = await dialog.Result;
- // Refresh content indicator after dialog closes
- if (!result.Canceled && !_isDisposed)
+ // Always refresh content indicator after dialog closes
+ // (content may have been saved even if dialog was closed with Cancel)
+ if (!_isDisposed)
{
await CheckNoteContent();
}
diff --git a/WebApp/Components/Shared/Components/PageNoteDialog.razor b/WebApp/Components/Shared/Components/PageNoteDialog.razor
index 594857c..81c7916 100644
--- a/WebApp/Components/Shared/Components/PageNoteDialog.razor
+++ b/WebApp/Components/Shared/Components/PageNoteDialog.razor
@@ -3,7 +3,7 @@
@inject ISnackbar Snackbar
@implements IAsyncDisposable
-
+
@if (_isLoading)
{
@@ -167,15 +167,21 @@
}
else
{
- await NotesService.CreateNoteAsync(_note);
+ // CreateNoteAsync returns the note with the ID populated
+ var createdNote = await NotesService.CreateNoteAsync(_note);
+ // Update _note with the returned note to get the ID immediately
+ _note = createdNote;
+ _isEdit = true; // Mark as existing note now
Snackbar.Add("Page note created successfully", Severity.Success);
}
if (!_isDisposed)
{
- // After saving, switch back to view mode and reload the note
+ // After saving, switch back to view mode and reload the note to ensure we have latest data
_isEditMode = false;
await LoadPageNote();
+ // Ensure dialog re-renders with updated color class after note ID is set
+ StateHasChanged();
}
}
catch (TaskCanceledException)
diff --git a/WebApp/Services/MarkdownHelper.cs b/WebApp/Services/MarkdownHelper.cs
index 2aa8555..1ac2022 100644
--- a/WebApp/Services/MarkdownHelper.cs
+++ b/WebApp/Services/MarkdownHelper.cs
@@ -92,4 +92,16 @@ public static class MarkdownHelper
return plainText;
}
+
+ ///
+ /// Gets the CSS class name for a note's color based on its ID.
+ /// Uses modulo 3 to cycle through 3 pastel color classes.
+ ///
+ /// The note ID.
+ /// CSS class name (e.g., "note-color-0", "note-color-1", "note-color-2"), or empty string if noteId is 0.
+ public static string GetNoteColorClass(int noteId)
+ {
+ if (noteId == 0) return string.Empty;
+ return $"note-color-{noteId % 3}";
+ }
}
diff --git a/WebApp/wwwroot/app.css b/WebApp/wwwroot/app.css
index 2ac96bc3..d6bb642 100644
--- a/WebApp/wwwroot/app.css
+++ b/WebApp/wwwroot/app.css
@@ -229,4 +229,17 @@
.markdown-content img {
max-width: 100%;
height: auto;
+}
+
+/* Note color classes - pastel background colors */
+.note-color-0 {
+ background-color: #e3f2fd;
+}
+
+.note-color-1 {
+ background-color: #fff9e6;
+}
+
+.note-color-2 {
+ background-color: #f3e5f5;
}
\ No newline at end of file