@using Management.Web.Shared.Components @using Management.Web.Shared.Components.Quiz @using Management.Web.Pages.Course.Module @using Management.Web.Pages.Course.Module.ModuleItems @using Management.Web.Pages.Course.Module.NewItemsButtons @using LocalModels @using BlazorMonaco @using BlazorMonaco.Editor @inject CoursePlanner configurationManagement @inject CoursePlanner planner @inject DragContainer dragContainer @code { [Parameter, EditorRequired] public LocalModule Module { get; set; } = default!; private bool dragging { get; set; } = false; private bool publishing = false; private string _notes { get; set; } = ""; private string notes { get => _notes; set { if (value != _notes) { _notes = value; if (planner.LocalCourse != null) { var newModule = Module with { Notes = _notes }; var newModules = planner.LocalCourse.Modules.Select( m => m.Name == newModule.Name ? newModule : m ); planner.LocalCourse = planner.LocalCourse with { Modules = newModules }; } } } } protected override void OnInitialized() { if (_notes == string.Empty) { _notes = Module.Notes; } planner.StateHasChanged += reload; } private void reload() { this.InvokeAsync(this.StateHasChanged); } public void Dispose() { planner.StateHasChanged -= reload; } private string accordionId { get => Module.Name.Replace(" ", "").Replace("#", "") + "-AccordionItem"; } void OnDragEnter() { dragging = true; } void OnDragLeave() { dragging = false; } void OnDrop() { dragging = false; if (dragContainer.DropCallback == null) { System.Console.WriteLine("no drop callback set"); return; } dragContainer.DropCallback?.Invoke(null, Module); } private bool isSyncedWithCanvas => planner .CanvasModules? .FirstOrDefault( cm => cm.Name == Module.Name ) != null; private async Task Publish() { publishing = true; await planner.CreateModule(Module); publishing = false; } }