mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
more component refactoring
This commit is contained in:
95
Management.Web/Pages/Course/Module/NewAssignment.razor
Normal file
95
Management.Web/Pages/Course/Module/NewAssignment.razor
Normal file
@@ -0,0 +1,95 @@
|
||||
@using Management.Web.Shared.Components
|
||||
@using Management.Web.Shared.Components.Forms
|
||||
|
||||
@inject CoursePlanner planner
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public LocalModule Module { get; set; } = default!;
|
||||
|
||||
[Required]
|
||||
[StringLength(50, ErrorMessage = "Name too long (50 character limit).")]
|
||||
private string Name { get; set; } = "";
|
||||
|
||||
private Modal? modal { get; set; } = null;
|
||||
|
||||
private void submitHandler()
|
||||
{
|
||||
System.Console.WriteLine("new assignment");
|
||||
var newAssignment = new LocalAssignment
|
||||
{
|
||||
Name = Name,
|
||||
Description = "",
|
||||
@* LockAtDueDate = true, *@
|
||||
Rubric = new RubricItem[] { },
|
||||
LockAt = null,
|
||||
DueAt = DateTime.Now,
|
||||
SubmissionTypes = new string[] { AssignmentSubmissionType.ONLINE_TEXT_ENTRY },
|
||||
LocalAssignmentGroupName = selectedAssignmentGroup?.Name,
|
||||
};
|
||||
|
||||
if(planner.LocalCourse != null)
|
||||
{
|
||||
var newModules =planner.LocalCourse.Modules.Select(m =>
|
||||
m.Name != Module.Name
|
||||
? m
|
||||
: Module with
|
||||
{
|
||||
Assignments=Module.Assignments.Append(newAssignment)
|
||||
}
|
||||
);
|
||||
planner.LocalCourse = planner.LocalCourse with
|
||||
{
|
||||
Modules=newModules
|
||||
};
|
||||
}
|
||||
Name = "";
|
||||
modal?.Hide();
|
||||
}
|
||||
|
||||
private void setAssignmentGroup(LocalAssignmentGroup? group)
|
||||
{
|
||||
selectedAssignmentGroup = group;
|
||||
}
|
||||
private LocalAssignmentGroup? selectedAssignmentGroup { get; set; }
|
||||
}
|
||||
|
||||
<button
|
||||
class="btn btn-outline-secondary"
|
||||
@onclick="() => modal?.Show()"
|
||||
>
|
||||
+ Assignment
|
||||
</button>
|
||||
|
||||
<Modal @ref="modal">
|
||||
<Title>New Assignment</Title>
|
||||
<Body>
|
||||
<form @onsubmit:preventDefault="true" @onsubmit="submitHandler">
|
||||
<label for="Assignment Name">Name</label>
|
||||
<input id="moduleName" class="form-control" @bind="Name" />
|
||||
</form>
|
||||
<br>
|
||||
<label class="form-label">Assignment Group</label>
|
||||
@if(planner != null)
|
||||
{
|
||||
<ButtonSelect
|
||||
Label="Assignment Group"
|
||||
Options="planner.LocalCourse?.Settings.AssignmentGroups ?? []"
|
||||
GetName="(g) => g?.Name"
|
||||
OnSelect="(g) => setAssignmentGroup(g)"
|
||||
/>
|
||||
}
|
||||
</Body>
|
||||
<Footer>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
@onclick="submitHandler"
|
||||
>
|
||||
Create Assignment
|
||||
</button>
|
||||
</Footer>
|
||||
</Modal>
|
||||
Reference in New Issue
Block a user