Generate navigation and render page embeds from PocketBase
This commit is contained in:
1 parent
6b5d9dda55
commit
3fd3796d73
26 files changed
+544
-114
No files matched your search
@@ -1,4 +1,3 @@
|
||||
using System.Globalization;
|
||||
using Elternbeirat.Contracts;
|
||||
using Elternbeirat.PocketBase;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -7,8 +6,6 @@ namespace Elternbeirat.Web.Features.Events;
|
||||
|
||||
public partial class EventList
|
||||
{
|
||||
private static readonly CultureInfo German = CultureInfo.GetCultureInfo("de-DE");
|
||||
|
||||
[LoggerMessage(Level = LogLevel.Warning, Message = "Could not load events from PocketBase.")]
|
||||
private static partial void LogLoadFailed(ILogger logger, Exception exception);
|
||||
|
||||
@@ -48,36 +45,4 @@ public partial class EventList
|
||||
.OrderByDescending(e => e.Start)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
// An event counts as all-day when its start carries no wall-clock time
|
||||
// (00:00); PocketBase has no separate flag.
|
||||
private static bool HasTime(Event ev) => ev.Start.TimeOfDay != TimeSpan.Zero;
|
||||
|
||||
// Formats the entry's date range for display: a single day, a date with a
|
||||
// time, or a span across days.
|
||||
private static string Format(Event ev)
|
||||
{
|
||||
var start = HasTime(ev)
|
||||
? ev.Start.ToString("dddd, d. MMMM yyyy, HH:mm", German) + " Uhr"
|
||||
: ev.Start.ToString("dddd, d. MMMM yyyy", German);
|
||||
|
||||
if (ev.End is not { } end)
|
||||
{
|
||||
return start;
|
||||
}
|
||||
|
||||
// Same day: append just the end time. Different days: append the full
|
||||
// end date.
|
||||
if (end.Date == ev.Start.Date)
|
||||
{
|
||||
return HasTime(ev)
|
||||
? start + "–" + end.ToString("HH:mm", German) + " Uhr"
|
||||
: start;
|
||||
}
|
||||
|
||||
var endText = HasTime(ev)
|
||||
? end.ToString("d. MMMM yyyy, HH:mm", German) + " Uhr"
|
||||
: end.ToString("d. MMMM yyyy", German);
|
||||
return start + " – " + endText;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user