mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
better class day highlighting
This commit is contained in:
@@ -1,25 +1,57 @@
|
||||
@page "/"
|
||||
@using CanvasModel.EnrollmentTerms
|
||||
@using Management.Web.Shared.Semester
|
||||
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||
|
||||
@inject ICanvasService canvasService
|
||||
@inject IConfigurationManagement configurationManagement
|
||||
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||
|
||||
@code
|
||||
{
|
||||
private IEnumerable<EnrollmentTermModel>? terms { get; set; } = null;
|
||||
private ulong? selectedTermId { get; set; } = null;
|
||||
private ulong? selectedTermId { get; set; }
|
||||
private EnrollmentTermModel? selectedTerm
|
||||
{
|
||||
get => terms?.FirstOrDefault(t => t.Id == selectedTermId);
|
||||
}
|
||||
private List<DayOfWeek> days { get; set; } = new();
|
||||
private bool saved { get; set; } = false;
|
||||
private SemesterConfiguration? configuration { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
terms = await canvasService.GetCurrentTermsFor();
|
||||
readTermFromConfig();
|
||||
readDaysFromConfig();
|
||||
}
|
||||
|
||||
private void readTermFromConfig()
|
||||
{
|
||||
if (terms == null || configurationManagement.Configuration == null) return;
|
||||
foreach (var term in terms)
|
||||
{
|
||||
var termInConfiguration = configurationManagement.Configuration.StartDate == term.StartAt;
|
||||
if (termInConfiguration)
|
||||
{
|
||||
selectedTermId = term.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readDaysFromConfig()
|
||||
{
|
||||
if (terms == null || configurationManagement.Configuration == null) return;
|
||||
|
||||
days = configurationManagement.Configuration.Days.ToList();
|
||||
}
|
||||
|
||||
|
||||
public async void HandleSave()
|
||||
{
|
||||
saved = true;
|
||||
configurationManagement.SetConfiguration(selectedTerm, days.ToArray());
|
||||
await ProtectedSessionStore.SetAsync("configuration", configurationManagement.Configuration);
|
||||
}
|
||||
}
|
||||
<PageTitle>Index</PageTitle>
|
||||
|
||||
@@ -60,22 +92,18 @@
|
||||
@day
|
||||
</button>
|
||||
</div>
|
||||
|
||||
}
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-auto">
|
||||
<button @onclick="() => {
|
||||
saved = true;
|
||||
configuration = ConfigurationManagement.CreateFromTerm(selectedTerm, days.ToArray());
|
||||
}" class="btn btn-primary" disabled="@saved">
|
||||
<button @onclick="@HandleSave" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (configuration is not null)
|
||||
@if (configurationManagement.Configuration is not null)
|
||||
{
|
||||
<SemesterDetail Configuration="configuration" />
|
||||
<div>Config complete</div>
|
||||
}
|
||||
Reference in New Issue
Block a user