diff --git a/Management.Web/Management.Web.csproj b/Management.Web/Management.Web.csproj index 38f645a..25ab135 100644 --- a/Management.Web/Management.Web.csproj +++ b/Management.Web/Management.Web.csproj @@ -5,6 +5,7 @@ + diff --git a/Management.Web/Pages/Index.razor b/Management.Web/Pages/Index.razor index da91c03..99eb9bd 100644 --- a/Management.Web/Pages/Index.razor +++ b/Management.Web/Pages/Index.razor @@ -110,4 +110,7 @@ } -
\ No newline at end of file +
+ + +@* *@ \ No newline at end of file diff --git a/Management.Web/Pages/_Host.cshtml b/Management.Web/Pages/_Host.cshtml index feb574b..8adc212 100644 --- a/Management.Web/Pages/_Host.cshtml +++ b/Management.Web/Pages/_Host.cshtml @@ -17,6 +17,7 @@ + @@ -33,6 +34,9 @@ 🗙 + + + diff --git a/Management.Web/Program.cs b/Management.Web/Program.cs index eeab58c..8c30dbd 100644 --- a/Management.Web/Program.cs +++ b/Management.Web/Program.cs @@ -32,6 +32,7 @@ if (canvas_url == null) builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); + builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/Management.Web/Shared/Components/AssignmentForm/AssignmentDescriptionEditor.razor b/Management.Web/Shared/Components/AssignmentForm/AssignmentDescriptionEditor.razor index 93d1057..a5cfcc5 100644 --- a/Management.Web/Shared/Components/AssignmentForm/AssignmentDescriptionEditor.razor +++ b/Management.Web/Shared/Components/AssignmentForm/AssignmentDescriptionEditor.razor @@ -15,7 +15,6 @@ if (assignmentContext.Assignment != null) { Description = assignmentContext.Assignment.Description; - Preview = Markdown.ToHtml(Description); TemplateId = assignmentContext.Assignment.TemplateId; UseTemplate = TemplateId != null && TemplateId != ""; VariableValues = assignmentContext.Assignment.TemplateVariables; @@ -27,7 +26,26 @@ assignmentContext.StateHasChanged -= reload; } - public string Description { get; set; } = default!; + private string description { get; set; } = default!; + public string Description + { + get => description; + set + { + description = value; + if (description != string.Empty) + { + if(assignmentContext.Assignment != null) + { + var newAssignment = assignmentContext.Assignment with + { + Description = description + }; + assignmentContext.SaveAssignment(newAssignment); + } + } + } + } public bool? UseTemplate { get; set; } = null; public string? TemplateId { get; set; } @@ -40,18 +58,9 @@ .AssignmentTemplates .FirstOrDefault(t => t.Id == TemplateId); - public string Preview { get; set; } = String.Empty; - private void saveDescription(ChangeEventArgs e) { - if(assignmentContext.Assignment != null) - { - var newAssignment = assignmentContext.Assignment with - { - Description = e.Value?.ToString() ?? "" - }; - assignmentContext.SaveAssignment(newAssignment); - } + } private void saveTemplateId(ChangeEventArgs e) @@ -67,6 +76,7 @@ } } + private MarkupString preview { get => (MarkupString) Markdown.ToHtml(Description); } } @@ -137,7 +147,6 @@ } - } else { @@ -159,11 +168,11 @@ class="form-control" rows=12 @bind="Description" - @oninput="saveDescription" + @bind:event="oninput" /> -
- @((MarkupString)Preview) +
+ @(preview)
} diff --git a/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor b/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor index 9d4a3de..ad04edf 100644 --- a/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor +++ b/Management.Web/Shared/Components/AssignmentForm/AssignmentForm.razor @@ -82,6 +82,7 @@ await canvas.Assignments.Delete(courseId, assignment); } } + AssignmentModal?.Hide(); } private void handleNameChange(ChangeEventArgs e) diff --git a/Management.Web/Shared/Components/MonacoEditorDemo.razor b/Management.Web/Shared/Components/MonacoEditorDemo.razor new file mode 100644 index 0000000..394387a --- /dev/null +++ b/Management.Web/Shared/Components/MonacoEditorDemo.razor @@ -0,0 +1,84 @@ + +@using BlazorMonaco +@using BlazorMonaco.Editor + +

Code Editor

+ +
+
+ New Value: +
+
+ +
+
+ See the console for results. +
+
+ +
+ +
+ +@code { + private StandaloneCodeEditor _editor = null!; + private string _valueToSet = ""; + + private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor) + { + return new StandaloneEditorConstructionOptions + { + Language = "markdown", + Theme = "vs-dark", + TabSize = 2, + Value = "this is the default \n value", + Minimap = new EditorMinimapOptions { Enabled = false } + }; + } + + private async Task EditorOnDidInit() + { + await _editor.AddCommand((int)KeyMod.CtrlCmd | (int)KeyCode.KeyH, (args) => + { + Console.WriteLine("Ctrl+H : Initial editor command is triggered."); + }); + + var newDecorations = new ModelDeltaDecoration[] + { + new ModelDeltaDecoration + { + Range = new BlazorMonaco.Range(3,1,3,1), + Options = new ModelDecorationOptions + { + IsWholeLine = true, + ClassName = "decorationContentClass", + GlyphMarginClassName = "decorationGlyphMarginClass" + } + } + }; + + decorationIds = await _editor.DeltaDecorations(null, newDecorations); + // You can now use 'decorationIds' to change or remove the decorations + } + + private string[] decorationIds = new string[0]; + + private async Task SetValue() + { + Console.WriteLine($"setting value to: {_valueToSet}"); + await _editor.SetValue(_valueToSet); + } + + private async Task GetValue() + { + var val = await _editor.GetValue(); + Console.WriteLine($"value is: {val}"); + } +} \ No newline at end of file diff --git a/Management.Web/Shared/Components/Quiz/QuizForm.razor b/Management.Web/Shared/Components/Quiz/QuizForm.razor index 1906dfc..d339416 100644 --- a/Management.Web/Shared/Components/Quiz/QuizForm.razor +++ b/Management.Web/Shared/Components/Quiz/QuizForm.razor @@ -26,6 +26,12 @@ quizContext.StateHasChanged -= reload; } + private void deleteQuiz() + { + quizContext.DeleteQuiz(); + modal?.Hide(); + } + private void addQuestion() { if(quizContext.Quiz != null) @@ -149,6 +155,8 @@ }