diff --git a/PlotLine/Controllers/LocationsController.cs b/PlotLine/Controllers/LocationsController.cs index 1ec8a321..694029cf 100644 --- a/PlotLine/Controllers/LocationsController.cs +++ b/PlotLine/Controllers/LocationsController.cs @@ -28,8 +28,9 @@ public sealed class LocationsController(ILocationService locations, GeographicHi return model is null ? NotFound() : View(model); } - public async Task Details(int id) + public async Task 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 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" }); } } diff --git a/PlotLine/Controllers/StoryElementReferencesController.cs b/PlotLine/Controllers/StoryElementReferencesController.cs index b27be4de..c7dace12 100644 --- a/PlotLine/Controllers/StoryElementReferencesController.cs +++ b/PlotLine/Controllers/StoryElementReferencesController.cs @@ -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"); } diff --git a/PlotLine/Services/CoreServices.cs b/PlotLine/Services/CoreServices.cs index e47028ba..227a7184 100644 --- a/PlotLine/Services/CoreServices.cs +++ b/PlotLine/Services/CoreServices.cs @@ -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, diff --git a/PlotLine/ViewModels/CoreViewModels.cs b/PlotLine/ViewModels/CoreViewModels.cs index 7a22b4a7..507c076c 100644 --- a/PlotLine/ViewModels/CoreViewModels.cs +++ b/PlotLine/ViewModels/CoreViewModels.cs @@ -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; } diff --git a/PlotLine/Views/Locations/Details.cshtml b/PlotLine/Views/Locations/Details.cshtml index 753fe19c..de3c8416 100644 --- a/PlotLine/Views/Locations/Details.cshtml +++ b/PlotLine/Views/Locations/Details.cshtml @@ -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 @@ -
-
Geographical position: Loading…
-
-@Html.AntiForgeryToken() - -
-
-

Location detail

-

@Model.Location.LocationName

-

@Model.Location.LocationPath

-
+
All locations
-
-
-
-

Type

-

@(Model.Location.LocationTypeName ?? "Not set")

-
-
-

Parent

-

@(Model.Location.ParentLocationName ?? "Top level")

-
-
-

Description

-

@(Model.Location.Description ?? "No description yet.")

-
-
-
- - @await Component.InvokeAsync("StoryElementReferences", new { entityType = PlotLine.Data.StoryElementType.Location, entityId = Model.Location.LocationID }) - @if (TempData["LocationMessage"] is string locationMessage) { } -
-

Known names

-
- @foreach (var name in knownNames) - { - var isPreferred = string.Equals(name, Model.Location.LocationName, StringComparison.OrdinalIgnoreCase); -
- @name - @if (isPreferred) + +
+
+
+
+
+

Type

+

@(Model.Location.LocationTypeName ?? "Not set")

+
+
+

Description

+

@(Model.Location.Description ?? "No description yet.")

+
+
+
+ +
+

Known names

+
+ @foreach (var name in knownNames) + { + var isPreferred = string.Equals(name, Model.Location.LocationName, StringComparison.OrdinalIgnoreCase); +
+ @name + @if (isPreferred) + { + Preferred + } + else + { +
+ + + +
+ } +
+ } +
+
+
+
+ @await Component.InvokeAsync("StoryElementReferences", new { entityType = PlotLine.Data.StoryElementType.Location, entityId = Model.Location.LocationID }) +
+
+
+

Hierarchy

+

Parent

+

@(Model.Location.ParentLocationName ?? "Top level")

+

Child locations

+ @if (!Model.ChildLocations.Any()) { - Preferred +

No child locations yet.

} else { -
- - - -
- } -
- } -
-
- -
-

Child locations

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

No child locations yet.

- } - else - { -
- @foreach (var child in Model.ChildLocations) - { - @child.LocationName - } -
- } -
- -
-

Relationships

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

No relationships defined yet.

