From 98838336a30d9daec7dc71baf9502ae35d768971 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 6 Dec 2026 15:50:41 +0000 Subject: [PATCH] Refine asset dependency flow and scene history --- PlotLine/Controllers/StoryAssetsController.cs | 43 ++++++- PlotLine/Data/Repositories.cs | 9 ++ PlotLine/Models/CoreModels.cs | 34 ++++++ PlotLine/Services/CoreServices.cs | 59 ++++++++- PlotLine/Services/ProjectAccessFilter.cs | 2 +- PlotLine/Sql/356_AssetDetails.sql | 113 ++++++++++++++++++ PlotLine/ViewModels/CoreViewModels.cs | 3 +- PlotLine/Views/StoryAssets/Details.cshtml | 103 +++------------- .../StoryAssets/_DependencyFields.cshtml | 41 +++++++ .../Views/StoryAssets/_DependencyFlow.cshtml | 50 ++++++++ .../Views/StoryAssets/_SceneHistory.cshtml | 53 ++++++++ PlotLine/wwwroot/css/asset-details.css | 83 +++++++++++++ 12 files changed, 498 insertions(+), 95 deletions(-) create mode 100644 PlotLine/Sql/356_AssetDetails.sql create mode 100644 PlotLine/Views/StoryAssets/_DependencyFields.cshtml create mode 100644 PlotLine/Views/StoryAssets/_DependencyFlow.cshtml create mode 100644 PlotLine/Views/StoryAssets/_SceneHistory.cshtml create mode 100644 PlotLine/wwwroot/css/asset-details.css diff --git a/PlotLine/Controllers/StoryAssetsController.cs b/PlotLine/Controllers/StoryAssetsController.cs index 0001f037..f9843540 100644 --- a/PlotLine/Controllers/StoryAssetsController.cs +++ b/PlotLine/Controllers/StoryAssetsController.cs @@ -121,7 +121,47 @@ public sealed class StoryAssetsController(IAssetService assets) : Controller [ValidateAntiForgeryToken] public async Task AddDependency(AssetDependencyEditViewModel model, int returnAssetId) { - await assets.SaveDependencyAsync(model); + if (!ModelState.IsValid) return BadRequest(); + + if (model.SourceAssetID == model.TargetAssetID) + { + TempData["AssetMessage"] = "Choose two different assets."; + } + else + { + model.AssetDependencyID = 0; + await assets.SaveDependencyAsync(model); + } + + return RedirectToAction(nameof(Details), new { id = returnAssetId, tab = "dependencies" }); + } + + [HttpPost] + [ValidateAntiForgeryToken] + public async Task EditDependency(int id, int returnAssetId, + [Bind(nameof(AssetDependencyEditViewModel.AssetDependencyTypeID), + nameof(AssetDependencyEditViewModel.SourceRequiredStateID), + nameof(AssetDependencyEditViewModel.TargetBlockedStateID), + nameof(AssetDependencyEditViewModel.Description))] AssetDependencyEditViewModel model) + { + if (!ModelState.IsValid) return BadRequest(); + + var detail = await assets.GetAssetDetailAsync(returnAssetId); + var dependency = detail?.Dependencies.SingleOrDefault(item => item.AssetDependencyID == id); + if (dependency is null) return NotFound(); + + if (dependency.SourceAssetID == dependency.TargetAssetID) + { + TempData["AssetMessage"] = "An asset cannot depend on itself. Remove this dependency to replace it."; + } + else + { + model.AssetDependencyID = id; + model.SourceAssetID = dependency.SourceAssetID; + model.TargetAssetID = dependency.TargetAssetID; + if (await assets.SaveDependencyAsync(model) == 0) return NotFound(); + } + return RedirectToAction(nameof(Details), new { id = returnAssetId, tab = "dependencies" }); } @@ -131,6 +171,7 @@ public sealed class StoryAssetsController(IAssetService assets) : Controller { if (model.SourceAssetID != model.TargetAssetID) { + model.AssetDependencyID = 0; await assets.SaveDependencyAsync(model); } diff --git a/PlotLine/Data/Repositories.cs b/PlotLine/Data/Repositories.cs index aefca1b4..0163e06e 100644 --- a/PlotLine/Data/Repositories.cs +++ b/PlotLine/Data/Repositories.cs @@ -199,6 +199,7 @@ public interface IAssetRepository Task RejectSceneAssetSuggestionAsync(int suggestionId, int userId); Task> CountSceneAssetSuggestionsByChapterAsync(int chapterId, int userId); Task> ListDependenciesByAssetAsync(int storyAssetId); + Task> ListLocationHistoryByAssetAsync(int storyAssetId); Task SaveDependencyAsync(AssetDependency dependency); Task DeleteDependencyAsync(int assetDependencyId); Task> ListCustodyBySceneAsync(int sceneId); @@ -3593,6 +3594,14 @@ public sealed class AssetRepository(ISqlConnectionFactory connectionFactory) : I return rows.ToList(); } + public async Task> ListLocationHistoryByAssetAsync(int storyAssetId) + { + using var connection = connectionFactory.CreateConnection(); + var rows = await connection.QueryAsync("dbo.SceneAssetLocation_ListByAsset", + new { StoryAssetID = storyAssetId }, commandType: CommandType.StoredProcedure); + return rows.ToList(); + } + public async Task SaveDependencyAsync(AssetDependency dependency) { using var connection = connectionFactory.CreateConnection(); diff --git a/PlotLine/Models/CoreModels.cs b/PlotLine/Models/CoreModels.cs index 67ebc6bc..f94d8da6 100644 --- a/PlotLine/Models/CoreModels.cs +++ b/PlotLine/Models/CoreModels.cs @@ -917,6 +917,12 @@ public sealed class AssetEvent public string? BookTitle { get; set; } public string? BookSubtitle { get; set; } public string BookDisplayTitle => BookTitleFormatter.DisplayTitle(BookTitle, BookSubtitle); + public int BookID { get; set; } + public int BookNumber { get; set; } + public int ChapterID { get; set; } + public int BookSortOrder { get; set; } + public int ChapterSortOrder { get; set; } + public int SceneSortOrder { get; set; } public decimal ChapterNumber { get; set; } public decimal SceneNumber { get; set; } public string SceneTitle { get; set; } = string.Empty; @@ -924,6 +930,28 @@ public sealed class AssetEvent public DateTime UpdatedDate { get; set; } } +public sealed record AssetSceneHistoryEntry +{ + public int SceneID { get; init; } + public string? BookTitle { get; init; } + public string? BookSubtitle { get; init; } + public string BookDisplayTitle => BookTitleFormatter.DisplayTitle(BookTitle, BookSubtitle); + public int BookID { get; init; } + public int BookNumber { get; init; } + public int ChapterID { get; init; } + public int BookSortOrder { get; init; } + public int ChapterSortOrder { get; init; } + public int SceneSortOrder { get; init; } + public decimal ChapterNumber { get; init; } + public decimal SceneNumber { get; init; } + public string SceneTitle { get; init; } = string.Empty; + public string Title { get; init; } = string.Empty; + public string? FromState { get; init; } + public string? ToState { get; init; } + public string? Detail { get; init; } + public string? Description { get; init; } +} + public sealed class AssetDependencyType { public int AssetDependencyTypeID { get; set; } @@ -984,6 +1012,12 @@ public sealed class AssetCustodyEvent public string? BookTitle { get; set; } public string? BookSubtitle { get; set; } public string BookDisplayTitle => BookTitleFormatter.DisplayTitle(BookTitle, BookSubtitle); + public int BookID { get; set; } + public int BookNumber { get; set; } + public int ChapterID { get; set; } + public int BookSortOrder { get; set; } + public int ChapterSortOrder { get; set; } + public int SceneSortOrder { get; set; } public decimal ChapterNumber { get; set; } public decimal SceneNumber { get; set; } public string SceneTitle { get; set; } = string.Empty; diff --git a/PlotLine/Services/CoreServices.cs b/PlotLine/Services/CoreServices.cs index a314bac8..c256c2ac 100644 --- a/PlotLine/Services/CoreServices.cs +++ b/PlotLine/Services/CoreServices.cs @@ -8072,9 +8072,8 @@ public sealed class AssetService( Asset = asset, Aliases = (await assets.ListAliasesAsync(storyAssetId)).Select(alias => alias.Alias).ToList(), ProjectAssets = projectAssets, - Events = await assets.ListEventsByAssetAsync(storyAssetId), + SceneHistory = await GetSceneHistoryAsync(storyAssetId), Dependencies = await assets.ListDependenciesByAssetAsync(storyAssetId), - CustodyEvents = await assets.ListCustodyByAssetAsync(storyAssetId), NewDependency = new AssetDependencyEditViewModel { ProjectID = asset.ProjectID, @@ -8089,6 +8088,62 @@ public sealed class AssetService( }; } + private async Task> GetSceneHistoryAsync(int assetId) + { + var events = await assets.ListEventsByAssetAsync(assetId); + var custody = await assets.ListCustodyByAssetAsync(assetId); + var locations = await assets.ListLocationHistoryByAssetAsync(assetId); + + return events.Select(item => new AssetSceneHistoryEntry + { + SceneID = item.SceneID, + BookID = item.BookID, + BookNumber = item.BookNumber, + BookTitle = item.BookTitle, + BookSubtitle = item.BookSubtitle, + ChapterID = item.ChapterID, + BookSortOrder = item.BookSortOrder, + ChapterSortOrder = item.ChapterSortOrder, + SceneSortOrder = item.SceneSortOrder, + ChapterNumber = item.ChapterNumber, + SceneNumber = item.SceneNumber, + SceneTitle = item.SceneTitle, + Title = string.IsNullOrWhiteSpace(item.EventTitle) ? item.AssetEventTypeName : item.EventTitle, + FromState = item.FromStateName, + ToState = item.ToStateName, + Description = item.EventDescription + }) + .Concat(custody.Select(item => new AssetSceneHistoryEntry + { + SceneID = item.SceneID, + BookID = item.BookID, + BookNumber = item.BookNumber, + BookTitle = item.BookTitle, + BookSubtitle = item.BookSubtitle, + ChapterID = item.ChapterID, + BookSortOrder = item.BookSortOrder, + ChapterSortOrder = item.ChapterSortOrder, + SceneSortOrder = item.SceneSortOrder, + ChapterNumber = item.ChapterNumber, + SceneNumber = item.SceneNumber, + SceneTitle = item.SceneTitle, + Title = item.CustodyEventTypeName, + Detail = item.CustodianSummary, + Description = item.Description + })) + .Concat(locations) + .OrderBy(item => item.BookSortOrder) + .ThenBy(item => item.BookNumber) + .ThenBy(item => item.BookID) + .ThenBy(item => item.ChapterSortOrder) + .ThenBy(item => item.ChapterNumber) + .ThenBy(item => item.ChapterID) + .ThenBy(item => item.SceneSortOrder) + .ThenBy(item => item.SceneNumber) + .ThenBy(item => item.SceneID) + .ToList(); + } + public async Task SaveAssetAsync(StoryAssetEditViewModel model) { var isNew = model.StoryAssetID == 0; diff --git a/PlotLine/Services/ProjectAccessFilter.cs b/PlotLine/Services/ProjectAccessFilter.cs index 79195139..d15063d2 100644 --- a/PlotLine/Services/ProjectAccessFilter.cs +++ b/PlotLine/Services/ProjectAccessFilter.cs @@ -135,7 +135,7 @@ public sealed class ProjectAccessFilter(IProjectAccessService access, ICurrentUs ["DeleteChecklistItem"] = "SceneChecklistItem", ["DeleteAttachment"] = "SceneAttachment" }, - ["StoryAssets"] = new(StringComparer.OrdinalIgnoreCase) { ["DeleteDependency"] = "AssetDependency" }, + ["StoryAssets"] = new(StringComparer.OrdinalIgnoreCase) { ["DeleteDependency"] = "AssetDependency", ["EditDependency"] = "AssetDependency" }, ["Timeline"] = new(StringComparer.OrdinalIgnoreCase) { ["LoadPreset"] = "TimelineViewPreset", ["DeletePreset"] = "TimelineViewPreset" }, ["Warnings"] = new(StringComparer.OrdinalIgnoreCase) { ["Dismiss"] = "ContinuityWarning", ["MarkIntentional"] = "ContinuityWarning", ["Restore"] = "ContinuityWarning" } }; diff --git a/PlotLine/Sql/356_AssetDetails.sql b/PlotLine/Sql/356_AssetDetails.sql new file mode 100644 index 00000000..dd474927 --- /dev/null +++ b/PlotLine/Sql/356_AssetDetails.sql @@ -0,0 +1,113 @@ +CREATE OR ALTER PROCEDURE dbo.AssetDependency_Save + @AssetDependencyID int = NULL, + @SourceAssetID int, + @TargetAssetID int, + @AssetDependencyTypeID int, + @SourceRequiredStateID int = NULL, + @TargetBlockedStateID int = NULL, + @Description nvarchar(max) = NULL +AS +BEGIN + SET NOCOUNT ON; + IF @SourceAssetID = @TargetAssetID + THROW 51000, 'An asset cannot depend on itself.', 1; + + IF NOT EXISTS ( + SELECT 1 FROM dbo.StoryAssets source + INNER JOIN dbo.StoryAssets target ON target.ProjectID = source.ProjectID + WHERE source.StoryAssetID = @SourceAssetID AND target.StoryAssetID = @TargetAssetID + ) + THROW 51000, 'Dependency endpoints must belong to the same project.', 1; + + IF @AssetDependencyID IS NULL OR @AssetDependencyID = 0 + BEGIN + INSERT dbo.AssetDependencies (SourceAssetID, TargetAssetID, AssetDependencyTypeID, SourceRequiredStateID, TargetBlockedStateID, Description) + VALUES (@SourceAssetID, @TargetAssetID, @AssetDependencyTypeID, @SourceRequiredStateID, @TargetBlockedStateID, @Description); + SET @AssetDependencyID = CAST(SCOPE_IDENTITY() AS int); + END + ELSE + BEGIN + UPDATE dbo.AssetDependencies + SET AssetDependencyTypeID = @AssetDependencyTypeID, + SourceRequiredStateID = @SourceRequiredStateID, + TargetBlockedStateID = @TargetBlockedStateID, + Description = @Description, + UpdatedDate = SYSUTCDATETIME() + WHERE AssetDependencyID = @AssetDependencyID AND IsArchived = 0 + AND SourceAssetID = @SourceAssetID AND TargetAssetID = @TargetAssetID; + + IF @@ROWCOUNT = 0 + SET @AssetDependencyID = 0; + END + SELECT @AssetDependencyID; +END; +GO + +CREATE OR ALTER PROCEDURE dbo.AssetEvent_ListByAsset + @StoryAssetID int +AS +BEGIN + SET NOCOUNT ON; + SELECT ae.AssetEventID, ae.StoryAssetID, sa.ProjectID, sa.AssetName, sa.AssetKindID, ak.KindName, + ae.SceneID, ae.AssetEventTypeID, aet.TypeName AS AssetEventTypeName, aet.MarkerText, + ae.FromStateID, fs.StateName AS FromStateName, ae.ToStateID, ts.StateName AS ToStateName, + ae.EventTitle, ae.EventDescription, ae.CreatedDate, ae.UpdatedDate, + b.BookID, b.BookNumber, b.BookTitle, b.Subtitle AS BookSubtitle, c.ChapterID, c.ChapterNumber, s.SceneNumber, s.SceneTitle, + b.SortOrder AS BookSortOrder, c.SortOrder AS ChapterSortOrder, s.SortOrder AS SceneSortOrder + FROM dbo.AssetEvents ae + INNER JOIN dbo.StoryAssets sa ON sa.StoryAssetID = ae.StoryAssetID + INNER JOIN dbo.AssetKinds ak ON ak.AssetKindID = sa.AssetKindID + INNER JOIN dbo.AssetEventTypes aet ON aet.AssetEventTypeID = ae.AssetEventTypeID + INNER JOIN dbo.Scenes s ON s.SceneID = ae.SceneID + INNER JOIN dbo.Chapters c ON c.ChapterID = s.ChapterID + INNER JOIN dbo.Books b ON b.BookID = c.BookID + LEFT JOIN dbo.AssetStates fs ON fs.AssetStateID = ae.FromStateID + LEFT JOIN dbo.AssetStates ts ON ts.AssetStateID = ae.ToStateID + WHERE ae.StoryAssetID = @StoryAssetID + ORDER BY b.SortOrder, c.SortOrder, s.SortOrder, ae.AssetEventID; +END; +GO + +CREATE OR ALTER PROCEDURE dbo.AssetCustodyEvent_ListByAsset + @StoryAssetID int +AS +BEGIN + SET NOCOUNT ON; + SELECT ace.AssetCustodyEventID, ace.StoryAssetID, sa.AssetName, ace.SceneID, + ace.AssetCustodyEventTypeID, acet.TypeName AS CustodyEventTypeName, ace.Description, + STRING_AGG(CONCAT(aec.CharacterNameText, N' (', cr.RoleName, N')'), N', ') AS CustodianSummary, + ace.CreatedDate, ace.UpdatedDate, b.BookID, b.BookNumber, b.BookTitle, b.Subtitle AS BookSubtitle, c.ChapterID, c.ChapterNumber, s.SceneNumber, s.SceneTitle, + b.SortOrder AS BookSortOrder, c.SortOrder AS ChapterSortOrder, s.SortOrder AS SceneSortOrder + FROM dbo.AssetCustodyEvents ace + INNER JOIN dbo.StoryAssets sa ON sa.StoryAssetID = ace.StoryAssetID + INNER JOIN dbo.AssetCustodyEventTypes acet ON acet.AssetCustodyEventTypeID = ace.AssetCustodyEventTypeID + INNER JOIN dbo.Scenes s ON s.SceneID = ace.SceneID + INNER JOIN dbo.Chapters c ON c.ChapterID = s.ChapterID + INNER JOIN dbo.Books b ON b.BookID = c.BookID + LEFT JOIN dbo.AssetCustodyEventCharacters aec ON aec.AssetCustodyEventID = ace.AssetCustodyEventID + LEFT JOIN dbo.CustodyRoles cr ON cr.CustodyRoleID = aec.CustodyRoleID + WHERE ace.StoryAssetID = @StoryAssetID + GROUP BY ace.AssetCustodyEventID, ace.StoryAssetID, sa.AssetName, ace.SceneID, ace.AssetCustodyEventTypeID, acet.TypeName, ace.Description, ace.CreatedDate, ace.UpdatedDate, + b.BookID, b.BookNumber, b.BookTitle, b.Subtitle, c.ChapterID, c.ChapterNumber, s.SceneNumber, s.SceneTitle, b.SortOrder, c.SortOrder, s.SortOrder + ORDER BY b.SortOrder, c.SortOrder, s.SortOrder, ace.AssetCustodyEventID; +END; +GO + +CREATE OR ALTER PROCEDURE dbo.SceneAssetLocation_ListByAsset + @StoryAssetID int +AS +BEGIN + SET NOCOUNT ON; + + SELECT sal.SceneID, b.BookID, b.BookNumber, b.BookTitle, b.Subtitle AS BookSubtitle, c.ChapterID, c.ChapterNumber, s.SceneNumber, s.SceneTitle, + b.SortOrder AS BookSortOrder, c.SortOrder AS ChapterSortOrder, s.SortOrder AS SceneSortOrder, + N'Location' AS Title, location.LocationPath AS Detail, sal.Description + FROM dbo.SceneAssetLocations sal + INNER JOIN dbo.Scenes s ON s.SceneID = sal.SceneID + INNER JOIN dbo.Chapters c ON c.ChapterID = s.ChapterID + INNER JOIN dbo.Books b ON b.BookID = c.BookID + LEFT JOIN dbo.LocationPaths location ON location.LocationID = sal.LocationID + WHERE sal.StoryAssetID = @StoryAssetID + ORDER BY b.SortOrder, c.SortOrder, s.SortOrder, sal.SceneAssetLocationID; +END; +GO diff --git a/PlotLine/ViewModels/CoreViewModels.cs b/PlotLine/ViewModels/CoreViewModels.cs index 18bb17a9..d133cea9 100644 --- a/PlotLine/ViewModels/CoreViewModels.cs +++ b/PlotLine/ViewModels/CoreViewModels.cs @@ -1849,9 +1849,8 @@ public sealed class StoryAssetDetailViewModel public StoryAsset Asset { get; set; } = new(); public IReadOnlyList Aliases { get; set; } = []; public IReadOnlyList ProjectAssets { get; set; } = []; - public IReadOnlyList Events { get; set; } = []; + public IReadOnlyList SceneHistory { get; set; } = []; public IReadOnlyList Dependencies { get; set; } = []; - public IReadOnlyList CustodyEvents { get; set; } = []; public AssetDependencyEditViewModel NewDependency { get; set; } = new(); public IReadOnlyList AssetOptions { get; set; } = []; public IReadOnlyList AssetDependencyTypeOptions { get; set; } = []; diff --git a/PlotLine/Views/StoryAssets/Details.cshtml b/PlotLine/Views/StoryAssets/Details.cshtml index f011b42d..2353dce0 100644 --- a/PlotLine/Views/StoryAssets/Details.cshtml +++ b/PlotLine/Views/StoryAssets/Details.cshtml @@ -1,4 +1,5 @@ @model StoryAssetDetailViewModel +@using Microsoft.AspNetCore.Mvc.Rendering @{ ViewData["DesktopLayout"] = "details"; ViewData["Title"] = Model.Asset.AssetName; @@ -48,7 +49,7 @@
-

Current state

+

Saved asset state

@if (!string.IsNullOrWhiteSpace(Model.Asset.Description)) {

@Model.Asset.Description

@@ -58,6 +59,7 @@

Aliases: @string.Join(", ", Model.Aliases)

}

Importance: @Model.Asset.Importance / 10

+

Asset edits and scene records can update these saved values. They are independent of manuscript focus.

State: @(Model.Asset.CurrentStateName ?? "No state")

Location: @(Model.Asset.CurrentLocationPath ?? "No location")

Resolved: @(Model.Asset.IsResolved ? "Yes" : "No")

@@ -77,24 +79,7 @@ } else { -
- @foreach (var dependency in Model.Dependencies) - { -
- @dependency.SourceAssetName @dependency.DependencyTypeName.ToLowerInvariant() @dependency.TargetAssetName - @dependency.SourceRequiredStateName before @dependency.TargetBlockedStateName - @if (!string.IsNullOrWhiteSpace(dependency.Description)) - { - @dependency.Description - } -
- - - -
-
- } -
+ }
@@ -102,90 +87,30 @@
- - + +
- - -
-
- - -
-
- - -
-
- - -
-
- - + +
+
+ +
-
-

Events across scenes

- @if (!Model.Events.Any()) - { -

No scene events yet.

- } - else - { -
- @foreach (var assetEvent in Model.Events) - { -
- @assetEvent.MarkerText -
- @assetEvent.EventTitle - @assetEvent.BookDisplayTitle / Ch @assetEvent.ChapterNumber / Scene @assetEvent.SceneNumber: @assetEvent.SceneTitle - @assetEvent.FromStateName -> @assetEvent.ToStateName - Open in timeline -
-
- } -
- } -
- -
-

Custody

- @if (!Model.CustodyEvents.Any()) - { -

No custody events yet.

- } - else - { -
- @foreach (var custody in Model.CustodyEvents) - { -
- @custody.CustodyEventTypeName - @custody.CustodianSummary - @custody.BookDisplayTitle / Ch @custody.ChapterNumber / Scene @custody.SceneNumber: @custody.SceneTitle - Open in timeline -
- } -
- } -
+
@section Scripts { + + } diff --git a/PlotLine/Views/StoryAssets/_DependencyFields.cshtml b/PlotLine/Views/StoryAssets/_DependencyFields.cshtml new file mode 100644 index 00000000..809f9360 --- /dev/null +++ b/PlotLine/Views/StoryAssets/_DependencyFields.cshtml @@ -0,0 +1,41 @@ +@model (StoryAssetDetailViewModel Detail, AssetDependency? Dependency) +@using Microsoft.AspNetCore.Mvc.Rendering +@{ + var dependency = Model.Dependency; + var prefix = $"dependency-{dependency?.AssetDependencyID ?? 0}"; + + SelectList Options(IEnumerable items, int? selected, string? currentLabel) + { + var value = selected?.ToString(); + if (value != null && currentLabel != null && !items.Any(item => item.Value == value)) + { + items = items.Append(new SelectListItem(currentLabel, value)); + } + return new SelectList(items, nameof(SelectListItem.Value), nameof(SelectListItem.Text), value); + } +} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
diff --git a/PlotLine/Views/StoryAssets/_DependencyFlow.cshtml b/PlotLine/Views/StoryAssets/_DependencyFlow.cshtml new file mode 100644 index 00000000..95b01ce4 --- /dev/null +++ b/PlotLine/Views/StoryAssets/_DependencyFlow.cshtml @@ -0,0 +1,50 @@ +@model StoryAssetDetailViewModel + +
+
    + @foreach (var dependency in Model.Dependencies) + { + var sourceCurrent = dependency.SourceAssetID == Model.Asset.StoryAssetID; + var targetCurrent = dependency.TargetAssetID == Model.Asset.StoryAssetID; +
  • + +
    + @dependency.DependencyTypeName to + +
    + +
    + @if (dependency.SourceRequiredStateName is not null || dependency.TargetBlockedStateName is not null) + { + Source required state · @(dependency.SourceRequiredStateName ?? "Any") + Target blocked state · @(dependency.TargetBlockedStateName ?? "Any") + } + @if (!string.IsNullOrWhiteSpace(dependency.Description)) + { + @dependency.Description + } +
    +
    + Edit dependency +
    + + + + + +
    + + + +
    +
    +
  • + } +
+
diff --git a/PlotLine/Views/StoryAssets/_SceneHistory.cshtml b/PlotLine/Views/StoryAssets/_SceneHistory.cshtml new file mode 100644 index 00000000..01b0de5e --- /dev/null +++ b/PlotLine/Views/StoryAssets/_SceneHistory.cshtml @@ -0,0 +1,53 @@ +@model StoryAssetDetailViewModel +
+

Scene history

+ @if (Model.SceneHistory.Count == 0) + { +

No scene records yet.

+ } + else + { +
    + @foreach (var scene in Model.SceneHistory.GroupBy(item => item.SceneID)) + { + var first = scene.First(); +
  1. + + @first.BookDisplayTitle / Ch @first.ChapterNumber.ToString("G29") / Scene @first.SceneNumber.ToString("G29") · @first.SceneTitle + +
      + @foreach (var item in scene) + { +
    • + @item.Title + @if (!string.IsNullOrWhiteSpace(item.Detail)) + { + · @item.Detail + } + @if (!string.IsNullOrWhiteSpace(item.FromState) && !string.IsNullOrWhiteSpace(item.ToState) + && item.FromState != item.ToState) + { + · @item.FromState → @item.ToState + } + else if (!string.IsNullOrWhiteSpace(item.ToState)) + { + · State @item.ToState + } + else if (!string.IsNullOrWhiteSpace(item.FromState)) + { + · From @item.FromState + } + @if (!string.IsNullOrWhiteSpace(item.Description) && item.Description != item.Title) + { + · @item.Description + } +
    • + } +
    +
  2. + } +
+ } +
diff --git a/PlotLine/wwwroot/css/asset-details.css b/PlotLine/wwwroot/css/asset-details.css new file mode 100644 index 00000000..5db61b4b --- /dev/null +++ b/PlotLine/wwwroot/css/asset-details.css @@ -0,0 +1,83 @@ +.asset-dependency-viewport { + overflow: auto; + border: 1px solid var(--bs-border-color); + border-radius: .5rem; + background: var(--bs-body-bg); +} + +.asset-dependency-flow { + display: grid; + gap: 1rem; + margin: 0; + padding: .75rem; + min-width: 26rem; + list-style: none; +} + +.asset-dependency-edge { + display: grid; + grid-template-columns: minmax(8rem, 1fr) minmax(8rem, .65fr) minmax(8rem, 1fr); + align-items: center; +} + +.asset-dependency-connector { + display: grid; + gap: .3rem; + text-align: center; + padding: 0 .45rem; + font-size: .875rem; +} + +.asset-dependency-arrow { + position: relative; + border-top: 1px solid var(--bs-secondary-color); +} + +.asset-dependency-arrow::after { + content: ""; + position: absolute; + right: 0; + top: -.29rem; + width: .5rem; + height: .5rem; + border-top: 1px solid var(--bs-secondary-color); + border-right: 1px solid var(--bs-secondary-color); + transform: rotate(45deg); +} + +.asset-dependency-context, +.asset-dependency-edit { + grid-column: 1 / -1; +} + +.asset-dependency-context { + display: grid; + font-size: .875rem; + overflow-wrap: anywhere; +} + +.asset-dependency-context:not(:empty) { + margin-block-start: .35rem; +} + +.asset-dependency-edit { + padding: .55rem .75rem; + border: 1px solid var(--bs-border-color); + border-radius: .45rem; +} + +.asset-scene-history { + list-style: none; + padding-inline-start: .85rem; + border-inline-start: 2px solid var(--bs-border-color); +} + +.asset-scene-history > li + li { + margin-block-start: .7rem; +} + +.asset-scene-history ul { + padding-inline-start: 1.15rem; + margin-block-start: .2rem; + overflow-wrap: anywhere; +}