247 lines
14 KiB
Plaintext
247 lines
14 KiB
Plaintext
@model LocationDetailViewModel
|
||
@using System.Text.Json
|
||
@using PlotLine.Models
|
||
@{
|
||
ViewData["DesktopLayout"] = "details";
|
||
ViewData["Title"] = Model.Location.LocationName;
|
||
ViewData["ProjectSection"] = "Locations";
|
||
IReadOnlyList<(string Id, string Label)> tabs =
|
||
[("overview", "Overview"), ("reference", "Reference"), ("hierarchy", "Hierarchy"),
|
||
("relationships", "Relationships"), ("usage", "Usage"), ("spatial", "Spatial awareness")];
|
||
var requestedTab = ViewData["LocationTab"] as string;
|
||
var activeTab = tabs.Any(tab => tab.Id == requestedTab) ? requestedTab! : "overview";
|
||
var knownNames = Model.Aliases
|
||
.Select(x => x.Alias)
|
||
.Append(Model.Location.LocationName)
|
||
.Where(name => !string.IsNullOrWhiteSpace(name))
|
||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||
.OrderBy(name => !string.Equals(name, Model.Location.LocationName, StringComparison.OrdinalIgnoreCase))
|
||
.ThenBy(name => name, StringComparer.OrdinalIgnoreCase)
|
||
.ToList();
|
||
}
|
||
|
||
<nav data-pwa-identity class="breadcrumb-trail" aria-label="Breadcrumb">
|
||
<a asp-controller="Projects" asp-action="Index">Projects</a>
|
||
<a asp-controller="Projects" asp-action="Details" asp-route-id="@Model.Project.ProjectID">@Model.Project.ProjectName</a>
|
||
<a asp-action="Index" asp-route-projectId="@Model.Project.ProjectID">Locations</a>
|
||
<span>@Model.Location.LocationName</span>
|
||
</nav>
|
||
|
||
<partial name="_ProjectSectionNav" model="Model.Project" />
|
||
|
||
<div class="location-page">
|
||
<div data-pd-context="location" data-pd-context-id="@Model.Location.LocationID" data-pd-context-label="@Model.Location.LocationName" data-pwa-help class="page-heading compact">
|
||
<span class="visual-avatar visual-avatar--lg" data-reference-primary-preview hidden><img alt="" /></span>
|
||
<partial name="_LocationIdentity" model="@((Model.Location.LocationName, (string?)Model.Project.ProjectName, Model.Location.LocationPath, "locations.details"))" />
|
||
<div data-pwa-context="Manage" class="button-row">
|
||
<a class="btn btn-outline-primary" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID">All locations</a>
|
||
<div class="dropdown pw-actions">
|
||
<button class="btn pw-actions__toggle dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Tools</button>
|
||
<div class="dropdown-menu dropdown-menu-end">
|
||
<a class="dropdown-item" asp-action="Edit" asp-route-id="@Model.Location.LocationID">Edit location</a>
|
||
<a class="dropdown-item" asp-action="Merge" asp-route-id="@Model.Location.LocationID">Merge with another location</a>
|
||
<div class="dropdown-divider"></div>
|
||
<form asp-action="Archive" method="post" class="archive-button-form" data-confirm-message="Archive this location? This will hide it from active lists and timelines, but the data will be kept and can be restored later.">
|
||
<input type="hidden" name="id" value="@Model.Location.LocationID" />
|
||
<input type="hidden" name="projectId" value="@Model.Project.ProjectID" />
|
||
<button class="dropdown-item text-danger" type="submit">Archive Location</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
@if (TempData["LocationMessage"] is string locationMessage)
|
||
{
|
||
<span hidden data-toast-message="info">@locationMessage</span>
|
||
}
|
||
|
||
<partial name="_LocationTabs" model="@((tabs, activeTab))" />
|
||
<div class="tab-content">
|
||
<div class="tab-pane @(activeTab == "overview" ? "active" : null)" id="location-panel-overview" role="tabpanel"
|
||
aria-labelledby="location-tab-overview" tabindex="0">
|
||
<section class="edit-panel pd-record-panel">
|
||
<div class="row g-3">
|
||
<div class="col-md-4">
|
||
<p class="eyebrow">Type</p>
|
||
<p>@(Model.Location.LocationTypeName ?? "Not set")</p>
|
||
</div>
|
||
<div class="col-12">
|
||
<p class="eyebrow">Description</p>
|
||
<p>@(Model.Location.Description ?? "No description yet.")</p>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="edit-panel">
|
||
<h2>Known names</h2>
|
||
<div class="asset-mini-list">
|
||
@foreach (var name in knownNames)
|
||
{
|
||
var isPreferred = string.Equals(name, Model.Location.LocationName, StringComparison.OrdinalIgnoreCase);
|
||
<div class="asset-mini-item">
|
||
<strong>@name</strong>
|
||
@if (isPreferred)
|
||
{
|
||
<span class="status-pill">Preferred</span>
|
||
}
|
||
else
|
||
{
|
||
<form asp-action="SetPreferredName" method="post">
|
||
<input type="hidden" name="id" value="@Model.Location.LocationID" />
|
||
<input type="hidden" name="preferredName" value="@name" />
|
||
<button class="btn btn-outline-secondary btn-sm" type="submit">Set as preferred</button>
|
||
</form>
|
||
}
|
||
</div>
|
||
}
|
||
</div>
|
||
</section>
|
||
</div>
|
||
<div class="tab-pane @(activeTab == "reference" ? "active" : null)" id="location-panel-reference" role="tabpanel"
|
||
aria-labelledby="location-tab-reference" tabindex="0">
|
||
@await Component.InvokeAsync("StoryElementReferences", new { entityType = PlotLine.Data.StoryElementType.Location, entityId = Model.Location.LocationID })
|
||
</div>
|
||
<div class="tab-pane @(activeTab == "hierarchy" ? "active" : null)" id="location-panel-hierarchy" role="tabpanel"
|
||
aria-labelledby="location-tab-hierarchy" tabindex="0">
|
||
<section class="edit-panel" data-location-hierarchy>
|
||
<h2>Hierarchy</h2>
|
||
<div class="button-row mb-2">
|
||
<button type="button" class="btn btn-outline-secondary btn-sm" data-tree-zoom="0.8" aria-label="Zoom out">−</button>
|
||
<button type="button" class="btn btn-outline-secondary btn-sm" data-tree-zoom="1.25" aria-label="Zoom in">+</button>
|
||
<button type="button" class="btn btn-outline-secondary btn-sm" data-tree-fit>Fit</button>
|
||
<button type="button" class="btn btn-outline-secondary btn-sm" data-tree-centre>Centre on current location</button>
|
||
</div>
|
||
<div class="location-tree-viewport" tabindex="0" aria-label="Location hierarchy. Drag blank space or scroll to pan.">
|
||
<div class="location-tree-space"><div class="location-tree-graph"></div></div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
<div class="tab-pane @(activeTab == "relationships" ? "active" : null)" id="location-panel-relationships" role="tabpanel"
|
||
aria-labelledby="location-tab-relationships" tabindex="0">
|
||
<section class="edit-panel" data-location-matrix
|
||
data-read-url="@Url.Action("DetailRelationships", new { id = Model.Location.LocationID })"
|
||
data-write-url="@Url.Action("WriteDetailRelationship")">
|
||
<h2 id="location-relationships">Relationships <help-icon key="locations.relationships" /></h2>
|
||
@Html.AntiForgeryToken()
|
||
<div class="location-matrix-tools">
|
||
<label>Relationship type
|
||
<select class="form-select form-select-sm" data-matrix-filter><option value="">All types</option></select>
|
||
</label>
|
||
<label>Add a location to this matrix
|
||
<select class="form-select form-select-sm" data-matrix-add><option value="">Choose location</option></select>
|
||
</label>
|
||
</div>
|
||
<p class="small muted">Rows are the starting locations. Columns are the destinations. Select a cell to inspect both directions.</p>
|
||
<details class="mb-2">
|
||
<summary>Legend</summary>
|
||
<div class="location-matrix-legend" data-matrix-legend></div>
|
||
</details>
|
||
<p role="alert" data-matrix-error hidden></p>
|
||
<div class="location-matrix-scroll" tabindex="0" aria-label="Relationship matrix">
|
||
<table class="location-matrix-table" data-matrix-table aria-label="Location relationships"></table>
|
||
</div>
|
||
<div class="location-direction-panels mt-3" data-matrix-editor></div>
|
||
</section>
|
||
</div>
|
||
<div class="tab-pane @(activeTab == "usage" ? "active" : null)" id="location-panel-usage" role="tabpanel"
|
||
aria-labelledby="location-tab-usage" tabindex="0">
|
||
<section class="edit-panel">
|
||
<h2>Used here <help-icon key="locations.usedHere" /></h2>
|
||
<div class="row g-3">
|
||
@foreach (var kind in new[] { "Scenes", "Characters", "Assets" })
|
||
{
|
||
<div class="col-md-4">
|
||
<h3>@kind</h3>
|
||
@foreach (var book in Model.Usage.Where(entry => entry.Kind == kind).GroupBy(entry => entry.BookID))
|
||
{
|
||
<h4>@BookTitleFormatter.DisplayTitle(book.First().BookTitle, book.First().BookSubtitle)</h4>
|
||
@foreach (var chapter in book.GroupBy(entry => entry.ChapterID))
|
||
{
|
||
var header = chapter.First();
|
||
<h5>Chapter @header.ChapterNumber.ToString("g") · @header.ChapterTitle</h5>
|
||
<ul class="location-usage-list">
|
||
@foreach (var entry in chapter)
|
||
{
|
||
<li>
|
||
<a asp-controller="Timeline" asp-action="Index" asp-route-ProjectID="@Model.Project.ProjectID"
|
||
asp-route-BookID="@entry.BookID" asp-route-SelectedSceneID="@entry.SceneID" asp-route-FocusType="location"
|
||
asp-route-FocusID="@Model.Location.LocationID" asp-route-navigateFocus="true">Scene @entry.SceneNumber.ToString("g")</a>
|
||
<strong>@entry.Name</strong>
|
||
@if (!string.IsNullOrWhiteSpace(entry.Description))
|
||
{
|
||
<span class="muted">@entry.Description</span>
|
||
}
|
||
</li>
|
||
}
|
||
</ul>
|
||
}
|
||
}
|
||
@if (!Model.Usage.Any(entry => entry.Kind == kind))
|
||
{
|
||
<p class="muted">No @kind.ToLowerInvariant() recorded here.</p>
|
||
}
|
||
</div>
|
||
}
|
||
</div>
|
||
</section>
|
||
</div>
|
||
<div class="tab-pane @(activeTab == "spatial" ? "active" : null)" id="location-panel-spatial" role="tabpanel"
|
||
aria-labelledby="location-tab-spatial" tabindex="0">
|
||
<partial name="_LocationSpatialPreview" model="Model" />
|
||
<details class="edit-panel">
|
||
<summary>Geographical lookup</summary>
|
||
<div class="mt-2" data-geography-location="@Model.Location.LocationID" data-project-id="@Model.Project.ProjectID">
|
||
<p role="status" data-geography-status>Loading…</p>
|
||
<div data-geography-body></div>
|
||
</div>
|
||
@Html.AntiForgeryToken()
|
||
</details>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script type="application/json" id="location-detail-data">@Html.Raw(JsonSerializer.Serialize(new
|
||
{
|
||
Current = Model.Location.LocationID,
|
||
Model.Project.ProjectID,
|
||
Model.CanEdit,
|
||
Locations = Model.Locations.Append(Model.Location).DistinctBy(location => location.LocationID)
|
||
.Select(location => new
|
||
{
|
||
Id = location.LocationID,
|
||
Parent = location.ParentLocationID,
|
||
Name = location.LocationName,
|
||
Path = location.LocationPath,
|
||
HierarchyUrl = Url.Action("Details", new { id = location.LocationID, tab = "hierarchy" })
|
||
}),
|
||
Types = Model.RelationshipTypes.Select(type => new { Id = type.LocationRelationshipTypeID, Name = type.TypeName })
|
||
}, new JsonSerializerOptions(JsonSerializerDefaults.Web)))</script>
|
||
|
||
@section Scripts {
|
||
<link rel="stylesheet" href="~/css/floor-plan-workspace.css" asp-append-version="true" />
|
||
<link rel="stylesheet" href="~/css/location-details.css" asp-append-version="true" />
|
||
<script src="~/js/floor-plan-renderer.js" asp-append-version="true" defer></script>
|
||
<script src="~/js/location-details.js" asp-append-version="true" defer></script>
|
||
<script src="~/js/location-geography.js" asp-append-version="true" defer></script>
|
||
<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>
|
||
<script>
|
||
(() => {
|
||
const linkedTabs = {
|
||
"#location-relationships": "location-tab-relationships",
|
||
"#story-element-references": "location-tab-reference"
|
||
};
|
||
|
||
function openLinkedTab() {
|
||
const id = linkedTabs[window.location.hash];
|
||
const tab = id && document.getElementById(id);
|
||
if (tab) bootstrap.Tab.getOrCreateInstance(tab).show();
|
||
}
|
||
|
||
openLinkedTab();
|
||
window.addEventListener("hashchange", openLinkedTab);
|
||
})();
|
||
</script>
|
||
}
|