This commit is contained in:
1 parent
45b7a2b7e6
commit
960d52686a
8 files changed
+98
-51
No files matched your search
@@ -164,7 +164,8 @@ public partial class TimetableViewModel : ObservableObject
|
||||
|
||||
public void Load()
|
||||
{
|
||||
var today = DateOnly.FromDateTime(Clock());
|
||||
var now = Clock();
|
||||
var today = DateOnly.FromDateTime(now);
|
||||
TodayLabel = today.ToString("dddd, dd.MM.yyyy", System.Globalization.CultureInfo.GetCultureInfo("de-DE"));
|
||||
|
||||
var publicHolidayDates = new HashSet<DateOnly>();
|
||||
@@ -176,7 +177,7 @@ public partial class TimetableViewModel : ObservableObject
|
||||
var duties = _supervisionDuties.GetAll();
|
||||
|
||||
BuildGrid(holidayBadges, duties);
|
||||
BuildWeekOverview(today, publicHolidayDates, duties);
|
||||
BuildWeekOverview(today, now, publicHolidayDates, duties);
|
||||
ApplyWeatherToWeekHeaders(today);
|
||||
_ = LoadWeatherAsync(today);
|
||||
BuildToday(today);
|
||||
@@ -436,13 +437,17 @@ public partial class TimetableViewModel : ObservableObject
|
||||
/// Vertretungsaufsicht) werden zwischen den betroffenen Stundenzeilen eingefügt, Vertretungsstunden
|
||||
/// ersetzen für ihre Stunde die sonst aus dem Stundenplan abgeleitete Anzeige.
|
||||
/// </summary>
|
||||
private void BuildWeekOverview(DateOnly today, HashSet<DateOnly> publicHolidayDates, List<SupervisionDuty> duties)
|
||||
private void BuildWeekOverview(DateOnly today, DateTime now, HashSet<DateOnly> publicHolidayDates,
|
||||
List<SupervisionDuty> duties)
|
||||
{
|
||||
WeekItems.Clear();
|
||||
var currentWeekMonday = today.AddDays(-((int)today.DayOfWeek + 6) % 7);
|
||||
var monday = currentWeekMonday.AddDays(WeekOffset * 7);
|
||||
var friday = monday.AddDays(4);
|
||||
WeekRangeLabel = $"{monday:dd.MM.} – {friday:dd.MM.yyyy}";
|
||||
var currentPeriod = monday == currentWeekMonday && Weekdays.Contains(today.DayOfWeek)
|
||||
? CurrentPeriodAt(TimeOnly.FromDateTime(now))
|
||||
: null;
|
||||
|
||||
var allSlots = _slots.GetAll();
|
||||
var groups = _groups.GetAll(includeInactive: true).ToDictionary(g => g.Id);
|
||||
@@ -459,7 +464,7 @@ public partial class TimetableViewModel : ObservableObject
|
||||
|
||||
for (var period = FirstPeriod; period <= LastPeriod; period++)
|
||||
{
|
||||
WeekItems.Add(WeekCellItem.PeriodLabel(period));
|
||||
WeekItems.Add(WeekCellItem.PeriodLabel(period, period == currentPeriod));
|
||||
foreach (var weekday in Weekdays)
|
||||
{
|
||||
var date = dateByWeekday[weekday];
|
||||
@@ -518,6 +523,19 @@ public partial class TimetableViewModel : ObservableObject
|
||||
WeekRows.Add(new WeekRowItem(rowCells));
|
||||
}
|
||||
|
||||
private int? CurrentPeriodAt(TimeOnly time)
|
||||
{
|
||||
for (var period = FirstPeriod; period <= LastPeriod; period++)
|
||||
{
|
||||
if (_periodSchedule.GetTimes(period) is not { } times) continue;
|
||||
var within = times.End > times.Start
|
||||
? time >= times.Start && time < times.End
|
||||
: times.End < times.Start && (time >= times.Start || time < times.End);
|
||||
if (within) return period;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void AddWeekSupervisionRowIfAny(int afterPeriod, ILookup<int, SupervisionDuty> dutiesByPeriod,
|
||||
List<SubstitutionEntry> substitutionsThisWeek, Dictionary<DayOfWeek, DateOnly> dateByWeekday)
|
||||
{
|
||||
@@ -845,6 +863,7 @@ public partial class WeekCellItem : ObservableObject
|
||||
public DayOfWeek? Weekday { get; private init; }
|
||||
public int PeriodNumber { get; private init; }
|
||||
public bool IsToday { get; private init; }
|
||||
public bool IsCurrentPeriod { get; private init; }
|
||||
public DateOnly? Date { get; private init; }
|
||||
public Guid GroupId { get; private init; }
|
||||
public string SubjectLabel { get; private init; } = "";
|
||||
@@ -908,7 +927,10 @@ public partial class WeekCellItem : ObservableObject
|
||||
}) + $" {date:dd.MM.}",
|
||||
};
|
||||
|
||||
public static WeekCellItem PeriodLabel(int period) => new() { IsPeriodLabel = true, Text = period.ToString() };
|
||||
public static WeekCellItem PeriodLabel(int period, bool isCurrentPeriod = false) => new()
|
||||
{
|
||||
IsPeriodLabel = true, PeriodNumber = period, IsCurrentPeriod = isCurrentPeriod, Text = period.ToString(),
|
||||
};
|
||||
|
||||
public static WeekCellItem Empty(DayOfWeek day, int period) => new() { Weekday = day, PeriodNumber = period };
|
||||
|
||||
|
||||
Reference in new issue
Block a user