UI improvements
This commit is contained in:
parent
97e3d1b490
commit
20fa98b4cb
2 changed files with 30 additions and 13 deletions
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
<div class="top-nav-buttons">
|
<div class="top-nav-buttons">
|
||||||
<div class="month-selection">
|
<div class="month-selection">
|
||||||
<button class="btn month-btn @(_isCurrentMonth ? "" : "selected")" @onclick="SelectNextMonth" disabled="@_isLoadingInitial">Next Month</button>
|
<button class="btn month-btn @(_isCurrentMonth ? "selected" : "")" @onclick="SelectCurrentMonth" disabled="@_isLoadingInitial">@MonthAndYear.CurrentMonthName</button>
|
||||||
<button class="btn month-btn @(_isCurrentMonth ? "selected" : "")" @onclick="SelectCurrentMonth" disabled="@_isLoadingInitial">Current Month</button>
|
<button class="btn month-btn @(_isCurrentMonth ? "" : "selected")" @onclick="SelectNextMonth" disabled="@_isLoadingInitial">@MonthAndYear.NextMonthName</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<button class="btn export-btn" @onclick="ExportToIcs" disabled="@_isLoadingInitial">Export to ICS</button>
|
<button class="btn export-btn" @onclick="ExportToIcs" disabled="@_isLoadingInitial">Export to ICS</button>
|
||||||
|
|
@ -46,9 +46,9 @@ else
|
||||||
<div class="calendar-container">
|
<div class="calendar-container">
|
||||||
<!-- Desktop week-based layout -->
|
<!-- Desktop week-based layout -->
|
||||||
<div class="calendar-grid desktop-calendar">
|
<div class="calendar-grid desktop-calendar">
|
||||||
@foreach (var week in GetWeeksInMonth())
|
@foreach (var week in SelectedDate.GetWeeksInMonth())
|
||||||
{
|
{
|
||||||
@foreach (var day in week)
|
@foreach (var day in week.Value)
|
||||||
{
|
{
|
||||||
<div class="day-cell">
|
<div class="day-cell">
|
||||||
<div class="day-header">
|
<div class="day-header">
|
||||||
|
|
@ -84,10 +84,10 @@ else
|
||||||
@if (SelectedSchedule.ContainsKey(day))
|
@if (SelectedSchedule.ContainsKey(day))
|
||||||
{
|
{
|
||||||
<div class="shift-times">
|
<div class="shift-times">
|
||||||
<small>@GetShiftTimes(day)</small>
|
@GetShiftTimes(day)
|
||||||
</div>
|
</div>
|
||||||
<div class="transport-info">
|
<div class="transport-info">
|
||||||
<small>@GetTransportSummary(day)</small>
|
@GetTransportSummary(day)
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -133,10 +133,10 @@ else
|
||||||
@if (SelectedSchedule.ContainsKey(day))
|
@if (SelectedSchedule.ContainsKey(day))
|
||||||
{
|
{
|
||||||
<div class="shift-times">
|
<div class="shift-times">
|
||||||
<small>@GetShiftTimes(day)</small>
|
@GetShiftTimes(day)
|
||||||
</div>
|
</div>
|
||||||
<div class="transport-info">
|
<div class="transport-info">
|
||||||
<small>@GetTransportSummary(day)</small>
|
@GetTransportSummary(day)
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
namespace ShiftScheduler.Client.Pages;
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace ShiftScheduler.Client.Pages;
|
||||||
|
|
||||||
public record MonthAndYear(int Month, int Year)
|
public record MonthAndYear(int Month, int Year)
|
||||||
{
|
{
|
||||||
public static MonthAndYear Current() => new MonthAndYear(DateTime.Now.Month, DateTime.Now.Year);
|
public static MonthAndYear Current() => new (DateTime.Now.Month, DateTime.Now.Year);
|
||||||
|
|
||||||
public static MonthAndYear Next()
|
public static MonthAndYear Next()
|
||||||
{
|
{
|
||||||
var today = DateTime.Today;
|
var today = DateTime.Today;
|
||||||
|
|
@ -11,7 +14,12 @@ public record MonthAndYear(int Month, int Year)
|
||||||
return new MonthAndYear(nextMonth, year);
|
return new MonthAndYear(nextMonth, year);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Title => new DateTime(Year, Month, 1).ToString("MMMM yyyy");
|
public static string CurrentMonthName => Current().ToDateTime.ToString("MMMM");
|
||||||
|
public static string NextMonthName => Next().ToDateTime.ToString("MMMM");
|
||||||
|
|
||||||
|
public string Title => ToDateTime.ToString("MMMM yyyy");
|
||||||
|
|
||||||
|
private DateTime ToDateTime => new DateTime(Year, Month, 1);
|
||||||
|
|
||||||
public IReadOnlyList<DateTime> DaysInMonth()
|
public IReadOnlyList<DateTime> DaysInMonth()
|
||||||
{
|
{
|
||||||
|
|
@ -19,4 +27,13 @@ public record MonthAndYear(int Month, int Year)
|
||||||
.Select(d => new DateTime(Year, Month, d))
|
.Select(d => new DateTime(Year, Month, d))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IReadOnlyDictionary<int, List<DateTime>> GetWeeksInMonth()
|
||||||
|
{
|
||||||
|
var days = DaysInMonth();
|
||||||
|
var weeks = days
|
||||||
|
.GroupBy(d => CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(d, CalendarWeekRule.FirstDay, DayOfWeek.Monday))
|
||||||
|
.ToDictionary(d => d.Key, d => d.ToList());
|
||||||
|
return weeks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue