Organize Location Details and Edit into entity tabs

This commit is contained in:
Codex 2026-12-05 17:44:29 +00:00
parent 73226c4fbd
commit 9e176c3348
10 changed files with 335 additions and 232 deletions

View File

@ -28,8 +28,9 @@ public sealed class LocationsController(ILocationService locations, GeographicHi
return model is null ? NotFound() : View(model);
}
public async Task<IActionResult> Details(int id)
public async Task<IActionResult> Details(int id, string? tab = null)
{
ViewData["LocationTab"] = tab;
var model = await locations.GetDetailAsync(id);
return model is null ? NotFound() : View(model);
}
@ -168,7 +169,7 @@ public sealed class LocationsController(ILocationService locations, GeographicHi
public async Task<IActionResult> AddRelationship(LocationRelationshipEditViewModel model)
{
await locations.SaveRelationshipAsync(model);
return RedirectToAction(nameof(Details), new { id = model.FromLocationID });
return RedirectToAction(nameof(Details), new { id = model.FromLocationID, tab = "relationships" });
}
[HttpPost]
@ -203,6 +204,6 @@ public sealed class LocationsController(ILocationService locations, GeographicHi
await locations.ArchiveRelationshipAsync(id);
if (location is not null) await savedData.Project(location.ProjectID, "locations", id, "Location Relationship");
TempData["ArchiveMessage"] = "Location relationship archived.";
return RedirectToAction(nameof(Details), new { id = returnLocationId });
return RedirectToAction(nameof(Details), new { id = returnLocationId, tab = "relationships" });
}
}

View File

