Alphabetize named choices across PlotDirector

This commit is contained in:
Codex 2026-12-05 23:55:08 +00:00
parent bd3a2deb33
commit a25c120048
12 changed files with 122 additions and 41 deletions

View File

@ -55,6 +55,8 @@ public sealed class ContextCharacterEditing(ICharacterService characters,IStoryC
if(field=="location"){
var library=await locations.ListByProjectAsync(book.ProjectID);
options=[new("No recorded location",""),..library.Where(l=>l.ProjectID==book.ProjectID&&!l.IsArchived)
.OrderBy(l => l.LocationName, StringComparer.CurrentCultureIgnoreCase)
.ThenBy(l => l.LocationPath, StringComparer.CurrentCultureIgnoreCase)
.Select(l=>new SelectListItem(string.IsNullOrWhiteSpace(l.LocationPath)?l.LocationName:l.LocationPath,l.LocationID.ToString()))];
}
var hash=appearance!=null?Hash(new{appearance.SceneCharacterID,appearance.SceneID,appearance.CharacterID,appearance.RoleInSceneTypeID,appearance.PresenceTypeID,appearance.LocationID,appearance.EntryLocationID,appearance.ExitLocationID,appearance.AppearanceNotes,appearance.OutfitDescription,appearance.EmotionalState,appearance.PhysicalCondition,appearance.KnowledgeNotes}):Hash(new{character.CharacterID,character.CharacterName,character.Aliases,character.CharacterImportance,character.DefaultDescription,character.SexValueID,character.Sex,character.BirthDate,character.IsDeceased,character.AgeAtSeriesStart,character.Height,character.EyeColour,character.ShowInQuickAddBar,character.ImagePath,character.ThumbnailPath,AliasRecords=aliases});

View File

@ -42,7 +42,7 @@ public sealed class ContextRelationshipEditing(ICharacterRepository repository,I
var form=new ContextRelationshipForm{BookID=bookId,SceneID=sceneId,RelationshipID=relationshipId,Mode=mode,ReferenceLens=referenceLens,SourceID=relation?.CharacterAID??0,TargetID=relation?.CharacterBID??0,TypeID=relation?.RelationshipTypeID??0,StateID=state??0,
Intensity=mode=="initial"?relation?.InitialIntensity:change?.Intensity??projected?.CurrentIntensity,Mutual=relation?.IsReciprocal??false,Known=mode=="initial"?relation?.ReaderInitiallyKnows??false:change?.IsKnownToOtherCharacter??false,
Notes=mode=="initial"?relation?.Notes:change?.Description,Label=mode=="initial"?(referenceLens=="family"?"Author-established initial family connection":"Initial relationship (before scene developments)"):"Relationship development at "+(data.Scenes.FirstOrDefault(s=>s.SceneID==sceneId)?.SceneTitle??"the selected scene"),
Characters=data.Characters.Where(c=>!c.IsArchived).OrderBy(c=>c.CharacterName).Select(c=>new SelectListItem(c.CharacterName,c.CharacterID.ToString())).ToList(),
Characters=data.Characters.Where(c=>!c.IsArchived).OrderBy(c => c.CharacterName, StringComparer.CurrentCultureIgnoreCase).Select(c=>new SelectListItem(c.CharacterName,c.CharacterID.ToString())).ToList(),
Types=lookups.RelationshipTypes.Where(t=>(t.IsActive||t.RelationshipTypeID==relation?.RelationshipTypeID)&&(referenceLens!="family"||ContextRelationshipLenses.Family(t.RelationshipCategoryName,t.TypeName))).Select(t=>new SelectListItem(t.RelationshipCategoryName+" · "+t.TypeName,t.RelationshipTypeID.ToString())).ToList(),
States=lookups.RelationshipStates.Where(s=>s.IsActive||s.RelationshipStateID==state).Select(s=>new SelectListItem(s.StateName,s.RelationshipStateID.ToString())).ToList()};
form.Fingerprint=Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new{relation,Events=data.RelationshipEvents.Where(e=>e.CharacterRelationshipID==relationshipId).ToList(),Matches=data.Relationships.Select(r=>new{r.CharacterRelationshipID,r.CharacterAID,r.CharacterBID,r.RelationshipTypeID,r.IsReciprocal,r.IsArchived})}))));

View File

@ -45,7 +45,7 @@ public sealed class ContextThreads(ContextSpatial spatial, IPlotLineWorkspaceRep
associations.Contains((t.PlotThreadID, scope.SceneID)),
scope.CanEdit && directLinks.Contains((t.PlotThreadID, scope.SceneID)),
scenes.Values.Where(s => s.NarrativeOrder < current.NarrativeOrder && associations.Contains((t.PlotThreadID, s.SceneID)))
.OrderBy(s => s.NarrativeOrder).ToArray())).OrderBy(t => t.PlotLineName).ThenBy(t => t.Title).ToArray();
.OrderBy(s => s.NarrativeOrder).ToArray())).OrderBy(t => t.PlotLineName, StringComparer.CurrentCultureIgnoreCase).ThenBy(t => t.Title, StringComparer.CurrentCultureIgnoreCase).ToArray();
return new(scope, rows);
}

View File

