Refine asset dependency flow and scene history

This commit is contained in:
Codex 2026-12-06 15:50:41 +00:00
parent 85cc4b1358
commit 98838336a3
12 changed files with 498 additions and 95 deletions

View File

@ -121,7 +121,47 @@ public sealed class StoryAssetsController(IAssetService assets) : Controller
[ValidateAntiForgeryToken]
public async Task<IActionResult> 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<IActionResult> 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);
}

View File

@ -199,6 +199,7 @@ public interface IAssetRepository
Task<SceneAssetSuggestionReviewResult?> RejectSceneAssetSuggestionAsync(int suggestionId, int userId);
Task<IReadOnlyList<SceneAssetSuggestionCount>> CountSceneAssetSuggestionsByChapterAsync(int chapterId, int userId);
Task<IReadOnlyList<AssetDependency>> ListDependenciesByAssetAsync(int storyAssetId);
Task<IReadOnlyList<AssetSceneHistoryEntry>> ListLocationHistoryByAssetAsync(int storyAssetId);
Task<int> SaveDependencyAsync(AssetDependency dependency);
Task DeleteDependencyAsync(int assetDependencyId);
Task<IReadOnlyList<AssetCustodyEvent>> ListCustodyBySceneAsync(int sceneId);
@ -3593,6 +3594,14 @@ public sealed class AssetRepository(ISqlConnectionFactory connectionFactory) : I
return rows.ToList();
}
public async Task<IReadOnlyList<AssetSceneHistoryEntry>> ListLocationHistoryByAssetAsync(int storyAssetId)
{
using var connection = connectionFactory.CreateConnection();
var rows = await connection.QueryAsync<AssetSceneHistoryEntry>("dbo.SceneAssetLocation_ListByAsset",
new { StoryAssetID = storyAssetId }, commandType: CommandType.StoredProcedure);
return rows.ToList();
}
public async Task<int> SaveDependencyAsync(AssetDependency dependency)
{
using var connection = connectionFactory.CreateConnection();

View File

@ -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;

View File

@ -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<IReadOnlyList<AssetSceneHistoryEntry>> 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<int> SaveAssetAsync(StoryAssetEditViewModel model)
{
var isNew = model.StoryAssetID == 0;

View File

@ -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" }
};

View File

@ -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

View File

@ -1849,9 +1849,8 @@ public sealed class StoryAssetDetailViewModel
public StoryAsset Asset { get; set; } = new();
public IReadOnlyList<string> Aliases { get; set; } = [];
public IReadOnlyList<StoryAsset> ProjectAssets { get; set; } = [];
public IReadOnlyList<AssetEvent> Events { get; set; } = [];
public IReadOnlyList<AssetSceneHistoryEntry> SceneHistory { get; set; } = [];
public IReadOnlyList<AssetDependency> Dependencies { get; set; } = [];
public IReadOnlyList<AssetCustodyEvent> CustodyEvents { get; set; } = [];
public AssetDependencyEditViewModel NewDependency { get; set; } = new();
public IReadOnlyList<SelectListItem> AssetOptions { get; set; } = [];
public IReadOnlyList<SelectListItem> AssetDependencyTypeOptions { get; set; } = [];

View File

@ -1,4 +1,5 @@
@model StoryAssetDetailViewModel
@using Microsoft.AspNetCore.Mvc.Rendering
@{
ViewData["DesktopLayout"] = "details";
ViewData["Title"] = Model.Asset.AssetName;
@ -48,7 +49,7 @@
<div class="tab-pane @(activeTab == "overview" ? "active" : null)" id="asset-panel-overview" role="tabpanel"
aria-labelledby="asset-tab-overview" tabindex="0">
<article class="plain-card">
<h2>Current state <help-icon key="storyAssets.currentState" /></h2>
<h2>Saved asset state <help-icon key="storyAssets.currentState" /></h2>
@if (!string.IsNullOrWhiteSpace(Model.Asset.Description))
{
<p class="lead-text">@Model.Asset.Description</p>
@ -58,6 +59,7 @@
<p><strong>Aliases:</strong> @string.Join(", ", Model.Aliases)</p>
}
<p><strong>Importance:</strong> @Model.Asset.Importance / 10</p>
<p class="muted">Asset edits and scene records can update these saved values. They are independent of manuscript focus.</p>
<p><strong>State:</strong> @(Model.Asset.CurrentStateName ?? "No state")</p>
<p><strong>Location:</strong> @(Model.Asset.CurrentLocationPath ?? "No location")</p>
<p><strong>Resolved:</strong> @(Model.Asset.IsResolved ? "Yes" : "No")</p>
@ -77,24 +79,7 @@
}
else
{
<div class="asset-mini-list">
@foreach (var dependency in Model.Dependencies)
{
<div class="asset-mini-item">
<strong>@dependency.SourceAssetName @dependency.DependencyTypeName.ToLowerInvariant() @dependency.TargetAssetName</strong>
<span>@dependency.SourceRequiredStateName before @dependency.TargetBlockedStateName</span>
@if (!string.IsNullOrWhiteSpace(dependency.Description))
{
<span>@dependency.Description</span>
}
<form asp-action="DeleteDependency" method="post">
<input type="hidden" name="id" value="@dependency.AssetDependencyID" />
<input type="hidden" name="returnAssetId" value="@Model.Asset.StoryAssetID" />
<button class="btn btn-outline-secondary btn-sm" type="submit">Remove</button>
</form>
</div>
}
</div>
<partial name="_DependencyFlow" model="Model" />
}
<form asp-action="AddDependency" method="post" class="asset-create-form">
@ -102,90 +87,30 @@
<input type="hidden" name="returnAssetId" value="@Model.Asset.StoryAssetID" />
<div class="row g-2">
<div class="col-md-6">
<label class="form-label">Source asset <help-icon key="storyAssets.dependencies.sourceAsset" mode="inline" /></label>
<select class="form-select form-select-sm" name="SourceAssetID" asp-items="Model.AssetOptions"></select>
<label class="form-label" for="dependency-source">Source asset <help-icon key="storyAssets.dependencies.sourceAsset" mode="inline" /></label>
<select class="form-select form-select-sm" id="dependency-source" name="SourceAssetID" asp-items="@(new SelectList(Model.AssetOptions, "Value", "Text", Model.NewDependency.SourceAssetID.ToString()))" required></select>
</div>
<div class="col-md-6">
<label class="form-label">Target asset <help-icon key="storyAssets.dependencies.targetAsset" mode="inline" /></label>
<select class="form-select form-select-sm" name="TargetAssetID" asp-items="Model.AssetOptions"></select>
</div>
<div class="col-md-4">
<label class="form-label">Dependency <help-icon key="storyAssets.dependencies.dependencyType" mode="inline" /></label>
<select class="form-select form-select-sm" name="AssetDependencyTypeID" asp-items="Model.AssetDependencyTypeOptions"></select>
</div>
<div class="col-md-4">
<label class="form-label">Source required state <help-icon key="storyAssets.dependencies.sourceRequiredState" mode="inline" /></label>
<select class="form-select form-select-sm" name="SourceRequiredStateID" asp-items="Model.AssetStateOptions">
<option value="">Any</option>
</select>
</div>
<div class="col-md-4">
<label class="form-label">Target blocked state <help-icon key="storyAssets.dependencies.targetBlockedState" mode="inline" /></label>
<select class="form-select form-select-sm" name="TargetBlockedStateID" asp-items="Model.AssetStateOptions">
<option value="">Any</option>
</select>
</div>
<div class="col-12">
<label class="form-label">Description <help-icon key="storyAssets.dependencies.description" mode="inline" /></label>
<textarea class="form-control form-control-sm" name="Description" rows="2"></textarea>
<label class="form-label" for="dependency-target">Target asset <help-icon key="storyAssets.dependencies.targetAsset" mode="inline" /></label>
<select class="form-select form-select-sm" id="dependency-target" name="TargetAssetID" asp-items="@(new SelectList(Model.AssetOptions, "Value", "Text", Model.NewDependency.TargetAssetID.ToString()))" required></select>
</div>
</div>
<div class="mt-2">
<partial name="_DependencyFields" model="@((Model, (AssetDependency?)null))" />
</div>
<button class="btn btn-outline-primary btn-sm mt-2" type="submit">Add dependency</button>
</form>
</article>
</div>
<div class="tab-pane @(activeTab == "scene-history" ? "active" : null)" id="asset-panel-scene-history" role="tabpanel"
aria-labelledby="asset-tab-scene-history" tabindex="0">
<section class="list-section mt-3">
<h2>Events across scenes <help-icon key="storyAssets.eventsAcrossScenes" /></h2>
@if (!Model.Events.Any())
{
<p class="muted">No scene events yet.</p>
}
else
{
<div class="asset-mini-list">
@foreach (var assetEvent in Model.Events)
{
<div class="asset-mini-item story-asset-event-item">
<span class="asset-event-marker">@assetEvent.MarkerText</span>
<div class="story-asset-event-details">
<strong>@assetEvent.EventTitle</strong>
<span>@assetEvent.BookDisplayTitle / Ch @assetEvent.ChapterNumber / Scene @assetEvent.SceneNumber: @assetEvent.SceneTitle</span>
<span>@assetEvent.FromStateName -> @assetEvent.ToStateName</span>
<a asp-controller="Timeline" asp-action="Index" asp-route-ProjectID="@Model.Project.ProjectID" asp-route-SelectedSceneID="@assetEvent.SceneID" asp-route-FocusType="asset" asp-route-FocusID="@Model.Asset.StoryAssetID" asp-route-navigateFocus="true">Open in timeline</a>
</div>
</div>
}
</div>
}
</section>
<section class="list-section mt-3">
<h2>Custody <help-icon key="storyAssets.custody" /></h2>
@if (!Model.CustodyEvents.Any())
{
<p class="muted">No custody events yet.</p>
}
else
{
<div class="asset-mini-list">
@foreach (var custody in Model.CustodyEvents)
{
<div class="asset-mini-item">
<strong>@custody.CustodyEventTypeName</strong>
<span>@custody.CustodianSummary</span>
<span>@custody.BookDisplayTitle / Ch @custody.ChapterNumber / Scene @custody.SceneNumber: @custody.SceneTitle</span>
<a asp-controller="Timeline" asp-action="Index" asp-route-ProjectID="@Model.Project.ProjectID" asp-route-SelectedSceneID="@custody.SceneID" asp-route-FocusType="asset" asp-route-FocusID="@Model.Asset.StoryAssetID" asp-route-navigateFocus="true">Open in timeline</a>
</div>
}
</div>
}
</section>
<partial name="_SceneHistory" model="Model" />
</div>
</div>
@section Scripts {
<link rel="stylesheet" href="~/css/location-details.css" asp-append-version="true" />
<link rel="stylesheet" href="~/css/asset-details.css" asp-append-version="true" />
<link rel="stylesheet" href="~/css/story-element-references.css" asp-append-version="true" />
<script src="~/js/story-element-references.js" asp-append-version="true"></script>
}

View File

@ -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<SelectListItem> 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);
}
}
<div class="row g-2">
<div class="col-md-4">
<label class="form-label" for="@prefix-type">Dependency <help-icon key="storyAssets.dependencies.dependencyType" mode="inline" /></label>
<select id="@prefix-type" class="form-select form-select-sm" name="AssetDependencyTypeID" required
asp-items="Options(Model.Detail.AssetDependencyTypeOptions, dependency?.AssetDependencyTypeID ?? Model.Detail.NewDependency.AssetDependencyTypeID, dependency?.DependencyTypeName)"></select>
</div>
<div class="col-md-4">
<label class="form-label" for="@prefix-required">Source required state <help-icon key="storyAssets.dependencies.sourceRequiredState" mode="inline" /></label>
<select id="@prefix-required" class="form-select form-select-sm" name="SourceRequiredStateID"
asp-items="Options(Model.Detail.AssetStateOptions, dependency?.SourceRequiredStateID, dependency?.SourceRequiredStateName)">
<option value="">Any</option>
</select>
</div>
<div class="col-md-4">
<label class="form-label" for="@prefix-blocked">Target blocked state <help-icon key="storyAssets.dependencies.targetBlockedState" mode="inline" /></label>
<select id="@prefix-blocked" class="form-select form-select-sm" name="TargetBlockedStateID"
asp-items="Options(Model.Detail.AssetStateOptions, dependency?.TargetBlockedStateID, dependency?.TargetBlockedStateName)">
<option value="">Any</option>
</select>
</div>
<div class="col-12">
<label class="form-label" for="@prefix-description">Description <help-icon key="storyAssets.dependencies.description" mode="inline" /></label>
<textarea id="@prefix-description" class="form-control form-control-sm" name="Description" rows="2">@dependency?.Description</textarea>
</div>
</div>

