started merging module and calendar pages

This commit is contained in:
2023-07-12 19:48:09 -06:00
parent fae06907be
commit ccbeb5a013
16 changed files with 166 additions and 76 deletions

View File

@@ -1,5 +1,6 @@
@page "/calendar"
@using CanvasModel.EnrollmentTerms
@using Management.Web.Shared.Module
@using Management.Web.Shared.Semester
@inject IConfigurationManagement configurationManagement
@@ -10,17 +11,26 @@
private SemesterPlanner? semester { get; set; }
protected override void OnParametersSet()
{
if (configurationManagement.Configuration != null)
semester = new SemesterPlanner(configurationManagement.Configuration);
if (configurationManagement.SemesterCalendar != null)
semester = new SemesterPlanner(configurationManagement.SemesterCalendar);
}
}
<br>
@if (semester != null)
{
@foreach (var month in semester.Months)
{
<MonthDetail Month="month" Semester="semester" />
<hr />
}
}
<div class="row">
<div class="col">
@if (semester != null)
{
@foreach (var month in semester.Months)
{
<MonthDetail Month="month" Semester="semester" />
<hr />
}
}
</div>
<div class="col">
<Modules />
</div>
</div>

View File

@@ -5,10 +5,13 @@
@inject ICanvasService canvasService
@inject IConfigurationManagement configurationManagement
@inject ProtectedSessionStorage ProtectedSessionStore
@inject ProtectedLocalStorage BrowserStorage
@code
{
private string semesterConfigurationKey = "semesterCalendarConfiguration";
private IEnumerable<EnrollmentTermModel>? terms { get; set; } = null;
private ulong? selectedTermId { get; set; }
private EnrollmentTermModel? selectedTerm
@@ -25,12 +28,27 @@
readDaysFromConfig();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(firstRender)
{
var storedConfiguration = await BrowserStorage.GetAsync<SemesterCalendarConfig>(semesterConfigurationKey);
if (storedConfiguration.Success) {
Console.WriteLine(JsonSerializer.Serialize(storedConfiguration.Value));
configurationManagement.SemesterCalendar = storedConfiguration.Value;
} else {
Console.WriteLine("no stored configuration");
}
StateHasChanged();
}
}
private void readTermFromConfig()
{
if (terms == null || configurationManagement.Configuration == null) return;
if (terms == null || configurationManagement.SemesterCalendar == null) return;
foreach (var term in terms)
{
var termInConfiguration = configurationManagement.Configuration.StartDate == term.StartAt;
var termInConfiguration = configurationManagement.SemesterCalendar.StartDate == term.StartAt;
if (termInConfiguration)
{
selectedTermId = term.Id;
@@ -40,17 +58,24 @@
private void readDaysFromConfig()
{
if (terms == null || configurationManagement.Configuration == null) return;
if (terms == null || configurationManagement.SemesterCalendar == null) return;
days = configurationManagement.Configuration.Days.ToList();
days = configurationManagement.SemesterCalendar.Days.ToList();
}
public async void HandleSave()
{
saved = true;
configurationManagement.SetConfiguration(selectedTerm, days.ToArray());
await ProtectedSessionStore.SetAsync("configuration", configurationManagement.Configuration);
configurationManagement.SetConfiguration(
selectedTerm ?? throw new Exception("cannot save configuration without selecting term"),
days.ToArray()
);
await BrowserStorage.SetAsync(
semesterConfigurationKey,
configurationManagement.SemesterCalendar ?? throw new Exception("Semester Calendar configuration not properly configured")
);
Console.WriteLine(JsonSerializer.Serialize(await BrowserStorage.GetAsync<SemesterCalendarConfig>(semesterConfigurationKey)));
}
}
<PageTitle>Index</PageTitle>
@@ -61,7 +86,7 @@
<div class="col-auto">
<form>
<lablel for="termselect">Select Term:</lablel>
<label for="termselect">Select Term:</label>
<select id="termselect" class="form-select" @bind="selectedTermId">
@foreach (var term in terms)
{
@@ -103,7 +128,7 @@
</div>
}
@if (configurationManagement.Configuration is not null)
@if (configurationManagement.SemesterCalendar is not null)
{
<div>Config complete</div>
}

View File

@@ -1,31 +0,0 @@
@page "/modules"
@using Management.Web.Shared.Module
@using System.Linq
@inject IModuleManager moduleManager
@code {
private bool showNewModule { get; set; } = false;
}
<PageTitle>Weather forecast</PageTitle>
@if (!showNewModule)
{
<button class="btn btn-secondary" @onclick="() => showNewModule = true">New Module</button>
}
else
{
<button class="btn btn-secondary" @onclick="() => showNewModule = false">Hide New Module</button>
}
@if (showNewModule)
{
<NewModule OnSubmit="() => showNewModule = false" />
}
@foreach (var i in moduleManager.Modules.Select((_value, i) => i))
{
<hr>
<ModuleDetail ModuleIndex="i" />
}