diff --git a/PlotLine/Models/CoreModels.cs b/PlotLine/Models/CoreModels.cs index 95cf9c1..1eecfa2 100644 --- a/PlotLine/Models/CoreModels.cs +++ b/PlotLine/Models/CoreModels.cs @@ -308,6 +308,15 @@ public sealed class Scene { public int SceneID { get; set; } public int ChapterID { get; set; } + public int BookID { get; set; } + public int BookNumber { get; set; } + public int BookSortOrder { get; set; } + public string? BookTitle { get; set; } + public string? BookSubtitle { get; set; } + public string BookDisplayTitle => BookTitleFormatter.DisplayTitle(BookTitle, BookSubtitle); + public decimal ChapterNumber { get; set; } + public int ChapterSortOrder { get; set; } + public string? ChapterTitle { get; set; } public decimal SceneNumber { get; set; } public string SceneTitle { get; set; } = string.Empty; public string? Summary { get; set; } diff --git a/PlotLine/Services/CoreServices.cs b/PlotLine/Services/CoreServices.cs index 1e0e30c..eb4bea2 100644 --- a/PlotLine/Services/CoreServices.cs +++ b/PlotLine/Services/CoreServices.cs @@ -7818,14 +7818,19 @@ public sealed class FloorPlanService( BlockTypeOptions = FloorPlanBlockTypes.All.Select(x => new SelectListItem(BlockTypeLabel(x), x)).ToList(), TransitionTypeOptions = FloorPlanTransitionTypes.All.Select(x => new SelectListItem(x, x)).ToList(), OccupancyScenes = occupancyScenes - .OrderBy(x => x.StartDateTime ?? DateTime.MaxValue) + .OrderBy(x => x.BookSortOrder) + .ThenBy(x => x.BookNumber) + .ThenBy(x => x.BookDisplayTitle) + .ThenBy(x => x.ChapterSortOrder) + .ThenBy(x => x.ChapterNumber) .ThenBy(x => x.SceneNumber) + .ThenBy(x => x.SortOrder) .ThenBy(x => x.SceneTitle) .Select(x => new FloorPlanOccupancySceneViewModel { SceneID = x.SceneID, InitialFloorPlanFloorID = x.InitialFloorPlanFloorID, - Label = $"Scene {x.SceneNumber}: {x.SceneTitle}" + Label = OccupancySceneLabel(x) }) .ToList(), OccupancyTokens = occupancyRows @@ -7967,6 +7972,15 @@ public sealed class FloorPlanService( private static string OccupantName(SceneFloorPlanOccupancy row) => row.CharacterName ?? row.AssetName ?? "Occupant"; + private static string OccupancySceneLabel(Scene scene) + { + var chapter = $"Chapter {scene.ChapterNumber:0.00}"; + var sceneLabel = $"Scene {scene.SceneNumber:0.00}: {scene.SceneTitle}"; + return scene.BookNumber > 0 + ? $"Book {scene.BookNumber}, {chapter}, {sceneLabel}" + : $"{chapter}, {sceneLabel}"; + } + private static bool IsVisibleEntranceTransition(string? transitionType) { var normalized = (transitionType ?? string.Empty) diff --git a/PlotLine/Sql/082_FloorPlanOccupancySceneOrdering.sql b/PlotLine/Sql/082_FloorPlanOccupancySceneOrdering.sql new file mode 100644 index 0000000..63767b1 --- /dev/null +++ b/PlotLine/Sql/082_FloorPlanOccupancySceneOrdering.sql @@ -0,0 +1,69 @@ +SET ANSI_NULLS ON; +GO +SET QUOTED_IDENTIFIER ON; +GO + +CREATE OR ALTER PROCEDURE dbo.Scene_ListByFloorPlan + @FloorPlanID int +AS +BEGIN + SET NOCOUNT ON; + + SELECT + s.SceneID, + s.ChapterID, + c.BookID, + b.BookNumber, + b.SortOrder AS BookSortOrder, + b.BookTitle, + b.Subtitle AS BookSubtitle, + c.ChapterNumber, + c.SortOrder AS ChapterSortOrder, + c.ChapterTitle, + s.SceneNumber, + s.SceneTitle, + s.Summary, + s.POVCharacterID, + s.PrimaryLocationID, + s.FloorPlanID, + s.InitialFloorPlanFloorID, + s.SortOrder, + s.TimeModeID, + tm.TimeModeName, + s.StartDateTime, + s.EndDateTime, + s.DurationAmount, + s.DurationUnitID, + du.DurationUnitName, + s.RelativeTimeText, + s.TimeConfidenceID, + tc.TimeConfidenceName, + s.ScenePurposeNotes, + s.SceneOutcomeNotes, + s.RevisionStatusID, + rs.StatusName AS RevisionStatusName, + s.CreatedDate, + s.UpdatedDate, + s.IsArchived + FROM dbo.Scenes s + INNER JOIN dbo.Chapters c ON c.ChapterID = s.ChapterID + INNER JOIN dbo.Books b ON b.BookID = c.BookID + INNER JOIN dbo.TimeModes tm ON tm.TimeModeID = s.TimeModeID + INNER JOIN dbo.TimeConfidences tc ON tc.TimeConfidenceID = s.TimeConfidenceID + INNER JOIN dbo.RevisionStatuses rs ON rs.RevisionStatusID = s.RevisionStatusID + LEFT JOIN dbo.DurationUnits du ON du.DurationUnitID = s.DurationUnitID + WHERE s.FloorPlanID = @FloorPlanID + AND s.IsArchived = 0 + AND c.IsArchived = 0 + AND b.IsArchived = 0 + ORDER BY + b.SortOrder, + b.BookNumber, + b.BookTitle, + c.SortOrder, + c.ChapterNumber, + s.SceneNumber, + s.SortOrder, + s.SceneTitle; +END; +GO