@ -137,7 +137,7 @@ public sealed class StoryElementReferencesController(
private IActionResult Return(StoryElementReferenceScope scope, string? error = null)
{
if (error is not null) TempData["ReferenceError"] = error;
return RedirectToAction("Details", scope.DetailsController, new { id = scope.EntityID, tab = scope.EntityType == StoryElementType.Character ? "reference" : null },
return RedirectToAction("Details", scope.DetailsController, new { id = scope.EntityID, tab = scope.EntityType is StoryElementType.Character or StoryElementType.Location ? "reference" : null },
scope.EntityType == StoryElementType.Character && Request.Form["operation"] == "caption"
? "character-gallery" : "story-element-references");
}

View File

@ -8355,6 +8355,7 @@ public sealed class LocationService(
ProjectID = location.ProjectID,
ParentLocationID = location.ParentLocationID,
LocationName = location.LocationName,
LocationPath = location.LocationPath,
Aliases = (await locations.ListAliasesAsync(location.LocationID)).Select(x => x.Alias).ToList(),
LocationTypeID = location.LocationTypeID,
Description = location.Description,

View File

@ -2297,6 +2297,7 @@ public sealed class LocationEditViewModel
[Display(Name = "Location type")]
public int? LocationTypeID { get; set; }
public string? LocationPath { get; set; }
public string? Description { get; set; }
[Display(Name = "Show in Quick Add Bar")]
public bool ShowInQuickAddBar { get; set; }

View File

@ -3,7 +3,11 @@
ViewData["DesktopLayout"] = "details";
ViewData["Title"] = Model.Location.LocationName;
ViewData["ProjectSection"] = "Locations";
var firstScene = Model.Scenes.FirstOrDefault();
IReadOnlyList<(string Id, string Label)> tabs =
[("overview", "Overview"), ("reference", "Reference"), ("hierarchy", "Hierarchy"),
("relationships", "Relationships"), ("usage", "Usage"), ("geography", "Geography")];
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)
@ -23,19 +27,9 @@
<partial name="_ProjectSectionNav" model="Model.Project" />
<section class="edit-panel" data-geography-location="@Model.Location.LocationID" data-project-id="@Model.Project.ProjectID">
<details><summary>Geographical position: <span data-geography-status>Loading…</span></summary><div data-geography-body></div></details>
</section>
@Html.AntiForgeryToken()
<script src="~/js/location-geography.js" asp-append-version="true" defer></script>
<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">
<div>
<p class="eyebrow">Location detail</p>
<h1>@Model.Location.LocationName <help-icon key="locations.details" /></h1>
<p class="muted">@Model.Location.LocationPath</p>
</div>
<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">
@ -54,172 +48,212 @@
</div>
</div>
<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-md-4">
<p class="eyebrow">Parent</p>
<p>@(Model.Location.ParentLocationName ?? "Top level")</p>
</div>
<div class="col-12">
<p class="eyebrow">Description</p>
<p>@(Model.Location.Description ?? "No description yet.")</p>
</div>
</div>
</section>
@await Component.InvokeAsync("StoryElementReferences", new { entityType = PlotLine.Data.StoryElementType.Location, entityId = Model.Location.LocationID })
@if (TempData["LocationMessage"] is string locationMessage)
{
<span hidden data-toast-message="info">@locationMessage</span>
}
<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)
<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">
<h2>Hierarchy</h2>
<p class="eyebrow">Parent</p>
<p>@(Model.Location.ParentLocationName ?? "Top level")</p>
<h3>Child locations <help-icon key="locations.childLocations" /></h3>
@if (!Model.ChildLocations.Any())
{
<span class="status-pill">Preferred</span>
<p class="muted">No child locations yet.</p>
}
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>
<section class="edit-panel">
<h2>Child locations <help-icon key="locations.childLocations" /></h2>
@if (!Model.ChildLocations.Any())
{
<p class="muted">No child locations yet.</p>
}
else
{
<div class="location-chip-list">
@foreach (var child in Model.ChildLocations)
{
<a class="location-chip" asp-action="Details" asp-route-id="@child.LocationID">@child.LocationName</a>
}
</div>
}
</section>
<section class="edit-panel">
<h2 id="location-relationships">Relationships <help-icon key="locations.relationships" /></h2>
@if (!Model.Relationships.Any())
{
<p class="muted">No relationships defined yet.</p>
}
else
{
<div class="location-relationship-list">
@foreach (var relationship in Model.Relationships)
{
<div class="location-relationship-card">
<div>
<strong>@relationship.FromLocationName</strong>
<span>@relationship.RelationshipTypeName.ToLowerInvariant()</span>
<strong>@relationship.ToLocationName</strong>
@if (relationship.IsBidirectional)
<div class="location-chip-list">
@foreach (var child in Model.ChildLocations)
{
<span class="location-badge">both ways</span>
<a class="location-chip" asp-action="Details" asp-route-id="@child.LocationID">@child.LocationName</a>
}
<p class="muted">@relationship.Notes</p>
</div>
<form asp-action="ArchiveRelationship" method="post" data-confirm-message="Archive this location relationship?&#10;&#10;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="@relationship.LocationRelationshipID" />
<input type="hidden" name="returnLocationId" value="@Model.Location.LocationID" />
<button class="btn btn-outline-secondary btn-sm" type="submit">Archive</button>
</form>
}
</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">
<h2 id="location-relationships">Relationships <help-icon key="locations.relationships" /></h2>
@if (!Model.Relationships.Any())
{
<p class="muted">No relationships defined yet.</p>
}
else
{
<div class="location-relationship-list">
@foreach (var relationship in Model.Relationships)
{
<div class="location-relationship-card">
<div>
<strong>@relationship.FromLocationName</strong>
<span>@relationship.RelationshipTypeName.ToLowerInvariant()</span>
<strong>@relationship.ToLocationName</strong>
@if (relationship.IsBidirectional)
{
<span class="location-badge">both ways</span>
}
<p class="muted">@relationship.Notes</p>
</div>
<form asp-action="ArchiveRelationship" method="post" data-confirm-message="Archive this location relationship?&#10;&#10;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="@relationship.LocationRelationshipID" />
<input type="hidden" name="returnLocationId" value="@Model.Location.LocationID" />
<button class="btn btn-outline-secondary btn-sm" type="submit">Archive</button>
</form>
</div>
}
</div>
}
<form asp-action="AddRelationship" method="post" class="asset-create-form mt-3">
<input asp-for="NewRelationship.ProjectID" type="hidden" name="ProjectID" />
<input asp-for="NewRelationship.FromLocationID" type="hidden" name="FromLocationID" />
<div class="row g-2">
<div class="col-md-5">
<label class="form-label" for="ToLocationID">To location</label>
<select data-location-picker data-project-id="@Model.Project.ProjectID" data-exclude-id="@Model.Location.LocationID" data-picker-label="Choose related location" class="form-select form-select-sm" id="ToLocationID" name="ToLocationID" asp-items="Model.LocationOptions"></select>
</div>
<div class="col-md-4">
<label class="form-label" for="LocationRelationshipTypeID">Relationship</label>
<select class="form-select form-select-sm" id="LocationRelationshipTypeID" name="LocationRelationshipTypeID" asp-items="Model.RelationshipTypeOptions"></select>
</div>
<div class="col-md-3">
<label class="form-label" for="Strength">Strength</label>
<input class="form-control form-control-sm" id="Strength" name="Strength" type="number" min="1" max="10" />
</div>
<div class="col-12 location-flags">
<label><input type="checkbox" name="IsBidirectional" value="true" /> Bidirectional</label>
<label><input type="checkbox" name="CanHearNormalSpeech" value="true" /> Can hear normal speech</label>
<label><input type="checkbox" name="CanHearLoudNoise" value="true" /> Can hear loud noise</label>
<label><input type="checkbox" name="CanSeeMovement" value="true" /> Can see movement</label>
<label><input type="checkbox" name="CanSeeClearly" value="true" /> Can see clearly</label>
<label><input type="checkbox" name="CanTravelDirectly" value="true" /> Can travel directly</label>
</div>
<div class="col-12">
<textarea class="form-control form-control-sm" name="Notes" rows="2" placeholder="Relationship notes"></textarea>
</div>
</div>
<button class="btn btn-outline-primary btn-sm mt-2" type="submit">Add relationship</button>
</form>
</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">
<div class="col-md-4">
<h3>Scenes</h3>
@foreach (var scene in Model.Scenes)
{
<p><strong>@SceneLabel(scene.ChapterNumber, scene.SceneNumber)</strong> <a asp-controller="Timeline" asp-action="Index" asp-route-ProjectID="@Model.Project.ProjectID" asp-route-SelectedSceneID="@scene.SceneID" asp-route-FocusType="location" asp-route-FocusID="@Model.Location.LocationID" asp-route-navigateFocus="true">@scene.SceneTitle</a></p>
}
@if (!Model.Scenes.Any()) { <p class="muted">No scenes set here.</p> }
</div>
<div class="col-md-4">
<h3>Characters</h3>
@foreach (var character in Model.Characters)
{
<p><strong>@character.CharacterName</strong> <span class="muted">@SceneLabel(character.ChapterNumber, character.SceneNumber)</span></p>
}
@if (!Model.Characters.Any()) { <p class="muted">No character placements yet.</p> }
</div>
<div class="col-md-4">
<h3>Assets</h3>
@foreach (var asset in Model.Assets)
{
<p><strong>@asset.AssetName</strong> <span class="muted">@asset.Description</span></p>
}
@if (!Model.Assets.Any()) { <p class="muted">No asset placements yet.</p> }
</div>
</div>
}
</section>
</div>
}
<form asp-action="AddRelationship" method="post" class="asset-create-form mt-3">
<input asp-for="NewRelationship.ProjectID" type="hidden" name="ProjectID" />
<input asp-for="NewRelationship.FromLocationID" type="hidden" name="FromLocationID" />
<div class="row g-2">
<div class="col-md-5">
<label class="form-label" for="ToLocationID">To location</label>
<select data-location-picker data-project-id="@Model.Project.ProjectID" data-exclude-id="@Model.Location.LocationID" data-picker-label="Choose related location" class="form-select form-select-sm" id="ToLocationID" name="ToLocationID" asp-items="Model.LocationOptions"></select>
</div>
<div class="col-md-4">
<label class="form-label" for="LocationRelationshipTypeID">Relationship</label>
<select class="form-select form-select-sm" id="LocationRelationshipTypeID" name="LocationRelationshipTypeID" asp-items="Model.RelationshipTypeOptions"></select>
</div>
<div class="col-md-3">
<label class="form-label" for="Strength">Strength</label>
<input class="form-control form-control-sm" id="Strength" name="Strength" type="number" min="1" max="10" />
</div>
<div class="col-12 location-flags">
<label><input type="checkbox" name="IsBidirectional" value="true" /> Bidirectional</label>
<label><input type="checkbox" name="CanHearNormalSpeech" value="true" /> Can hear normal speech</label>
<label><input type="checkbox" name="CanHearLoudNoise" value="true" /> Can hear loud noise</label>
<label><input type="checkbox" name="CanSeeMovement" value="true" /> Can see movement</label>
<label><input type="checkbox" name="CanSeeClearly" value="true" /> Can see clearly</label>
<label><input type="checkbox" name="CanTravelDirectly" value="true" /> Can travel directly</label>
</div>
<div class="col-12">
<textarea class="form-control form-control-sm" name="Notes" rows="2" placeholder="Relationship notes"></textarea>
</div>
<div class="tab-pane @(activeTab == "geography" ? "active" : null)" id="location-panel-geography" role="tabpanel"
aria-labelledby="location-tab-geography" tabindex="0">
<section class="edit-panel" data-geography-location="@Model.Location.LocationID" data-project-id="@Model.Project.ProjectID">
<h2>Geographical position</h2>
<p role="status" data-geography-status>Loading…</p>
<div data-geography-body></div>
</section>
@Html.AntiForgeryToken()
</div>
<button class="btn btn-outline-primary btn-sm mt-2" type="submit">Add relationship</button>
</form>
</section>
<section class="edit-panel">
<h2>Used here <help-icon key="locations.usedHere" /></h2>
<div class="row g-3">
<div class="col-md-4">
<h3>Scenes</h3>
@foreach (var scene in Model.Scenes)
{
<p><strong>@SceneLabel(scene.ChapterNumber, scene.SceneNumber)</strong> <a asp-controller="Timeline" asp-action="Index" asp-route-ProjectID="@Model.Project.ProjectID" asp-route-SelectedSceneID="@scene.SceneID" asp-route-FocusType="location" asp-route-FocusID="@Model.Location.LocationID" asp-route-navigateFocus="true">@scene.SceneTitle</a></p>
}
@if (!Model.Scenes.Any()) { <p class="muted">No scenes set here.</p> }
</div>
<div class="col-md-4">
<h3>Characters</h3>
@foreach (var character in Model.Characters)
{
<p><strong>@character.CharacterName</strong> <span class="muted">@SceneLabel(character.ChapterNumber, character.SceneNumber)</span></p>
}
@if (!Model.Characters.Any()) { <p class="muted">No character placements yet.</p> }
</div>
<div class="col-md-4">
<h3>Assets</h3>
@foreach (var asset in Model.Assets)
{
<p><strong>@asset.AssetName</strong> <span class="muted">@asset.Description</span></p>
}
</div>
</div>
@functions {
private static string SceneLabel(decimal chapterNumber, decimal sceneNumber)
=> chapterNumber > 0 ? $"Chapter {chapterNumber:g}, Scene {sceneNumber:g}" : $"Scene {sceneNumber:g}";
}
@if (!Model.Assets.Any()) { <p class="muted">No asset placements yet.</p> }
</div>
</div>
</section>
</div>
@section Scripts {
<script src="~/js/location-geography.js" asp-append-version="true" defer></script>
<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>
}