@ -1745,7 +1745,7 @@ public sealed class ChapterService(
PendingCharacterSuggestionCount = sceneRows.Sum(x => x.PendingCharacterSuggestionCount),
PendingAssetSuggestionCount = sceneRows.Sum(x => x.PendingAssetSuggestionCount),
PendingLocationSuggestionCount = sceneRows.Sum(x => x.PendingLocationSuggestionCount),
CharacterOptions = ToOptionalSelectList(await characters.ListCharactersAsync(project.ProjectID), x => x.CharacterID, x => x.CharacterName),
CharacterOptions = ToOptionalSelectList((await characters.ListCharactersAsync(project.ProjectID)).OrderBy(x => x.CharacterName, StringComparer.CurrentCultureIgnoreCase), x => x.CharacterID, x => x.CharacterName),
PovDisplayLabel = BuildChapterPovDisplay(chapter, sceneRows)
};
}
@ -1770,7 +1770,7 @@ public sealed class ChapterService(
RevisionStatusID = DefaultRevisionStatusId(lookupData),
RevisionStatuses = ToSelectList(lookupData.RevisionStatuses, x => x.RevisionStatusID, x => x.StatusName),
ChapterPurposes = ToOptionalSelectList(lookupData.ChapterPurposeTypes, x => x.ChapterPurposeID, x => x.PurposeName),
CharacterOptions = ToOptionalSelectList(await characters.ListCharactersAsync(project.ProjectID), x => x.CharacterID, x => x.CharacterName)
CharacterOptions = ToOptionalSelectList((await characters.ListCharactersAsync(project.ProjectID)).OrderBy(x => x.CharacterName, StringComparer.CurrentCultureIgnoreCase), x => x.CharacterID, x => x.CharacterName)
};
}
@ -1810,7 +1810,7 @@ public sealed class ChapterService(
Project = project,
RevisionStatuses = ToSelectList(lookupData.RevisionStatuses, x => x.RevisionStatusID, x => x.StatusName),
ChapterPurposes = ToOptionalSelectList(lookupData.ChapterPurposeTypes, x => x.ChapterPurposeID, x => x.PurposeName),
CharacterOptions = ToOptionalSelectList(await characters.ListCharactersAsync(project.ProjectID), x => x.CharacterID, x => x.CharacterName)
CharacterOptions = ToOptionalSelectList((await characters.ListCharactersAsync(project.ProjectID)).OrderBy(x => x.CharacterName, StringComparer.CurrentCultureIgnoreCase), x => x.CharacterID, x => x.CharacterName)
};
}
@ -2158,8 +2158,10 @@ public sealed class SceneService(
model.ReturnBookID ??= model.Book?.BookID;
var plotLookups = await plots.GetLookupsAsync();
var plotLines = await plots.ListPlotLinesAsync(model.Project.ProjectID);
var plotThreads = await plots.ListPlotThreadsByProjectAsync(model.Project.ProjectID);
var plotLines = (await plots.ListPlotLinesAsync(model.Project.ProjectID))
.OrderBy(x => x.PlotLineName, StringComparer.CurrentCultureIgnoreCase).ToList();
var plotThreads = (await plots.ListPlotThreadsByProjectAsync(model.Project.ProjectID))
.OrderBy(x => x.PlotLineName, StringComparer.CurrentCultureIgnoreCase).ThenBy(x => x.PlotLineID).ThenBy(x => x.ThreadTitle, StringComparer.CurrentCultureIgnoreCase).ToList();
var assetLookups = await assets.GetLookupsAsync();
var projectAssets = await assets.ListAssetsAsync(model.Project.ProjectID);
var characterLookups = await characters.GetLookupsAsync();
@ -2202,13 +2204,13 @@ public sealed class SceneService(
model.ThreadTypeOptions = ToOptionalSelectList(plotLookups.ThreadTypes, x => x.ThreadTypeID, x => x.TypeName);
model.ThreadEventTypeOptions = ChapterService.ToSelectList(plotLookups.ThreadEventTypes, x => x.ThreadEventTypeID, x => x.TypeName);
model.PlotEventTypeOptions = ChapterService.ToSelectList(plotLookups.PlotEventTypes, x => x.PlotEventTypeID, x => x.TypeName);
model.AssetOptions = ToOptionalSelectList(projectAssets, x => x.StoryAssetID, x => x.AssetName);
model.AssetOptions = ToOptionalSelectList(projectAssets.OrderBy(x => x.AssetName, StringComparer.CurrentCultureIgnoreCase), x => x.StoryAssetID, x => x.AssetName);
model.AssetKindOptions = ChapterService.ToSelectList(assetLookups.AssetKinds, x => x.AssetKindID, x => x.KindName);
model.AssetStateOptions = ToOptionalSelectList(assetLookups.AssetStates, x => x.AssetStateID, x => x.StateName);
model.AssetEventTypeOptions = ChapterService.ToSelectList(assetLookups.AssetEventTypes, x => x.AssetEventTypeID, x => x.TypeName);
model.AssetCustodyEventTypeOptions = ChapterService.ToSelectList(assetLookups.AssetCustodyEventTypes, x => x.AssetCustodyEventTypeID, x => x.TypeName);
model.CustodyRoleOptions = ChapterService.ToSelectList(assetLookups.CustodyRoles, x => x.CustodyRoleID, x => x.RoleName);
model.CharacterOptions = ToOptionalSelectList(projectCharacters, x => x.CharacterID, x => x.CharacterName);
model.CharacterOptions = ToOptionalSelectList(projectCharacters.OrderBy(x => x.CharacterName, StringComparer.CurrentCultureIgnoreCase), x => x.CharacterID, x => x.CharacterName);
model.CharacterRoleOptions = ToOptionalSelectList(characterLookups.RoleTypes, x => x.CharacterRoleInSceneTypeID, x => x.TypeName);
model.PresenceTypeOptions = ToOptionalSelectList(characterLookups.PresenceTypes, x => x.PresenceTypeID, x => x.TypeName);
model.CharacterAttributeTypeOptions = ChapterService.ToSelectList(characterLookups.AttributeTypes, x => x.CharacterAttributeTypeID, x => x.AttributeName);
@ -2216,7 +2218,8 @@ public sealed class SceneService(
model.RelationshipOptions = ToOptionalSelectList(projectRelationships, x => x.CharacterRelationshipID, x => $"{x.CharacterAName} -> {x.CharacterBName} ({x.RelationshipTypeName})");
model.RelationshipTypeOptions = ToRelationshipTypeSelectList(characterLookups.RelationshipTypes);
model.RelationshipStateOptions = ChapterService.ToSelectList(characterLookups.RelationshipStates, x => x.RelationshipStateID, x => x.StateName);
model.LocationOptions = ToOptionalSelectList(projectLocations, x => x.LocationID, x => new string(' ', x.Depth * 2) + x.LocationName);
model.LocationOptions = ToOptionalSelectList(projectLocations.OrderBy(x => x.LocationName, StringComparer.CurrentCultureIgnoreCase).ThenBy(x => x.LocationPath, StringComparer.CurrentCultureIgnoreCase),
x => x.LocationID, x => string.IsNullOrWhiteSpace(x.LocationPath) ? x.LocationName : x.LocationPath);
model.SceneOptions = ToOptionalSelectList(allSceneOptions.Where(x => x.SceneID != model.SceneID), x => x.SceneID, x => $"{x.BookDisplayTitle} / Ch {x.ChapterNumber} / Scene {x.SceneNumber}: {x.SceneTitle}");
model.ChapterOptions = ChapterService.ToSelectList(chapterOptions, x => x.ChapterID, x => $"{x.BookDisplayTitle} / Chapter {x.ChapterNumber}: {x.ChapterTitle}");
model.SceneDependencyTypeOptions = ChapterService.ToSelectList(dependencyLookups.DependencyTypes, x => x.SceneDependencyTypeID, x => x.TypeName);
@ -2715,9 +2718,10 @@ public sealed class TimelineService(
SceneOptions = orderedScenes.Select(x => new SelectListItem($"Scene {x.SceneNumber}: {x.SceneTitle}", x.SceneID.ToString())).ToList(),
SceneFromOptions = orderedScenes.Select(x => new SelectListItem($"Scene {x.SceneNumber}: {x.SceneTitle}", x.SceneID.ToString(), x.SceneID == filter.SceneFromID)).ToList(),
SceneToOptions = orderedScenes.Select(x => new SelectListItem($"Scene {x.SceneNumber}: {x.SceneTitle}", x.SceneID.ToString(), x.SceneID == filter.SceneToID)).ToList(),
PlotLineOptions = plotLines.Select(x => new SelectListItem(x.PlotLineName, x.PlotLineID.ToString(), x.PlotLineID == filter.PlotLineID)).ToList(),
PlotThreadOptions = plotThreads.Select(x => new SelectListItem(x.ThreadTitle, x.PlotThreadID.ToString(), x.PlotThreadID == filter.PlotThreadID)).ToList(),
AssetOptions = allAssets.Select(x => new SelectListItem(x.AssetName, x.StoryAssetID.ToString(), x.StoryAssetID == filter.StoryAssetID)).ToList(),
PlotLineOptions = plotLines.OrderBy(x => x.PlotLineName, StringComparer.CurrentCultureIgnoreCase).Select(x => new SelectListItem(x.PlotLineName, x.PlotLineID.ToString(), x.PlotLineID == filter.PlotLineID)).ToList(),
PlotThreadOptions = plotThreads.OrderBy(x => x.PlotLineName, StringComparer.CurrentCultureIgnoreCase).ThenBy(x => x.PlotLineID).ThenBy(x => x.ThreadTitle, StringComparer.CurrentCultureIgnoreCase)
.Select(x => new SelectListItem($"{x.PlotLineName}: {x.ThreadTitle}", x.PlotThreadID.ToString(), x.PlotThreadID == filter.PlotThreadID)).ToList(),
AssetOptions = allAssets.OrderBy(x => x.AssetName, StringComparer.CurrentCultureIgnoreCase).Select(x => new SelectListItem(x.AssetName, x.StoryAssetID.ToString(), x.StoryAssetID == filter.StoryAssetID)).ToList(),
QuickAddAssets = allAssets
.Where(x => x.ShowInQuickAddBar)
.OrderByDescending(x => x.Importance)
@ -2726,7 +2730,7 @@ public sealed class TimelineService(
AssetEventTypeOptions = ChapterService.ToSelectList(assetLookupData.AssetEventTypes, x => x.AssetEventTypeID, x => x.TypeName),
AssetStateOptions = assetLookupData.AssetStates.Select(x => new SelectListItem(x.StateName, x.AssetStateID.ToString())).ToList(),
AssetDependencyTypeOptions = ChapterService.ToSelectList(assetLookupData.AssetDependencyTypes, x => x.AssetDependencyTypeID, x => x.TypeName),
CharacterOptions = allCharacters.Select(x => new SelectListItem(x.CharacterName, x.CharacterID.ToString(), x.CharacterID == filter.CharacterID)).ToList(),
CharacterOptions = allCharacters.OrderBy(x => x.CharacterName, StringComparer.CurrentCultureIgnoreCase).Select(x => new SelectListItem(x.CharacterName, x.CharacterID.ToString(), x.CharacterID == filter.CharacterID)).ToList(),
QuickAddCharacters = allCharacters
.Where(x => x.ShowInQuickAddBar)
.OrderByDescending(x => x.CharacterImportance ?? 0)
@ -2734,8 +2738,9 @@ public sealed class TimelineService(
.ToList(),
CharacterRoleOptions = characterLookupData.RoleTypes.Select(x => new SelectListItem(x.TypeName, x.CharacterRoleInSceneTypeID.ToString())).ToList(),
PresenceTypeOptions = characterLookupData.PresenceTypes.Select(x => new SelectListItem(x.TypeName, x.PresenceTypeID.ToString())).ToList(),
PovCharacterOptions = allCharacters.Select(x => new SelectListItem(x.CharacterName, x.CharacterID.ToString(), x.CharacterID == filter.POVCharacterID)).ToList(),
LocationOptions = allLocations.Select(x => new SelectListItem(x.LocationPath, x.LocationID.ToString(), x.LocationID == filter.LocationID)).ToList(),
PovCharacterOptions = allCharacters.OrderBy(x => x.CharacterName, StringComparer.CurrentCultureIgnoreCase).Select(x => new SelectListItem(x.CharacterName, x.CharacterID.ToString(), x.CharacterID == filter.POVCharacterID)).ToList(),
LocationOptions = allLocations.OrderBy(x => x.LocationName, StringComparer.CurrentCultureIgnoreCase).ThenBy(x => x.LocationPath, StringComparer.CurrentCultureIgnoreCase)
.Select(x => new SelectListItem(string.IsNullOrWhiteSpace(x.LocationPath) ? x.LocationName : x.LocationPath, x.LocationID.ToString(), x.LocationID == filter.LocationID)).ToList(),
QuickAddLocations = allLocations
.Where(x => x.ShowInQuickAddBar)
.OrderBy(x => x.LocationPath)
@ -3495,9 +3500,10 @@ public sealed partial class StoryStateService(
BookOptions = timeline.Books.Select(x => new SelectListItem($"Book {x.BookNumber}: {x.BookDisplayTitle}", x.BookID.ToString(), x.BookID == filter.BookID)).ToList(),
ChapterOptions = timeline.Chapters.Select(x => new SelectListItem($"Ch {x.ChapterNumber}: {x.ChapterTitle}", x.ChapterID.ToString(), x.ChapterID == filter.ChapterID)).ToList(),
SceneOptions = orderedScenes.Select(x => new SelectListItem($"Scene {x.SceneNumber:g}: {x.SceneTitle}", x.SceneID.ToString(), x.SceneID == filter.SelectedSceneID)).ToList(),
CharacterOptions = allCharacters.Select(x => new SelectListItem(x.CharacterName, x.CharacterID.ToString(), filter.CharacterIDs.Contains(x.CharacterID))).ToList(),
AssetOptions = allAssets.Select(x => new SelectListItem(x.AssetName, x.StoryAssetID.ToString(), filter.AssetIDs.Contains(x.StoryAssetID))).ToList(),
LocationOptions = allLocations.Select(x => new SelectListItem(x.LocationPath, x.LocationID.ToString(), filter.LocationIDs.Contains(x.LocationID))).ToList()
CharacterOptions = allCharacters.OrderBy(x => x.CharacterName, StringComparer.CurrentCultureIgnoreCase).Select(x => new SelectListItem(x.CharacterName, x.CharacterID.ToString(), filter.CharacterIDs.Contains(x.CharacterID))).ToList(),
AssetOptions = allAssets.OrderBy(x => x.AssetName, StringComparer.CurrentCultureIgnoreCase).Select(x => new SelectListItem(x.AssetName, x.StoryAssetID.ToString(), filter.AssetIDs.Contains(x.StoryAssetID))).ToList(),
LocationOptions = allLocations.OrderBy(x => x.LocationName, StringComparer.CurrentCultureIgnoreCase).ThenBy(x => x.LocationPath, StringComparer.CurrentCultureIgnoreCase)
.Select(x => new SelectListItem(string.IsNullOrWhiteSpace(x.LocationPath) ? x.LocationName : x.LocationPath, x.LocationID.ToString(), filter.LocationIDs.Contains(x.LocationID))).ToList()
};
if (string.Equals(filter.DisplayMode, "StoryState", StringComparison.OrdinalIgnoreCase) && filter.SelectedSceneID.HasValue)
@ -5183,7 +5189,7 @@ public sealed class PlotService(IProjectRepository projects, IBookRepository boo
model.BookOptions = (await books.ListByProjectAsync(model.ProjectID))
.Select(x => new SelectListItem($"Book {x.BookNumber}: {x.BookDisplayTitle}", x.BookID.ToString()))
.ToList();
model.ParentPlotLineOptions = parentCandidates
model.ParentPlotLineOptions = parentCandidates.OrderBy(x => x.PlotLineName, StringComparer.CurrentCultureIgnoreCase)
.Select(x => new SelectListItem(x.PlotLineName, x.PlotLineID.ToString()))
.ToList();
return model;
@ -5192,7 +5198,7 @@ public sealed class PlotService(IProjectRepository projects, IBookRepository boo
private async Task<PlotThreadEditViewModel> PopulatePlotThreadListsAsync(PlotThreadEditViewModel model, PlotLookupData lookupData)
{
var plotLines = await plots.ListPlotLinesAsync(model.ProjectID);
model.PlotLineOptions = ChapterService.ToSelectList(plotLines, x => x.PlotLineID, x => x.PlotLineName);
model.PlotLineOptions = ChapterService.ToSelectList(plotLines.OrderBy(x => x.PlotLineName, StringComparer.CurrentCultureIgnoreCase), x => x.PlotLineID, x => x.PlotLineName);
model.ThreadTypeOptions = ChapterService.ToSelectList(lookupData.ThreadTypes, x => x.ThreadTypeID, x => x.TypeName);
model.ThreadStatusOptions = ChapterService.ToSelectList(lookupData.ThreadStatuses, x => x.ThreadStatusID, x => x.StatusName);
model.SceneOptions = (await plots.ListSceneOptionsAsync(model.ProjectID))
@ -6008,7 +6014,7 @@ public sealed class RelationshipMapService(IProjectRepository projects, ICharact
BookOptions = data.Books.OrderBy(x => x.SortOrder).ThenBy(x => x.BookNumber).Select(x => new SelectListItem($"Book {x.BookNumber}: {x.BookDisplayTitle}", x.BookID.ToString(), x.BookID == point.BookID)).ToList(),
ChapterOptions = data.Chapters.OrderBy(x => BookSort(data, x.BookID)).ThenBy(x => x.SortOrder).Select(x => new SelectListItem($"Ch {x.ChapterNumber}: {x.ChapterTitle}", x.ChapterID.ToString(), x.ChapterID == point.ChapterID)).ToList(),
SceneOptions = data.Scenes.OrderBy(x => SceneIndex(sceneOrder, x.SceneID)).Select(x => new SelectListItem($"Ch {ChapterNumber(data, x.ChapterID)} / Scene {x.SceneNumber}: {x.SceneTitle}", x.SceneID.ToString(), x.SceneID == point.SceneID)).ToList(),
CharacterOptions = data.Characters.OrderBy(x => x.CharacterName).Select(x => new SelectListItem(x.CharacterName, x.CharacterID.ToString(), x.CharacterID == focusCharacterId)).ToList(),
CharacterOptions = data.Characters.OrderBy(x => x.CharacterName, StringComparer.CurrentCultureIgnoreCase).Select(x => new SelectListItem(x.CharacterName, x.CharacterID.ToString(), x.CharacterID == focusCharacterId)).ToList(),
Categories = data.RelationshipCategories.OrderBy(x => x.SortOrder).Select(x => new RelationshipMapCategoryViewModel
{
RelationshipCategoryID = x.RelationshipCategoryID,
@ -6192,7 +6198,7 @@ public sealed class WriterWorkspaceService(
return new WriterDashboardViewModel
{
ProjectID = projectId,
ProjectOptions = projectRows.Select(x => new SelectListItem(x.ProjectName, x.ProjectID.ToString(), x.ProjectID == projectId)).ToList(),
ProjectOptions = projectRows.OrderBy(x => x.ProjectName, StringComparer.CurrentCultureIgnoreCase).Select(x => new SelectListItem(x.ProjectName, x.ProjectID.ToString(), x.ProjectID == projectId)).ToList(),
WriteNext = await GetDashboardScenesAsync(projectIds, "WriteNext", bookId),
ContinueWriting = await GetDashboardScenesAsync(projectIds, "ContinueWriting", bookId),
RevisionQueue = await GetDashboardScenesAsync(projectIds, "RevisionQueue", bookId),
@ -6615,7 +6621,7 @@ public sealed class WritingScheduleService(
? []
: await books.ListByProjectAsync(selectedProject.ProjectID);
model.ProjectOptions = projectRows
model.ProjectOptions = projectRows.OrderBy(x => x.ProjectName, StringComparer.CurrentCultureIgnoreCase)
.Select(x => new SelectListItem(x.ProjectName, x.ProjectID.ToString(), x.ProjectID == model.ProjectID))
.ToList();
model.BookOptions = bookRows
@ -8282,7 +8288,8 @@ public sealed class AssetService(
=> states.Select(x => new SelectListItem(x.StateName, x.AssetStateID.ToString())).ToList();
private static IReadOnlyList<SelectListItem> ToOptionalLocationList(IEnumerable<LocationItem> items)
=> items.Select(x => new SelectListItem(new string(' ', x.Depth * 2) + x.LocationName, x.LocationID.ToString())).ToList();
=> items.OrderBy(x => x.LocationName, StringComparer.CurrentCultureIgnoreCase).ThenBy(x => x.LocationPath, StringComparer.CurrentCultureIgnoreCase)
.Select(x => new SelectListItem(string.IsNullOrWhiteSpace(x.LocationPath) ? x.LocationName : x.LocationPath, x.LocationID.ToString())).ToList();
}
public sealed class LocationService(
@ -8308,8 +8315,9 @@ public sealed class LocationService(
Form = new EntityMergeForm { SourceID = sourceId },
TargetOptions = (await locations.ListByProjectAsync(source.ProjectID))
.Where(x => x.LocationID != sourceId && !x.IsArchived)
.OrderBy(x => x.LocationName, StringComparer.OrdinalIgnoreCase)
.Select(x => new SelectListItem(x.LocationName, x.LocationID.ToString())).ToList()
.OrderBy(x => x.LocationName, StringComparer.CurrentCultureIgnoreCase)
.ThenBy(x => x.LocationPath, StringComparer.CurrentCultureIgnoreCase)
.Select(x => new SelectListItem(string.IsNullOrWhiteSpace(x.LocationPath) ? x.LocationName : x.LocationPath, x.LocationID.ToString())).ToList()
};
}
@ -8717,7 +8725,8 @@ public sealed class FloorPlanService(
PositionWithinLocation = FloorPlanTransitionPositions.Centre
},
LocationOptions = ToOptionalLocationOptions(projectLocations, "Create/link automatically"),
Locations = projectLocations,
Locations = projectLocations.OrderBy(x => x.LocationName, StringComparer.CurrentCultureIgnoreCase)
.ThenBy(x => x.LocationPath, StringComparer.CurrentCultureIgnoreCase).ToList(),
BlockTypeOptions = FloorPlanBlockTypes.All.Select(x => new SelectListItem(BlockTypeLabel(x), x)).ToList(),
TransitionTypeOptions = FloorPlanTransitionTypes.All.Select(x => new SelectListItem(x, x)).ToList(),
OccupancyScenes = occupancyScenes
@ -9652,7 +9661,8 @@ public sealed class FloorPlanService(
private static IReadOnlyList<SelectListItem> ToOptionalLocationOptions(IEnumerable<LocationItem> projectLocations, string emptyLabel)
{
var items = new List<SelectListItem> { new(emptyLabel, string.Empty) };
items.AddRange(projectLocations.Select(x => new SelectListItem(string.IsNullOrWhiteSpace(x.LocationPath) ? x.LocationName : x.LocationPath, x.LocationID.ToString())));
items.AddRange(projectLocations.OrderBy(x => x.LocationName, StringComparer.CurrentCultureIgnoreCase).ThenBy(x => x.LocationPath, StringComparer.CurrentCultureIgnoreCase)
.Select(x => new SelectListItem(string.IsNullOrWhiteSpace(x.LocationPath) ? x.LocationName : x.LocationPath, x.LocationID.ToString())));
return items;
}
}
@ -9799,7 +9809,7 @@ public sealed class CharacterService(
ReaderInitiallyKnows = true,
IsReciprocal = true
},
CharacterOptions = projectCharacters.Select(x => new SelectListItem(x.CharacterName, x.CharacterID.ToString())).ToList(),
CharacterOptions = projectCharacters.OrderBy(x => x.CharacterName, StringComparer.CurrentCultureIgnoreCase).Select(x => new SelectListItem(x.CharacterName, x.CharacterID.ToString())).ToList(),
RelationshipTypeOptions = ToRelationshipTypeSelectList(relationshipLookups.RelationshipTypes),
RelationshipStateOptions = relationshipLookups.RelationshipStates.Select(x => new SelectListItem(x.StateName, x.RelationshipStateID.ToString())).ToList(),
BookOptions = projectBooks.Select(x => new SelectListItem($"Book {x.BookNumber}: {x.BookDisplayTitle}", x.BookID.ToString())).ToList(),

View File

@ -257,7 +257,8 @@
.Where(x => x.LocationID.HasValue)
.GroupBy(x => x.LocationID!.Value)
.Select(x => x.First())
.OrderBy(x => x.LocationName)
.OrderBy(x => x.LocationName, StringComparer.CurrentCultureIgnoreCase)
.ThenBy(x => x.LocationPath, StringComparer.CurrentCultureIgnoreCase)
.ToList();
var floorTransitions = transitionsByFloor.GetValueOrDefault(floor.FloorPlanFloorID) ?? [];
<div class="floor-plan-transition-editor @(isActive ? string.Empty : "d-none")" data-transition-editor="@floor.FloorPlanFloorID">
@ -731,7 +732,8 @@
.Where(x => x.LocationID.HasValue)
.GroupBy(x => x.LocationID!.Value)
.Select(x => x.First())
.OrderBy(x => x.LocationName)
.OrderBy(x => x.LocationName, StringComparer.CurrentCultureIgnoreCase)
.ThenBy(x => x.LocationPath, StringComparer.CurrentCultureIgnoreCase)
.ToList();
<div class="modal fade" id="edit-transition-@transition.FloorPlanTransitionID" tabindex="-1" aria-labelledby="edit-transition-title-@transition.FloorPlanTransitionID" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">

View File

@ -13,7 +13,7 @@
<section id="mapsApp" class="maps-app" aria-label="Maps workspace">
<header class="maps-toolbar">
<h1>Maps <help-icon key="maps.workspace" /></h1>
<form id="mapsSelectorForm" data-pwa-context="Map" data-pwa-scope="Map"><label>Map <select id="mapsSelect" name="map" aria-label="Current map"><option value="">All maps</option>@foreach(var map in Model.Maps){<option value="@map.MapID" selected="@(map.MapID == Model.Document?.Map.MapID)">@map.Name @(map.ParentMapID.HasValue ? "↳" : "")</option>}</select></label></form>
<form id="mapsSelectorForm" data-pwa-context="Map" data-pwa-scope="Map"><label>Map <select id="mapsSelect" name="map" aria-label="Current map"><option value="">All maps</option>@foreach(var map in Model.Maps.OrderBy(map => map.Name, StringComparer.CurrentCultureIgnoreCase)){<option value="@map.MapID" selected="@(map.MapID == Model.Document?.Map.MapID)">@map.Name @(map.ParentMapID.HasValue ? "↳" : "")</option>}</select></label></form>
<div data-pwa-context="Mode" data-pwa-essential="true" role="group" aria-label="Map mode"><button type="button" data-mode="create" aria-pressed="true">Create</button><button type="button" data-mode="explore" aria-pressed="false">Explore</button><button type="button" data-mode="story" aria-pressed="false">Story</button></div>
<form class="maps-find" id="mapsSearchForm" data-pwa-context="Search" data-pwa-scope="Search"><label>Find on map <input id="mapsFind" name="search" type="search" placeholder="Place or feature name" /></label></form>
<button type="button" id="mapsNew" data-pwa-context="Map" data-ribbon-icon="add">New map</button>
@ -71,7 +71,7 @@
</div>
<aside id="mapsDetails" class="maps-details" aria-label="Details"><h2>Details</h2><div id="mapsDetailContent">Select something on the map to see its details.</div></aside>
</div>
<dialog id="mapsNewDialog"><form id="mapsNewForm"><h2>New map</h2><label>Name <input name="Name" maxlength="200" required autofocus /></label><label>What are you mapping? <select name="Kind">@foreach(var kind in PlotLine.Services.MapValidation.Kinds){<option>@kind</option>}</select></label><label>How would you like to begin? <select name="Starter"><option value="blank">Blank map</option><option value="land">Single land mass</option><option value="island">Large island</option><option value="islands">Island group</option><option value="two">Two land masses</option><option value="inland">Inland region</option><option value="local">City / local area</option></select></label><label>Parent map <select name="ParentMapID"><option value="">None</option>@foreach(var map in Model.Maps){<option value="@map.MapID">@map.Name</option>}</select></label><p>Starter layouts contain editable shapes only. You name and define your world.</p><div><button type="button" id="mapsNewCancel">Cancel</button><button type="submit">Create map</button></div></form></dialog>
<dialog id="mapsNewDialog"><form id="mapsNewForm"><h2>New map</h2><label>Name <input name="Name" maxlength="200" required autofocus /></label><label>What are you mapping? <select name="Kind">@foreach(var kind in PlotLine.Services.MapValidation.Kinds){<option>@kind</option>}</select></label><label>How would you like to begin? <select name="Starter"><option value="blank">Blank map</option><option value="land">Single land mass</option><option value="island">Large island</option><option value="islands">Island group</option><option value="two">Two land masses</option><option value="inland">Inland region</option><option value="local">City / local area</option></select></label><label>Parent map <select name="ParentMapID"><option value="">None</option>@foreach(var map in Model.Maps.OrderBy(map => map.Name, StringComparer.CurrentCultureIgnoreCase)){<option value="@map.MapID">@map.Name</option>}</select></label><p>Starter layouts contain editable shapes only. You name and define your world.</p><div><button type="button" id="mapsNewCancel">Cancel</button><button type="submit">Create map</button></div></form></dialog>
<dialog id="mapsArrangeDialog"><h2>Arrange from relationships</h2><p>Preview an arrangement using directions and relative distances. Known distances never control spacing.</p><label><input type="checkbox" id="mapsOnlyNew" /> Arrange unplaced / new items only</label><p id="mapsArrangeWarnings"></p><button type="button" id="mapsArrangeCancel">Cancel</button><button type="button" id="mapsArrangeApply">Apply arrangement</button></dialog>
<dialog id="mapsGeographicDialog" aria-labelledby="mapsGeographicTitle">
<h2 id="mapsGeographicTitle">Position geographically</h2>

View File

@ -3,7 +3,9 @@
ViewData["ShellClass"] = "plotline-shell-wide";
ViewData["Title"] = "Plot Lines";
ViewData["ProjectSection"] = "Plot Lines";
var selectedThreads = Model.PlotLines.Where(x => x.IsSelected).SelectMany(x => x.Threads).ToList();
var plotLineChoices = Model.PlotLines.OrderBy(x => x.Line.PlotLineName, StringComparer.CurrentCultureIgnoreCase).ToList();
var selectedThreads = plotLineChoices.Where(x => x.IsSelected)
.SelectMany(x => x.Threads.OrderBy(thread => thread.ThreadTitle, StringComparer.CurrentCultureIgnoreCase)).ToList();
}
<nav data-pwa-identity class="breadcrumb-trail" aria-label="Breadcrumb">
@ -51,7 +53,7 @@
<fieldset class="plot-line-picker">
<legend>Plot lines</legend>
@foreach (var item in Model.PlotLines)
@foreach (var item in plotLineChoices)
{
<label class="plot-line-choice" style="--line-colour:@item.Line.Colour">
<input type="checkbox" name="plotLineId" value="@item.Line.PlotLineID" checked="@item.IsSelected" data-line-choice />

View File

@ -1,4 +1,5 @@
@model TimelineViewModel
<link rel="stylesheet" href="~/css/location-picker.css" asp-append-version="true" />
@{
ViewData["Title"] = "Timeline";
ViewData["ShellClass"] = "plotline-shell-wide";
@ -585,7 +586,8 @@
<div class="row g-2">
<div class="col-6"><label class="form-label">Event type <help-icon key="timeline.fields.dragAssetEvent" mode="inline" /></label><select class="form-select form-select-sm" name="AssetEventTypeID" asp-items="Model.AssetEventTypeOptions"></select></div>
<div class="col-6"><label class="form-label">State transition <help-icon key="timeline.fields.dragAssetEvent" mode="inline" /></label><select class="form-select form-select-sm" name="ToStateID" asp-items="Model.AssetStateOptions"><option value="">Optional</option></select></div>
<div class="col-12"><label class="form-label">Location <help-icon key="sceneInspector.fields.assetLocation" mode="inline" /></label><select class="form-select form-select-sm" name="LocationID" asp-items="Model.LocationOptions"><option value="">Optional</option></select></div>
<div class="col-12"><label for="timelineAssetLocationID" class="form-label">Location <help-icon key="sceneInspector.fields.assetLocation" mode="inline" /></label><select id="timelineAssetLocationID" class="form-select form-select-sm" name="LocationID" asp-items="Model.LocationOptions"
data-location-picker data-project-id="@Model.Project.ProjectID" data-picker-label="Choose asset location" data-empty-location-label="No location"><option value="">Optional</option></select></div>
<div class="col-12"><label class="form-label">Event title</label><input class="form-control form-control-sm" name="EventTitle" /></div>
<div class="col-12"><label class="form-label">Custody note</label><textarea class="form-control form-control-sm" name="CustodyNote" rows="2"></textarea></div>
</div>
@ -1148,6 +1150,7 @@ else
}
@section Scripts {
<script src="~/js/location-picker.js" asp-append-version="true"></script>
<partial name="_ValidationScriptsPartial" />
<script src="~/js/scene-inspector-v2.js" asp-append-version="true"></script>
}

View File

@ -51,7 +51,7 @@
@for(var pane = 0; pane < 2; pane++) {
@if(pane == 1){<div data-context-divider role="separator" tabindex="0" aria-label="Resize Context panes" aria-controls="context-pane-0 context-pane-1" aria-orientation="vertical" aria-valuemin="20" aria-valuemax="80" aria-valuenow="50" hidden></div>}
<section id="context-pane-@pane" class="context-pane" data-context-pane="@pane" aria-label="Context pane @(pane+1)" hidden="@(pane==1)">
<div class="context-pane-toolbar"><label>Tool <select data-context-tab class="form-select form-select-sm">@foreach(var tab in tabs){<option value="@tab.id">@tab.displayName</option>}</select></label></div>
<div class="context-pane-toolbar"><label>Tool <select data-context-tab class="form-select form-select-sm">@foreach(var tab in tabs.OrderBy(tab => tab.displayName, StringComparer.CurrentCultureIgnoreCase)){<option value="@tab.id" selected="@(tab.id == (pane == 0 ? "overview" : "characters"))">@tab.displayName</option>}</select></label></div>
<p data-context-pane-status class="context-pane-status" role="status"></p>
<div data-context-pane-content class="context-pane-content" tabindex="0" aria-label="Pane @(pane+1) reference content"></div>
</section>

View File

@ -4,7 +4,7 @@
<button type="button" class="btn btn-link btn-sm float-end" data-context-refresh title="Read updated saved information; does not request AI">Refresh saved data</button>
@if(Model.Document==null){<p>No story maps are saved for this project. The Maps workspace can hold your locations and their relationships.</p>}
else{
<div class="writing-chart-controls"><label>Map <select class="form-select form-select-sm" data-context-map-choice>@foreach(var map in Model.Maps){<option value="@map.MapID" selected="@(map.MapID==Model.Document.Map.MapID)">@map.Name</option>}</select></label><label>Lens <select class="form-select form-select-sm" data-context-map-lens data-writing-view-state="context-map-lens"><option value="scene">Scene location</option><option value="people">Scene participants</option><option value="plots">Plot Line locations</option><option value="all">All saved places</option></select></label></div>
<div class="writing-chart-controls"><label>Map <select class="form-select form-select-sm" data-context-map-choice>@foreach(var map in Model.Maps.OrderBy(map => map.Name, StringComparer.CurrentCultureIgnoreCase)){<option value="@map.MapID" selected="@(map.MapID==Model.Document.Map.MapID)">@map.Name</option>}</select></label><label>Lens <select class="form-select form-select-sm" data-context-map-lens data-writing-view-state="context-map-lens"><option value="scene">Scene location</option><option value="people">Scene participants</option><option value="plots">Plot Line locations</option><option value="all">All saved places</option></select></label></div>
<p class="small" data-context-map-location>@(Model.Position?.FeatureID.HasValue==true?$"Saved scene location: {Model.Position.LocationName} · {Model.Position.Status}":"The scene has no reliably mapped location yet. You can still explore this saved map.")</p>
<div class="writing-chart-controls"><button type="button" class="btn btn-outline-secondary btn-sm" data-context-map-fit>Fit map</button><button type="button" class="btn btn-outline-secondary btn-sm" data-context-map-focus disabled="@(Model.Position?.FeatureID==null)">Show scene location</button><button type="button" class="btn btn-outline-secondary btn-sm" data-context-map-zoom=".8" aria-label="Zoom in">+</button><button type="button" class="btn btn-outline-secondary btn-sm" data-context-map-zoom="1.25" aria-label="Zoom out">−</button></div>
<p class="small text-muted">Saved places and location relationships. Drag to pan; selecting a place explores the map without moving Word.</p>

View File

@ -34,6 +34,67 @@
});render();return{get value(){return value===''?(options.allowRoot?'':undefined):(value!==undefined&&records.has(value)&&allowed(value)?value:undefined);},focus:()=>search.focus(),path};
}
async function data(project){const response=await fetch(`/LocationWorkspace/Picker?projectId=${project}`,{cache:'no-store'});if(!response.ok||response.redirected)throw Error('Locations are unavailable.');return response.json();}
function enhance(select){if(select.dataset.pickerReady)return;select.dataset.pickerReady='true';const trigger=button('',async()=>{trigger.disabled=true;let dialog;try{const directory=await data(select.dataset.projectId);dialog=element('dialog',undefined,'pd-location-picker-dialog');const heading=element('h2',select.dataset.pickerLabel||'Choose location'),body=element('div'),actions=element('div',undefined,'button-row');const picker=mount(body,{...directory,label:heading.textContent,allowRoot:select.dataset.allowRoot==='true',selected:select.value||(select.dataset.allowRoot==='true'?'':undefined),rootLabel:'Root level',excludeIds:select.dataset.excludeId?[select.dataset.excludeId]:[],excludeBranches:select.dataset.excludeBranch?[select.dataset.excludeBranch]:[]});const save=button('Choose location',()=>{if(picker.value===undefined)return;const id=picker.value;if(![...select.options].some(o=>o.value===id))select.add(new Option(picker.path(id),id));select.value=id;select.dispatchEvent(new Event('change',{bubbles:true}));update();dialog.close();});save.className='btn btn-primary btn-sm';const cancel=button('Cancel',()=>dialog.close());cancel.className='btn btn-outline-secondary btn-sm';actions.append(save,cancel);dialog.append(heading,body,actions);dialog.addEventListener('close',()=>{dialog.remove();trigger.focus();});document.body.append(dialog);dialog.showModal();picker.focus();}catch(e){window.PlotDirector?.toast?.error(e.message);dialog?.remove();}finally{trigger.disabled=select.disabled;}});trigger.className='btn btn-outline-secondary pd-location-picker-trigger';trigger.setAttribute('aria-haspopup','dialog');trigger.setAttribute('aria-label',select.dataset.pickerLabel||'Choose location');function update(){trigger.textContent=select.selectedOptions[0]?.textContent?.trim()||'Choose location…';trigger.disabled=select.disabled;}select.addEventListener('change',update);update();select.hidden=true;select.after(trigger);}
function enhance(select) {
if (select.dataset.pickerReady) return;
select.dataset.pickerReady = 'true';
const label = select.dataset.pickerLabel || 'Choose location';
const trigger = button('', async () => {
trigger.disabled = true;
let dialog;
try {
const directory = await data(select.dataset.projectId);
dialog = element('dialog', undefined, 'pd-location-picker-dialog');
const heading = element('h2', label);
const body = element('div');
const actions = element('div', undefined, 'button-row');
const emptyLabel = select.dataset.emptyLocationLabel;
const allowRoot = select.dataset.allowRoot === 'true' || Boolean(emptyLabel);
const picker = mount(body, {
...directory,
label,
allowRoot,
selected: select.value || (allowRoot ? '' : undefined),
rootLabel: emptyLabel || 'Root level',
excludeIds: select.dataset.excludeId ? [select.dataset.excludeId] : [],
excludeBranches: select.dataset.excludeBranch ? [select.dataset.excludeBranch] : []
});
const save = button('Choose location', () => {
const id = picker.value;
if (id === undefined) return;
if (![...select.options].some(option => option.value === id)) {
select.add(new Option(picker.path(id), id));
}
select.value = id;
select.dispatchEvent(new Event('change', { bubbles: true }));
dialog.close();
});
save.className = 'btn btn-primary btn-sm';
const cancel = button('Cancel', () => dialog.close());
cancel.className = 'btn btn-outline-secondary btn-sm';
actions.append(save, cancel);
dialog.append(heading, body, actions);
dialog.addEventListener('close', () => { dialog.remove(); trigger.focus(); });
document.body.append(dialog);
dialog.showModal();
picker.focus();
} catch (error) {
window.PlotDirector?.toast?.error(error.message);
dialog?.remove();
} finally {
trigger.disabled = select.disabled;
}
});
trigger.className = 'btn btn-outline-secondary pd-location-picker-trigger';
trigger.setAttribute('aria-haspopup', 'dialog');
trigger.setAttribute('aria-label', label);
function update() {
trigger.textContent = select.selectedOptions[0]?.textContent?.trim() || 'Choose location…';
trigger.disabled = select.disabled;
}
select.addEventListener('change', update);
update();
select.hidden = true;
select.after(trigger);
}
document.querySelectorAll('select[data-location-picker]').forEach(enhance);window.PlotDirectorLocationPicker=Object.freeze({mount,enhance,data});
})();

View File

@ -26,7 +26,8 @@
const params=new URLSearchParams(location.search);if(!initialContextApplied&&params.has('sceneId')&&scenes.has(Number(params.get('sceneId')))){state.sceneID=Number(params.get('sceneId'));state.lens='scene';state.selection={kind:'scene',sceneID:state.sceneID};}initialContextApplied=true;
$('mapStoryScenario').innerHTML=option(0,'Canonical manuscript')+data.scenarios.map(s=>option(s.scenarioID,s.scenarioName)).join('');$('mapStoryScenario').value=String(data.scenarioID||0);state.scenarioID=data.scenarioID||0;
$('mapStoryBook').innerHTML=option(0,'All books')+[...new Map(data.scenes.map(s=>[s.bookID,s.bookTitle])).entries()].map(([id,name])=>option(id,name)).join('');$('mapStoryBook').value=String(state.bookID);
for(let i=1;i<=3;i++){$('mapStoryCharacter'+i).innerHTML=option(0,i===1?'Choose character':'None')+[...data.characters].sort((a,b)=>a.name.localeCompare(b.name,undefined,{sensitivity:'base'})||a.characterID-b.characterID).map(c=>option(c.characterID,c.name)).join('');$('mapStoryCharacter'+i).value=String(state.characterIDs[i-1]||0);$('mapStoryPlot'+i).innerHTML=option(0,i===1?'All Plot Lines':'None')+data.plotLines.map(p=>option(p.plotLineID,p.plotLineName)).join('');$('mapStoryPlot'+i).value=String(state.plotIDs[i-1]||0);}
const plotLines = [...data.plotLines].sort((a,b)=>a.plotLineName.localeCompare(b.plotLineName,undefined,{sensitivity:'base'})||a.plotLineID-b.plotLineID);
for(let i=1;i<=3;i++){$('mapStoryCharacter'+i).innerHTML=option(0,i===1?'Choose character':'None')+[...data.characters].sort((a,b)=>a.name.localeCompare(b.name,undefined,{sensitivity:'base'})||a.characterID-b.characterID).map(c=>option(c.characterID,c.name)).join('');$('mapStoryCharacter'+i).value=String(state.characterIDs[i-1]||0);$('mapStoryPlot'+i).innerHTML=option(0,i===1?'All Plot Lines':'None')+plotLines.map(p=>option(p.plotLineID,p.plotLineName)).join('');$('mapStoryPlot'+i).value=String(state.plotIDs[i-1]||0);}
$('mapStoryLens').value=state.lens;scopeOptions();
}
function scopeOptions(){