- } - else - { -
- @foreach (var relationship in Model.Relationships) - { -
-
- @relationship.FromLocationName - @relationship.RelationshipTypeName.ToLowerInvariant() - @relationship.ToLocationName - @if (relationship.IsBidirectional) +
+ @foreach (var child in Model.ChildLocations) { - both ways + @child.LocationName } -

@relationship.Notes

-
- - - -
+ } +
+
+
+
+

Relationships

+ @if (!Model.Relationships.Any()) + { +

No relationships defined yet.

+ } + else + { +
+ @foreach (var relationship in Model.Relationships) + { +
+
+ @relationship.FromLocationName + @relationship.RelationshipTypeName.ToLowerInvariant() + @relationship.ToLocationName + @if (relationship.IsBidirectional) + { + both ways + } +

@relationship.Notes

+
+
+ + + +
+
+ } +
+ } + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + + + + +
+
+ +
+
+ +
+
+
+
+
+

Used here

+
+
+

Scenes

+ @foreach (var scene in Model.Scenes) + { +

@SceneLabel(scene.ChapterNumber, scene.SceneNumber) @scene.SceneTitle

+ } + @if (!Model.Scenes.Any()) {

No scenes set here.

} +
+
+

Characters

+ @foreach (var character in Model.Characters) + { +

@character.CharacterName @SceneLabel(character.ChapterNumber, character.SceneNumber)

+ } + @if (!Model.Characters.Any()) {

No character placements yet.

} +
+
+

Assets

+ @foreach (var asset in Model.Assets) + { +

@asset.AssetName @asset.Description

+ } + @if (!Model.Assets.Any()) {

No asset placements yet.

} +
- } +
- } - -
- - -
-
- - -
-
- - -
-
- - -
-
- - - - - - -
-
- -
+
+
+

Geographical position

+

Loading…

+
+
+ @Html.AntiForgeryToken()
- - - - -
-

Used here

-
-
-

Scenes

- @foreach (var scene in Model.Scenes) - { -

@SceneLabel(scene.ChapterNumber, scene.SceneNumber) @scene.SceneTitle

- } - @if (!Model.Scenes.Any()) {

No scenes set here.

} -
-
-

Characters

- @foreach (var character in Model.Characters) - { -

@character.CharacterName @SceneLabel(character.ChapterNumber, character.SceneNumber)

- } - @if (!Model.Characters.Any()) {

No character placements yet.

} -
-
-

Assets

- @foreach (var asset in Model.Assets) - { -

@asset.AssetName @asset.Description

-} +
+
@functions { private static string SceneLabel(decimal chapterNumber, decimal sceneNumber) => chapterNumber > 0 ? $"Chapter {chapterNumber:g}, Scene {sceneNumber:g}" : $"Scene {sceneNumber:g}"; } - @if (!Model.Assets.Any()) {

No asset placements yet.

} -
-
- - @section Scripts { + + } diff --git a/PlotLine/Views/Locations/Edit.cshtml b/PlotLine/Views/Locations/Edit.cshtml index 4bfe354e..4f4addc8 100644 --- a/PlotLine/Views/Locations/Edit.cshtml +++ b/PlotLine/Views/Locations/Edit.cshtml @@ -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 @@ }
-
-

Location

-

@ViewData["Title"]

-
+ + @if (existing) + { + + }
-
+ + + - - -
-
Names
-
- - - -
-
- -
- @for (var i = 0; i < Model.Aliases.Count; i++) - { - - @Model.Aliases[i] - - - - } +
+ +
+
Names
+
+ + +
-
- - -
-
-
Hierarchy
-
- - -
-
- - -
-
-
- - -
Makes this item available as a draggable shortcut on the Timeline page.
-
-
-
Companion matching
-
-
-

Companion Detection

-
- - -
Use this for generic places that would create noisy suggestions, such as Home, Kitchen, Road or Shop.
+
+ +
+ @for (var i = 0; i < Model.Aliases.Count; i++) + { + + @Model.Aliases[i] + + + + }
- - - -
Higher values make this location stronger evidence in future Word Companion detection. The default is 50.
-
+
+ + +
+
+
+
+ + +
Makes this item available as a draggable shortcut on the Timeline page.
+
+
+
Companion matching
+
+
+

Companion Detection

+
+ + +
Use this for generic places that would create noisy suggestions, such as Home, Kitchen, Road or Shop.
+
+ + + +
Higher values make this location stronger evidence in future Word Companion detection. The default is 50.
+
+
+
+ + +
-
- - +
+
+
+
+ + +
+
+ + +
- Cancel + Cancel
+@if (existing) +{ +
+
+

Save any location changes before updating its references.

+ @await Component.InvokeAsync("StoryElementReferences", new { entityType = PlotLine.Data.StoryElementType.Location, entityId = Model.LocationID }) +
+
+} + @section Scripts { + +