79 lines
3.7 KiB
Plaintext

@model (PlotLineListViewModel Lines, PlotThreadListViewModel Threads)
@{
ViewData["Title"] = "Plot Lines";
ViewData["ProjectSection"] = "Plot Lines";
var projectId = Model.Lines.Project.ProjectID;
var lines = Model.Lines.PlotLines;
var lineIds = lines.Select(line => line.PlotLineID).ToHashSet();
var children = lines.ToLookup(line => line.ParentPlotLineID);
var threads = Model.Threads.PlotThreads.ToLookup(thread => thread.PlotLineID);
var displayed = new HashSet<int>();
async Task RenderLineAsync(PlotLine.Models.PlotLineItem line)
{
if (!displayed.Add(line.PlotLineID))
{
return;
}
<details class="border rounded px-3 py-2 mb-2">
<summary data-planning-line="@line.PlotLineID">
<span class="colour-swatch" style="background-color:@line.Colour" aria-hidden="true"></span>
<strong>@line.PlotLineName</strong>
<small class="muted"> · @(line.BookID.HasValue ? line.BookTitle ?? "Book" : "Project-wide") · @line.PlotImportanceName</small>
</summary>
<div class="button-row my-2">
<a class="btn btn-outline-secondary btn-sm" asp-controller="PlotLines" asp-action="Edit" asp-route-id="@line.PlotLineID" data-planning-edit>Edit plot line</a>
<a class="btn btn-outline-secondary btn-sm" asp-controller="PlotThreads" asp-action="Create" asp-route-projectId="@projectId" asp-route-plotLineId="@line.PlotLineID" data-planning-add-thread>Add thread</a>
<a class="btn btn-outline-secondary btn-sm" asp-controller="Timeline" asp-action="Index" asp-route-projectId="@projectId" asp-route-FocusType="plotline" asp-route-FocusID="@line.PlotLineID">Focus scenes</a>
<form asp-controller="PlotLines" asp-action="Archive" method="post" class="archive-button-form" data-confirm-message="Archive this plot line? You can restore it from Archived Items.">
<input type="hidden" name="id" value="@line.PlotLineID" />
<input type="hidden" name="projectId" value="@projectId" />
<button class="btn btn-outline-danger btn-sm" type="submit">Archive</button>
</form>
</div>
@if (threads[line.PlotLineID].Any())
{
<ul class="list-unstyled ps-3 mb-2">
@foreach (var thread in threads[line.PlotLineID])
{
<li data-planning-thread>
<span class="colour-swatch" style="background-color:@line.Colour" aria-hidden="true"></span>
<a asp-controller="PlotThreads" asp-action="Edit" asp-route-id="@thread.PlotThreadID">@thread.ThreadTitle</a>
</li>
}
</ul>
}
@foreach (var child in children[line.PlotLineID])
{
await RenderLineAsync(child);
}
</details>
}
}
<div data-pwa-header class="page-heading">
<h1>Plot Lines <help-icon key="plotLines.index" /></h1>
</div>
<partial name="_PlanningRibbon" model="(projectId, (int?)null, true, lines.Count > 0)" />
@if (lines.Count == 0)
{
<p class="muted">No plot lines yet. Add a plot line to start planning.</p>
}
else
{
@foreach (var line in lines.Where(line => line.ParentPlotLineID is not int parent || !lineIds.Contains(parent)))
{
await RenderLineAsync(line);
}
@foreach (var line in lines.Where(line => !displayed.Contains(line.PlotLineID)))
{
await RenderLineAsync(line);
}
}
@section Scripts {
<script src="~/js/plot-line-manage.js" asp-append-version="true"></script>
}