Adds SoftDelete/Trash across characters, chapters, locations, beats with a purge schedule and Trash page. Reworks the web client for keyboard-driven navigation (focus helpers, help overlay, keyboard.md doc). Moves the ChapterPage tag editor to the bottom of the page to match CharacterDetailPage.
49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using Novelly.Api.Chapters;
|
|
using Novelly.Api.Characters;
|
|
using Novelly.Api.Tags;
|
|
|
|
namespace Novelly.Api.Beats;
|
|
|
|
public class Beat
|
|
{
|
|
public Guid Id { get; set; } = Guid.NewGuid();
|
|
|
|
public Guid ChapterId { get; set; }
|
|
public Chapter? Chapter { get; set; }
|
|
|
|
public int SortOrder { get; set; }
|
|
|
|
public string Title { get; set; } = string.Empty;
|
|
|
|
public List<Character> Characters { get; set; } = [];
|
|
|
|
public List<CharacterArcStage> ArcStages { get; set; } = [];
|
|
|
|
public string? WhatHappened { get; set; }
|
|
|
|
public string? WhatsNext { get; set; }
|
|
|
|
public List<Tag> Tags { get; set; } = [];
|
|
|
|
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
|
public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow;
|
|
}
|
|
|
|
public class BeatEntityTypeConfiguration : IEntityTypeConfiguration<Beat>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Beat> entity)
|
|
{
|
|
entity.Property(b => b.Title).IsRequired().HasMaxLength(200);
|
|
entity.HasIndex(b => new { b.ChapterId, b.SortOrder });
|
|
entity.HasQueryFilter(b => b.Chapter!.DeletedAt == null);
|
|
|
|
entity.HasOne(b => b.Chapter).WithMany(c => c.Beats)
|
|
.HasForeignKey(b => b.ChapterId).OnDelete(DeleteBehavior.Cascade);
|
|
|
|
entity.HasMany(b => b.Characters).WithMany(c => c.Beats)
|
|
.UsingEntity(join => join.ToTable("BeatCharacters"));
|
|
}
|
|
}
|