View File

@ -0,0 +1,50 @@
@model StoryAssetDetailViewModel
<div class="asset-dependency-viewport" tabindex="0" aria-label="Dependency flow">
<ul class="asset-dependency-flow">
@foreach (var dependency in Model.Dependencies)
{
var sourceCurrent = dependency.SourceAssetID == Model.Asset.StoryAssetID;
var targetCurrent = dependency.TargetAssetID == Model.Asset.StoryAssetID;
<li class="asset-dependency-edge">
<div class="location-tree-node" data-current="@(sourceCurrent ? "true" : null)">
<a asp-action="Details" asp-route-id="@dependency.SourceAssetID" asp-route-tab="dependencies"
aria-current="@(sourceCurrent ? "page" : null)">@dependency.SourceAssetName</a>
</div>
<div class="asset-dependency-connector">
<span>@dependency.DependencyTypeName<span class="visually-hidden"> to</span></span>
<span class="asset-dependency-arrow" aria-hidden="true"></span>
</div>
<div class="location-tree-node" data-current="@(targetCurrent ? "true" : null)">
<a asp-action="Details" asp-route-id="@dependency.TargetAssetID" asp-route-tab="dependencies"
aria-current="@(targetCurrent ? "page" : null)">@dependency.TargetAssetName</a>
</div>
<div class="asset-dependency-context">
@if (dependency.SourceRequiredStateName is not null || dependency.TargetBlockedStateName is not null)
{
<span>Source required state · @(dependency.SourceRequiredStateName ?? "Any")</span>
<span>Target blocked state · @(dependency.TargetBlockedStateName ?? "Any")</span>
}
@if (!string.IsNullOrWhiteSpace(dependency.Description))
{
<span>@dependency.Description</span>
}
</div>
<details class="asset-dependency-edit mt-2">
<summary>Edit dependency</summary>
<form asp-action="EditDependency" method="post" class="mt-2">
<input type="hidden" name="id" value="@dependency.AssetDependencyID" />
<input type="hidden" name="returnAssetId" value="@Model.Asset.StoryAssetID" />
<partial name="_DependencyFields" model="@((Model, (AssetDependency?)dependency))" />
<button class="btn btn-outline-primary btn-sm mt-2" type="submit">Save dependency</button>
</form>
<form asp-action="DeleteDependency" method="post">
<input type="hidden" name="id" value="@dependency.AssetDependencyID" />
<input type="hidden" name="returnAssetId" value="@Model.Asset.StoryAssetID" />
<button class="btn btn-outline-secondary btn-sm mt-2" type="submit">Remove</button>
</form>
</details>
</li>
}
</ul>
</div>

