Files
chapter-organizer/WebApp/Components/Pages/NoteEditDialog.razor
T
poprhythm ddb743847d Add meeting schedule state management services and related models
This commit introduces several new services and models to manage the meeting schedule state within localStorage. The MeetingScheduleState class is created to track scheduled teams, absent students, time slot counts, extended teams, and excluded students. Additionally, the IMeetingScheduleStateService interface and its implementation, MeetingScheduleStateService, are added to handle loading and saving state data. The MeetingScheduleClipboardService and MeetingScheduleDataService are also introduced to facilitate clipboard operations and data loading from the database, respectively. These enhancements improve the overall functionality and user experience of the meeting scheduling feature.
2026-01-19 23:02:55 -05:00

107 lines
3.2 KiB
Plaintext

@using Core.Entities
@using Core.Services
@using WebApp.Services
@using PSC.Blazor.Components.MarkdownEditor
@using MudBlazor
@inject INotesService NotesService
@inject INoteNamingService NoteNamingService
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@inject MarkdownTablePasteService MarkdownTablePasteService
<MudDialog Class="@MarkdownHelper.GetNoteColorClass(_note.Id)">
<DialogContent>
<MudStack Spacing="3">
<MudTextField @bind-Value="_note.Title"
Label="Title"
Variant="Variant.Outlined"
Required="true"
RequiredError="Title is required"
MaxLength="200"
ReadOnly="@IsPageNote" />
<MudText Typo="Typo.subtitle2" Class="mb-2">Content (Markdown)</MudText>
<MarkdownEditor Value="@_note.Content"
ValueChanged="@((string? value) => _note.Content = value)"
Placeholder="Enter your markdown content here..."
AutoSaveEnabled="false"
NativeSpellChecker="false" />
</MudStack>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="Save">Save</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter]
IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public Note Note { get; set; } = null!;
[Parameter]
public bool IsEdit { get; set; }
private Note _note = null!;
private bool _pasteMarkdownInitialized = false;
private bool IsPageNote => Note?.Title != null && NoteNamingService.IsPageNote(Note.Title);
protected override void OnInitialized()
{
_note = new Note
{
Id = Note.Id,
Title = Note.Title ?? "",
Content = Note.Content ?? ""
};
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && !_pasteMarkdownInitialized)
{
// Initialize paste-markdown after EasyMDE has rendered
await Task.Delay(150); // Wait for EasyMDE to initialize
await MarkdownTablePasteService.InitializeAsync();
_pasteMarkdownInitialized = true;
}
}
private async Task Save()
{
if (string.IsNullOrWhiteSpace(_note.Title))
{
Snackbar.Add("Title is required", Severity.Warning);
return;
}
try
{
if (IsEdit)
{
await NotesService.UpdateNoteAsync(_note);
Snackbar.Add("Note updated successfully", Severity.Success);
}
else
{
await NotesService.CreateNoteAsync(_note);
Snackbar.Add("Note created successfully", Severity.Success);
}
MudDialog.Close(DialogResult.Ok(true));
}
catch (Exception ex)
{
Snackbar.Add($"Error saving note: {ex.Message}", Severity.Error);
}
}
private void Cancel()
{
MudDialog.Close(DialogResult.Cancel());
}
}