Hero: planning en hero-brede aan/uit verwijderd (hero altijd aan, live zodra er een titel is); migratie, API, admin, tests en docs bijgewerkt

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 08:21:32 +01:00
co-authored by Claude Sonnet 5.5
parent ef62a3714f
commit b78e890f65
29 changed files with 341 additions and 285 deletions
@@ -93,11 +93,8 @@ public static class HeroMapping
NeedsRender(image),
PreviewSrc: PreviewSrc(image));
public static bool IsLive(HeroContent hero, DateTimeOffset now)
=> hero.IsActive
&& !string.IsNullOrWhiteSpace(hero.Title)
&& (hero.StartsAt is null || hero.StartsAt <= now)
&& (hero.EndsAt is null || now < hero.EndsAt);
/// <summary>The hero is always on: it is live as soon as it has usable content (a title). There is no switch and no schedule (a deliberate choice; they may come back later, per slide).</summary>
public static bool IsLive(HeroContent hero) => !string.IsNullOrWhiteSpace(hero.Title);
private static List<HeroButtonDto> Buttons(HeroContent hero)
{
@@ -118,7 +115,7 @@ public static class HeroMapping
/// <summary>The published hero, or null when it is not live. Inactive slides and slides without a stored image are left out.</summary>
public static PublicHeroDto? ToPublic(HeroContent hero, DateTimeOffset now, int maxPublishedSlides)
{
if (!IsLive(hero, now))
if (!IsLive(hero))
{
return null;
}
@@ -159,7 +156,7 @@ public static class HeroMapping
{
if (hero is null)
{
return new HeroAdminDto(null, string.Empty, null, null, HeroDisplays.Single, [], true, null, null, [], false, null, maxPublishedSlides);
return new HeroAdminDto(null, string.Empty, null, null, HeroDisplays.Single, [], [], false, null, maxPublishedSlides);
}
var slides = hero.Slides
@@ -175,11 +172,8 @@ public static class HeroMapping
hero.Lead,
hero.Display,
Buttons(hero),
hero.IsActive,
hero.StartsAt,
hero.EndsAt,
slides,
IsLive(hero, now),
IsLive(hero),
hero.UpdatedAt,
maxPublishedSlides);
}
@@ -19,7 +19,7 @@ public interface IHeroService
/// <summary>The hero for the admin (empty defaults when none exists yet), with whether it is live right now.</summary>
Task<HeroAdminDto> GetAsync(CancellationToken cancellationToken);
/// <summary>Replaces the whole hero: texts, buttons, display, schedule and the ordered slide list.</summary>
/// <summary>Replaces the whole hero: texts, buttons, display and the ordered slide list.</summary>
Task<HeroAdminDto> SaveAsync(HeroSaveRequest request, Guid callerId, CancellationToken cancellationToken);
}
@@ -163,9 +163,6 @@ public class HeroService(
hero.Button2Label = buttons.Count > 1 ? buttons[1].Label : null;
hero.Button2Target = buttons.Count > 1 ? buttons[1].Target : null;
hero.IsActive = r.IsActive;
hero.StartsAt = r.StartsAt;
hero.EndsAt = r.EndsAt;
hero.UpdatedAt = now;
hero.LastModifiedByUserId = callerId;
}
@@ -175,7 +172,7 @@ public class HeroService(
public interface IPublicHeroService
{
/// <summary>The hero as websites get it, or null (no hero, switched off, outside the schedule or without a title).</summary>
/// <summary>The hero as websites get it, or null (no hero or without a title).</summary>
Task<PublicHeroDto?> GetActiveAsync(CancellationToken cancellationToken);
}