View File

@ -0,0 +1,53 @@
@model StoryAssetDetailViewModel
<section class="list-section mt-3">
<h2>Scene history <help-icon key="storyAssets.eventsAcrossScenes" /></h2>
@if (Model.SceneHistory.Count == 0)
{
<p class="muted">No scene records yet.</p>
}
else
{
<ol class="asset-scene-history">
@foreach (var scene in Model.SceneHistory.GroupBy(item => item.SceneID))
{
var first = scene.First();
<li>
<a asp-controller="Timeline" asp-action="Index" asp-route-ProjectID="@Model.Project.ProjectID"
asp-route-SelectedSceneID="@scene.Key" asp-route-FocusType="asset"
asp-route-FocusID="@Model.Asset.StoryAssetID" asp-route-navigateFocus="true">
@first.BookDisplayTitle / Ch @first.ChapterNumber.ToString("G29") / Scene @first.SceneNumber.ToString("G29") · @first.SceneTitle
</a>
<ul>
@foreach (var item in scene)
{
<li>
<strong>@item.Title</strong>
@if (!string.IsNullOrWhiteSpace(item.Detail))
{
<span> · @item.Detail</span>
}
@if (!string.IsNullOrWhiteSpace(item.FromState) && !string.IsNullOrWhiteSpace(item.ToState)
&& item.FromState != item.ToState)
{
<span> · @item.FromState → @item.ToState</span>
}
else if (!string.IsNullOrWhiteSpace(item.ToState))
{
<span> · State @item.ToState</span>
}
else if (!string.IsNullOrWhiteSpace(item.FromState))
{
<span> · From @item.FromState</span>
}
@if (!string.IsNullOrWhiteSpace(item.Description) && item.Description != item.Title)
{
<span> · @item.Description</span>
}
</li>
}
</ul>
</li>
}
</ol>
}
</section>

View File

@ -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;
}