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="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">Current Month</button>
|
||||
<button class="btn month-btn @(_isCurrentMonth ? "selected" : "")" @onclick="SelectCurrentMonth" disabled="@_isLoadingInitial">@MonthAndYear.CurrentMonthName</button>
|
||||
<button class="btn month-btn @(_isCurrentMonth ? "" : "selected")" @onclick="SelectNextMonth" disabled="@_isLoadingInitial">@MonthAndYear.NextMonthName</button>
|
||||
</div>
|
||||
<div class="action-buttons">
|
||||
<button class="btn export-btn" @onclick="ExportToIcs" disabled="@_isLoadingInitial">Export to ICS</button>
|
||||
|
|
@ -46,9 +46,9 @@ else
|
|||
<div class="calendar-container">
|
||||
<!-- Desktop week-based layout -->
|
||||
<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-header">
|
||||
|
|
@ -84,10 +84,10 @@ else
|
|||
@if (SelectedSchedule.ContainsKey(day))
|
||||
{
|
||||
<div class="shift-times">
|
||||
<small>@GetShiftTimes(day)</small>
|
||||
@GetShiftTimes(day)
|
||||
</div>
|
||||
<div class="transport-info">
|
||||
<small>@GetTransportSummary(day)</small>
|
||||
@GetTransportSummary(day)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
|
@ -133,10 +133,10 @@ else
|
|||
@if (SelectedSchedule.ContainsKey(day))
|
||||
{
|
||||
<div class="shift-times">
|
||||
<small>@GetShiftTimes(day)</small>
|
||||
@GetShiftTimes(day)
|
||||
</div>
|
||||
<div class="transport-info">
|
||||
<small>@GetTransportSummary(day)</small>
|
||||
@GetTransportSummary(day)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
|
@ -146,5 +146,5 @@ else
|
|||
}
|
||||
|
||||
<ConfigurationDialog IsVisible="_showConfigDialog"
|
||||
OnClose="HideConfiguration"
|
||||
OnConfigurationChanged="OnConfigurationChanged" />
|
||||
OnClose="HideConfiguration"
|
||||
OnConfigurationChanged="OnConfigurationChanged" />
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
namespace ShiftScheduler.Client.Pages;
|
||||
using System.Globalization;
|
||||
|
||||
namespace ShiftScheduler.Client.Pages;
|
||||
|
||||
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()
|
||||
{
|
||||
var today = DateTime.Today;
|
||||
|
|
@ -10,13 +13,27 @@ public record MonthAndYear(int Month, int Year)
|
|||
var year = today.Month == 12 ? today.Year + 1 : today.Year;
|
||||
return new MonthAndYear(nextMonth, year);
|
||||
}
|
||||
|
||||
public static string CurrentMonthName => Current().ToDateTime.ToString("MMMM");
|
||||
public static string NextMonthName => Next().ToDateTime.ToString("MMMM");
|
||||
|
||||
public string Title => new DateTime(Year, Month, 1).ToString("MMMM yyyy");
|
||||
public string Title => ToDateTime.ToString("MMMM yyyy");
|
||||
|
||||
private DateTime ToDateTime => new DateTime(Year, Month, 1);
|
||||
|
||||
public IReadOnlyList<DateTime> DaysInMonth()
|
||||
{
|
||||
return Enumerable.Range(1, DateTime.DaysInMonth(Year, Month))
|
||||
.Select(d => new DateTime(Year, Month, d))
|
||||
.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