mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
83 lines
2.0 KiB
Plaintext
83 lines
2.0 KiB
Plaintext
@using Markdig
|
|
|
|
@inject CoursePlanner planner
|
|
@inject AssignmentEditorContext assignmentContext
|
|
|
|
@code
|
|
{
|
|
protected override void OnInitialized()
|
|
{
|
|
assignmentContext.StateHasChanged += reload;
|
|
reload();
|
|
}
|
|
private void reload()
|
|
{
|
|
if (assignmentContext.Assignment != null)
|
|
{
|
|
if(description == string.Empty)
|
|
{
|
|
description = assignmentContext.Assignment.Description;
|
|
descriptionForPreview = description;
|
|
this.InvokeAsync(this.StateHasChanged);
|
|
}
|
|
}
|
|
}
|
|
public void Dispose()
|
|
{
|
|
assignmentContext.StateHasChanged -= reload;
|
|
}
|
|
|
|
private string description { get; set; } = string.Empty;
|
|
private string descriptionForPreview { get; set; } = string.Empty;
|
|
public bool? UseTemplate { get; set; } = null;
|
|
|
|
public string? TemplateId { get; set; }
|
|
|
|
public Dictionary<string, string> VariableValues { get; set; } = new Dictionary<string, string>();
|
|
|
|
private AssignmentTemplate? selectedTemplate =>
|
|
planner
|
|
.LocalCourse?
|
|
.Settings
|
|
.AssignmentTemplates
|
|
.FirstOrDefault(t => t.Id == TemplateId);
|
|
|
|
private void handleNewDescription(string newDescription)
|
|
{
|
|
if (newDescription != string.Empty)
|
|
{
|
|
descriptionForPreview = newDescription;
|
|
if (assignmentContext.Assignment != null)
|
|
{
|
|
var newAssignment = assignmentContext.Assignment with
|
|
{
|
|
Description = newDescription
|
|
};
|
|
assignmentContext.SaveAssignment(newAssignment);
|
|
}
|
|
}
|
|
}
|
|
|
|
private MarkupString preview { get => (MarkupString)Markdown.ToHtml(descriptionForPreview); }
|
|
|
|
}
|
|
|
|
@if(assignmentContext.Assignment != null && planner.LocalCourse != null)
|
|
{
|
|
<div class="row h-100">
|
|
<div class="col-6">
|
|
@* <textarea
|
|
id="description"
|
|
class="form-control h-100"
|
|
rows=12
|
|
@bind="description"
|
|
@oninput="handleNewDescription"
|
|
/> *@
|
|
|
|
<MonacoTextArea Value="@description" OnChange="@handleNewDescription" />
|
|
</div>
|
|
<div class="col-6" @key="descriptionForPreview">
|
|
@(preview)
|
|
</div>
|
|
</div>
|
|
} |