View File

@ -1,8 +1,12 @@
@model LocationEditViewModel
@{
ViewData["DesktopLayout"] = "wide";
ViewData["DesktopLayout"] = "details";
ViewData["Title"] = Model.LocationID == 0 ? "New Location" : "Edit Location";
ViewData["ProjectSection"] = "Locations";
var existing = Model.LocationID > 0;
IReadOnlyList<(string Id, string Label)> tabs = existing
? [("overview", "Overview"), ("reference", "Reference"), ("hierarchy", "Hierarchy")]
: [("overview", "Overview"), ("hierarchy", "Hierarchy")];
}
@if (Model.Project is not null)
@ -18,90 +22,126 @@
}
<div data-pwa-task class="page-heading compact">
<div>
<p class="eyebrow">Location</p>
<h1>@ViewData["Title"] <help-icon key="locations.edit" /></h1>
</div>
<partial name="_LocationIdentity" model="@((existing ? Model.LocationName : "New Location", Model.Project?.ProjectName, Model.LocationPath, "locations.edit"))" />
@if (existing)
{
<div class="button-row">
<a class="btn btn-outline-primary" asp-action="Details" asp-route-id="@Model.LocationID">View location</a>
</div>
}
</div>
<form asp-action="Save" method="post" class="edit-panel pd-record-form">
<partial name="_LocationTabs" model="@((tabs, "overview"))" />
<form asp-action="Save" method="post" class="edit-panel pd-record-form tab-content location-record-form">
<input asp-for="LocationID" type="hidden" />
<input asp-for="ProjectID" type="hidden" />
<div asp-validation-summary="ModelOnly" class="text-danger" role="alert"></div>
<div class="row g-3 pd-record-fields">
<div class="pd-record-group-label" role="heading" aria-level="2">Names</div>
<div class="col-md-8 pd-record-span-6">
<label asp-for="LocationName" class="form-label"></label>
<input asp-for="LocationName" class="form-control" />
<span asp-validation-for="LocationName" class="text-danger"></span>
</div>
<div class="col-12 pd-record-span-6">
<label class="form-label">Known names</label>
<div class="d-flex flex-wrap gap-2 mb-2" data-alias-list>
@for (var i = 0; i < Model.Aliases.Count; i++)
{
<span class="badge rounded-pill text-bg-light border d-inline-flex align-items-center gap-2">
<span>@Model.Aliases[i]</span>
<button class="btn-close btn-close-sm" type="button" aria-label="Remove @Model.Aliases[i]" data-remove-alias></button>
<input type="hidden" name="Aliases" value="@Model.Aliases[i]" />
</span>
}
<div class="tab-pane active" id="location-panel-overview" role="tabpanel"
aria-labelledby="location-tab-overview" tabindex="0">
<div asp-validation-summary="All" class="text-danger" role="alert"></div>
<div class="row g-3 pd-record-fields">
<div class="pd-record-group-label" role="heading" aria-level="2">Names</div>
<div class="col-md-8 pd-record-span-6">
<label asp-for="LocationName" class="form-label"></label>
<input asp-for="LocationName" class="form-control" />
<span asp-validation-for="LocationName" class="text-danger"></span>
</div>
<div class="input-group">
<input class="form-control" type="text" maxlength="200" placeholder="Add another name" data-alias-input />
<button class="btn btn-outline-secondary" type="button" data-add-alias>Add</button>
</div>
</div>
<div class="pd-record-group-label" role="heading" aria-level="2">Hierarchy</div>
<div class="col-md-4 pd-record-span-6">
<label asp-for="LocationTypeID" class="form-label">Location type <help-icon key="locations.fields.locationType" mode="inline" /></label>
<select data-location-type-picker asp-for="LocationTypeID" asp-items="Model.LocationTypeOptions" class="form-select">
<option value="">Not set</option>
</select>
</div>
<div class="col-12 pd-record-span-6">
<label asp-for="ParentLocationID" class="form-label">Parent location <help-icon key="locations.fields.parentLocation" mode="inline" /></label>
<select data-location-picker data-project-id="@Model.ProjectID" data-exclude-branch="@Model.LocationID" data-allow-root="true" data-picker-label="Choose parent location" asp-for="ParentLocationID" asp-items="Model.ParentLocationOptions" class="form-select">
<option value="">Top level</option>
</select>
</div>
<div class="col-12 pd-record-span-12">
<div class="form-check">
<input asp-for="ShowInQuickAddBar" class="form-check-input" />
<label asp-for="ShowInQuickAddBar" class="form-check-label">Show in Quick Add Bar <help-icon key="locations.fields.quickAdd" mode="inline" /></label>
<div class="form-text">Makes this item available as a draggable shortcut on the Timeline page.</div>
</div>
</div>
<div class="pd-record-group-label" role="heading" aria-level="2">Companion matching</div>
<div class="col-12 pd-record-span-12">
<section class="list-section p-3">
<h2 class="h5">Companion Detection</h2>
<div class="form-check mb-3">
<input asp-for="ExcludeFromCompanionDetection" class="form-check-input" />
<label asp-for="ExcludeFromCompanionDetection" class="form-check-label"></label>
<div class="form-text">Use this for generic places that would create noisy suggestions, such as Home, Kitchen, Road or Shop.</div>
<div class="col-12 pd-record-span-6">
<label class="form-label">Known names</label>
<div class="d-flex flex-wrap gap-2 mb-2" data-alias-list>
@for (var i = 0; i < Model.Aliases.Count; i++)
{
<span class="badge rounded-pill text-bg-light border d-inline-flex align-items-center gap-2">
<span>@Model.Aliases[i]</span>
<button class="btn-close btn-close-sm" type="button" aria-label="Remove @Model.Aliases[i]" data-remove-alias></button>
<input type="hidden" name="Aliases" value="@Model.Aliases[i]" />
</span>
}
</div>
<label asp-for="DetectionPriority" class="form-label"></label>
<input asp-for="DetectionPriority" class="form-control form-control-sm" type="number" min="0" max="1000" />
<span asp-validation-for="DetectionPriority" class="text-danger"></span>
<div class="form-text">Higher values make this location stronger evidence in future Word Companion detection. The default is 50.</div>
</section>
<div class="input-group">
<input class="form-control" type="text" maxlength="200" placeholder="Add another name" data-alias-input />
<button class="btn btn-outline-secondary" type="button" data-add-alias>Add</button>
</div>
</div>
<div class="col-12 pd-record-span-12">
<div class="form-check">
<input asp-for="ShowInQuickAddBar" class="form-check-input" />
<label asp-for="ShowInQuickAddBar" class="form-check-label">Show in Quick Add Bar <help-icon key="locations.fields.quickAdd" mode="inline" /></label>
<div class="form-text">Makes this item available as a draggable shortcut on the Timeline page.</div>
</div>
</div>
<div class="pd-record-group-label" role="heading" aria-level="2">Companion matching</div>
<div class="col-12 pd-record-span-12">
<section class="list-section p-3">
<h2 class="h5">Companion Detection</h2>
<div class="form-check mb-3">
<input asp-for="ExcludeFromCompanionDetection" class="form-check-input" />
<label asp-for="ExcludeFromCompanionDetection" class="form-check-label"></label>
<div class="form-text">Use this for generic places that would create noisy suggestions, such as Home, Kitchen, Road or Shop.</div>
</div>
<label asp-for="DetectionPriority" class="form-label"></label>
<input asp-for="DetectionPriority" class="form-control form-control-sm" type="number" min="0" max="1000" />
<span asp-validation-for="DetectionPriority" class="text-danger"></span>
<div class="form-text">Higher values make this location stronger evidence in future Word Companion detection. The default is 50.</div>
</section>
</div>
<div class="col-12 pd-record-span-12">
<label asp-for="Description" class="form-label"></label>
<textarea asp-for="Description" class="form-control" rows="5"></textarea>
</div>
</div>
<div class="col-12 pd-record-span-12">
<label asp-for="Description" class="form-label"></label>
<textarea asp-for="Description" class="form-control" rows="5"></textarea>
</div>
<div class="tab-pane" id="location-panel-hierarchy" role="tabpanel"
aria-labelledby="location-tab-hierarchy" tabindex="0">
<div class="row g-3 pd-record-fields">
<div class="col-md-4 pd-record-span-6">
<label asp-for="LocationTypeID" class="form-label">Location type <help-icon key="locations.fields.locationType" mode="inline" /></label>
<select data-location-type-picker asp-for="LocationTypeID" asp-items="Model.LocationTypeOptions" class="form-select">
<option value="">Not set</option>
</select>
</div>
<div class="col-12 pd-record-span-6">
<label asp-for="ParentLocationID" class="form-label">Parent location <help-icon key="locations.fields.parentLocation" mode="inline" /></label>
<select data-location-picker data-project-id="@Model.ProjectID" data-exclude-branch="@Model.LocationID" data-allow-root="true" data-picker-label="Choose parent location" asp-for="ParentLocationID" asp-items="Model.ParentLocationOptions" class="form-select">
<option value="">Top level</option>
</select>
</div>
</div>
</div>
<div data-pwa-context="Record" data-pwa-priority="0" class="button-row mt-3">
<button class="btn btn-primary" data-pwa-icon="save" type="submit">Save location</button>
<a class="btn btn-outline-secondary" data-pwa-icon="close" asp-action="Index" asp-route-projectId="@Model.ProjectID">Cancel</a>
<a class="btn btn-outline-secondary" data-pwa-icon="close" asp-action="@(existing ? "Details" : "Index")" asp-route-id="@(existing ? Model.LocationID : (int?)null)" asp-route-projectId="@(existing ? (int?)null : Model.ProjectID)">Cancel</a>
</div>
</form>
@if (existing)
{
<div class="tab-content">
<div class="tab-pane" id="location-panel-reference" role="tabpanel"
aria-labelledby="location-tab-reference" tabindex="0">
<p class="muted">Save any location changes before updating its references.</p>
@await Component.InvokeAsync("StoryElementReferences", new { entityType = PlotLine.Data.StoryElementType.Location, entityId = Model.LocationID })
</div>
</div>
}
@section Scripts {
<partial name="_ValidationScriptsPartial" />
<script src="~/js/story-element-references.js" asp-append-version="true"></script>
<script>
$(function () {
const form = $(".location-record-form");
const validator = form.data("validator");
if (!validator) return;
// Overview fields must still be validated when saving from Hierarchy.
validator.settings.ignore = "input[type=hidden]";
form.on("invalid-form.validate", () => {
bootstrap.Tab.getOrCreateInstance(document.getElementById("location-tab-overview")).show();
});
});
</script>
<script>
(() => {
const list = document.querySelector("[data-alias-list]");

View File

@ -0,0 +1,10 @@
@model (string Name, string? ProjectName, string? Path, string HelpKey)
<div>
<p class="eyebrow">@(Model.ProjectName is string projectName ? $"{projectName} · Location" : "Location")</p>
<h1>@Model.Name <help-icon key="@Model.HelpKey" /></h1>
@if (!string.IsNullOrWhiteSpace(Model.Path))
{
<p class="muted">@Model.Path</p>
}
</div>

View File

@ -0,0 +1,12 @@
@model (IReadOnlyList<(string Id, string Label)> Tabs, string ActiveTab)
<nav class="nav nav-tabs mb-3" role="tablist" aria-label="Location workspace">
@foreach (var tab in Model.Tabs)
{
var active = tab.Id == Model.ActiveTab;
<button class="nav-link @(active ? "active" : null)" id="location-tab-@tab.Id"
type="button" role="tab" data-bs-toggle="tab" data-bs-target="#location-panel-@tab.Id"
aria-controls="location-panel-@tab.Id" aria-selected="@(active ? "true" : "false")"
tabindex="@(active ? null : "-1")">@tab.Label</button>
}
</nav>

View File

@ -8,9 +8,9 @@
["entityId"] = scope.EntityID.ToString()
};
var isCharacter = scope.EntityType == StoryElementType.Character;
var refreshUrl = isCharacter
? Url.Action("Details", "Characters", new { id = scope.EntityID, tab = "reference" }, protocol: null, host: null, fragment: "story-element-references")
: Url.Action("Details", scope.DetailsController, new { id = scope.EntityID }, protocol: null, host: null, fragment: "story-element-references");
var referenceTab = scope.EntityType is StoryElementType.Character or StoryElementType.Location ? "reference" : null;
var refreshUrl = Url.Action("Details", scope.DetailsController, new { id = scope.EntityID, tab = referenceTab },
protocol: null, host: null, fragment: "story-element-references");
}
<section id="story-element-references" class="list-section mt-3" aria-labelledby="story-element-reference-title"
data-story-element-references data-project-id="@Model.Access.ProjectID"

View File

@ -61,3 +61,7 @@ html[data-standalone="true"] .pd-record-canvas { overflow-wrap: anywhere; }
max-width: none;
padding-inline: 1rem;
}
.location-record-form:not(:has(> .tab-pane.active)) {
display: none;
}