diff --git a/Docs/Relationships/Workspace.md b/Docs/Relationships/Workspace.md index fbfa7895..7495a0da 100644 --- a/Docs/Relationships/Workspace.md +++ b/Docs/Relationships/Workspace.md @@ -32,7 +32,7 @@ Not included: cross-device layout storage, automatic importance suggestions, tim The page is now a single bounded application surface beneath the existing ribbon in browser and PWA mode. A page-scoped shell class removes content-width limits and gutters. Height follows the actual ribbon and viewport via ResizeObserver; internal palettes, history and List scroll without extending the document. The application maximise mode has an explicit restore button and Escape fallback, with no browser fullscreen API. -The toolbar contains Map/List, a named focus chip with clear action, Auto-arrange, Layout and Display. The legend and original selectors are inside Display. The map's fit, zoom, centre and select/pan controls form a floating vertical toolbar. The right rail shares its space between Supporting characters and contextual detail. Character detail is built from the same canonical response and includes existing avatar, importance, relationship count and selectable connections/history. List is a separate workspace view; no standalone list remains beneath the map. +The toolbar contains Map/List, a named focus chip with clear action, Auto-arrange, Layout and Display. The colour key is pinned beneath the right rail. Display exposes network visibility, Story point and maximise/restore; the original selectors are in the Story point dialog. The map's fit, zoom, centre and select/pan controls form a floating vertical toolbar. The right rail shares its space between Supporting characters and contextual detail. Character detail is built from the same canonical response and includes existing avatar, importance, relationship count and selectable connections/history. List is a separate workspace view; no standalone list remains beneath the map. The timeline retains its existing state resolver, range keyboard navigation and scene defaults. Presentation adds explicit Initial/End buttons, change dots, progress and selected-scene output. Relationship dialogs retain their form and save path, with avatar pairs and subordinate endpoint selectors. Graph nodes retain Cytoscape and category line colours, adding existing portrait paths or generated initials. Node, label, focus, palette and timeline surfaces use the application's semantic theme tokens and update when the active theme changes. @@ -45,3 +45,9 @@ Browser regression coverage additionally checks viewport bounds, complete mobile Relationships declares its existing toolbar controls as normal `data-pwa-context` contributions. The shell binds commands and form fields to their live sources; there is no second focus, view or maximise state. Layout and Display request the existing compact ribbon menus. A small shared renderer extension honours `data-pwa-compact` for such contributions and copies explicitly declared passive legend content without IDs or interactive controls. Help uses the standard page-help contribution. Only in standalone mode, accounted contributions suppress the entire secondary toolbar and remove its grid row. The existing viewport measurement gives the space to the canvas. Browser presentation and all importance thresholds, cast assignment, graph, timeline, dialog and persistence logic remain unchanged. PWA maximise keeps the ribbon reachable so its Restore command remains available. `relationships-ribbon.cjs` covers command/state binding, menus, recovered height, mobile overflow and navigation cleanup; the existing relationship and PWA browser suites remain regression gates. + +## Ribbon presentation refinement + +Workspace commands explicitly select distinct icons from the existing SVG icon catalogue, including new diagram/navigation glyphs where no suitable icon existed. Layout and Display summaries declare their own icons rather than inheriting the first child command's icon. The shared form renderer also honours an explicitly declared field icon. + +Display now contains one network-visibility checkbox and two commands: Story point and maximise/restore. The previous GET selectors and update action remain available in a compact Story point dialog. Its network checkbox remains associated with that original GET form, so submitting the selectors preserves network visibility. The colour key is outside the ribbon and fixed beneath the right palette/detail rail. Both browser and PWA Display panels have no scroll container; focused browser tests assert distinct command glyphs and non-scrolling desktop/mobile menus. diff --git a/PlotLine.Tests/Browser/relationships-ribbon.cjs b/PlotLine.Tests/Browser/relationships-ribbon.cjs index bef46bc5..af571ae9 100644 --- a/PlotLine.Tests/Browser/relationships-ribbon.cjs +++ b/PlotLine.Tests/Browser/relationships-ribbon.cjs @@ -23,8 +23,16 @@ const base='http://127.0.0.1:5238'; for(const name of ['Map','List','Full cast','Details','Add relationship','Auto-arrange','Remove focused from map','Reset layout','Characters','Maximise workspace']) await command(name); for(const name of ['View','Focus','Relationship','Arrange','Layout','Display']) assert(await shell.locator(`.pd-context-group[aria-label="${name}"]`).count(),name+' group'); assert(await shell.locator('[data-help-open]').count(),'Help uses ribbon help'); - assert(await shell.locator('.relationship-map-legend-grid').count(),'Display includes existing legend'); - assert(await shell.locator('select').count()>=4,'Display retains story selectors'); + assert.equal(await shell.locator('.relationship-map-legend-grid').count(),0,'legend removed from ribbon'); + assert(await app.locator('.rw-rail .rw-colour-key').isVisible(),'colour key at bottom of right panel'); + await (await command('Story point…')).click(); assert(await app.locator('#rwStoryDialog').evaluate(e=>e.open)); + assert(await app.locator('#rwStoryDialog select').count()>=4,'story selectors remain available in compact dialog'); await app.locator('#rwCloseStory').click(); + const iconPaths=await shell.locator('button.pd-context-command').evaluateAll(nodes=>nodes.map(n=>n.querySelector('svg path')?.getAttribute('d'))); + assert(iconPaths.every(Boolean),'every command has a relevant icon'); assert.equal(new Set(iconPaths).size,iconPaths.length,'command icons are distinct'); + await command('Maximise workspace'); + const display=shell.locator('.pd-context-group[aria-label="Display"] > details > .pd-context-menu-content'); + assert(await display.evaluate(e=>e.scrollHeight<=e.clientHeight+1 && e.scrollWidth<=e.clientWidth+1),'Display has no scrolling'); + assert(await (await command('Story point…')).isVisible()); assert(await (await command('Maximise workspace')).isVisible()); const geometry=await app.locator('#rwApp').evaluate(e=>({top:e.getBoundingClientRect().top,board:document.getElementById('rwBoard').getBoundingClientRect().top,rows:getComputedStyle(e).gridTemplateRows.split(' ').length})); assert.equal(geometry.rows,1,'no reserved toolbar grid row');assert(Math.abs(geometry.board-geometry.top)<2,'palettes start immediately, recovered space used'); await (await command('List')).click();assert(await app.locator('#rwListPanel').isVisible());assert.equal(await (await command('List')).getAttribute('aria-pressed'),'true'); @@ -44,6 +52,8 @@ const base='http://127.0.0.1:5238'; await (await command('Restore workspace')).click();assert(!(await app.locator('#rwApp').evaluate(e=>e.classList.contains('rw-maximised')))); await app.setViewportSize({width:390,height:900});await (await command('Characters')).click();assert(await app.locator('.rw-navigation').isVisible(),'mobile cast opens via existing ribbon overflow'); assert(await app.locator('.rw-toolbar').isHidden()); + await command('Maximise workspace'); + assert(await display.evaluate(e=>e.scrollHeight<=e.clientHeight+1 && e.scrollWidth<=e.clientWidth+1),'mobile Display has no scrolling'); await app.goto(base+'/fixture');assert.equal(await app.locator('[data-pwa-context-controls]').getByRole('button',{name:'Add relationship',exact:true}).count(),0,'navigation clears relationship contributions'); assert.deepEqual(errors,[]);console.log('PASS Relationships ribbon: browser fallback, PWA controls/state/menus, recovered height, mobile overflow and navigation cleanup'); } finally {await browser.close();} diff --git a/PlotLine/Help/Articles/RelationshipMap/Overview.md b/PlotLine/Help/Articles/RelationshipMap/Overview.md index 15a0cd7b..884727cc 100644 --- a/PlotLine/Help/Articles/RelationshipMap/Overview.md +++ b/PlotLine/Help/Articles/RelationshipMap/Overview.md @@ -37,7 +37,7 @@ Drag empty canvas to pan. Use **+ / −**, Ctrl/Cmd-wheel, or a two-finger pinch Installed PWA users can right-click palette characters, map characters, connections or canvas to access the existing application command menu. The same actions are available through buttons, with no right-click required. Select a connection to inspect its history or edit it at the timeline point. **Map / List** switches between workspace views of the same relationship state. The right rail switches between Supporting characters and contextual Details. Focusing a character shows their relationship count, connections, editing actions and history; selecting a connection shows its current state, notes and history. -Positions, focus, zoom, pan and palette collapse are remembered in this browser for the project/book. They do not sync to other devices. On smaller screens, **Characters** opens a searchable drawer containing the whole cast, and **Details** opens the contextual panel. Selecting a character closes the drawer and returns to the map. The canvas and timeline remain the primary surface. **Display** contains the compact relationship legend and the older book/chapter/scene selectors. +Positions, focus, zoom, pan and palette collapse are remembered in this browser for the project/book. They do not sync to other devices. On smaller screens, **Characters** opens a searchable drawer containing the whole cast, and **Details** opens the contextual panel. Selecting a character closes the drawer and returns to the map. The canvas and timeline remain the primary surface. **Display** contains Show full network, **Story point…**, and maximise/restore. Story point opens the existing book/chapter/scene and focus selectors in a separate dialog. The relationship colour key stays at the bottom of the right panel. # Example diff --git a/PlotLine/Services/RibbonPresentation.cs b/PlotLine/Services/RibbonPresentation.cs index 743a6357..bad5e661 100644 --- a/PlotLine/Services/RibbonPresentation.cs +++ b/PlotLine/Services/RibbonPresentation.cs @@ -41,6 +41,14 @@ public static class RibbonPresentation return null; } public static IReadOnlyList AdditionalIcons { get; } = [ + new("map", "M3 5l6-2 6 2 6-2v16l-6 2-6-2-6 2z M9 3v16 M15 5v16", "relationships"), + new("focus", "M12 2v4 M12 18v4 M2 12h4 M18 12h4 M19 12a7 7 0 1 0-14 0 7 7 0 0 0 14 0 M14 12a2 2 0 1 0-4 0 2 2 0 0 0 4 0", "relationships"), + new("details", "M4 3h16v18H4z M8 7h8 M8 11h8 M8 15h5", "books"), + new("auto-arrange", "M3 3h6v6H3z M15 3h6v6h-6z M3 15h6v6H3z M15 15h6v6h-6z M11 6h2 M6 11v2 M18 11v2 M11 18h2", "planning"), + new("layout", "M3 3h18v18H3z M3 8h18 M8 8v13 M16 8v13", "planning"), + new("display", "M3 4h18v14H3z M8 22h8 M12 18v4", "planning"), + new("maximise", "M9 3H3v6 M15 3h6v6 M3 15v6h6 M21 15v6h-6", "planning"), + new("hide-node", "M5 5h14v14H5z M9 12h6 M2 12h3 M19 12h3", "relationships"), new("save", "M4 3h13l4 4v14H3V3z M7 3v6h10V3 M7 21v-7h10v7", "planning"), new("close", "M5 5l14 14 M19 5L5 19", "planning"), new("cut", "M4 3l16 18 M20 3L9 14 M8 17a3 3 0 1 0-6 0 3 3 0 0 0 6 0 M22 17a3 3 0 1 0-6 0 3 3 0 0 0 6 0", "planning"), diff --git a/PlotLine/Views/RelationshipMap/Index.cshtml b/PlotLine/Views/RelationshipMap/Index.cshtml index d321ea3e..8f3455d4 100644 --- a/PlotLine/Views/RelationshipMap/Index.cshtml +++ b/PlotLine/Views/RelationshipMap/Index.cshtml @@ -9,22 +9,33 @@

Relationships

- - + +
-
+
- - - -
Layout
- - - + + + +
Layout
+ + +
-
Display
-
+
Display
+ + + +
+ +
+
+

Story point and focus

+
@@ -50,27 +61,10 @@
- Project Start -
-
- @foreach (var category in Model.Categories) - { - - - @category.CategoryName - - } -
- - - - - + +
} - @if (side == "right") { } + @if (side == "right") {

Relationship key

+ @foreach (var category in Model.Categories) + { + + + @category.CategoryName + + } +
+ +
} @if (side == "left" || side == "right") { @: } } diff --git a/PlotLine/wwwroot/css/relationship-workspace.css b/PlotLine/wwwroot/css/relationship-workspace.css index 895626dc..1508f822 100644 --- a/PlotLine/wwwroot/css/relationship-workspace.css +++ b/PlotLine/wwwroot/css/relationship-workspace.css @@ -138,3 +138,15 @@ html[data-standalone="true"] .rw-app.rw-maximised { top: var(--rw-ribbon-bottom, [data-pwa-context-controls] .relationship-map-legend-grid { display:flex; flex-wrap:wrap; gap:8px; max-width:310px; padding:8px; } /* Ribbon dropdowns must stay above the maximised application surface. */ html[data-standalone="true"] .rw-app.rw-maximised { z-index: 1010; } +.rw-colour-key { flex-shrink: 0; border-top: 1px solid var(--pd-border); padding: 8px; background: var(--pd-nested); } +.rw-colour-key h3 { margin-bottom: 5px; } +.rw-colour-key .relationship-map-legend-grid { display: flex; flex-wrap: wrap; gap: 5px 10px; font-size: 10px; } +.rw-colour-key .relationship-map-legend-item > span:last-child { color: var(--pd-text); } +.rw-display > .rw-menu-panel { max-height: none; overflow: visible; } +body.rw-page [data-pwa-context-controls] .pd-context-group[aria-label="Display"] > details > .pd-context-menu-content { max-height: none; overflow: visible; } +body.rw-page [data-pwa-context-controls] .pd-context-group[aria-label="Display"] .pd-context-form { display: block; } +body.rw-page [data-pwa-context-controls] .pd-context-group[aria-label="Display"] .pd-context-field { flex-direction: row; justify-content: flex-start; max-width: none; padding: 7px; gap: 8px; } +body.rw-page [data-pwa-context-controls] .pd-context-group[aria-label="Display"] input[type="checkbox"] { width: 16px; min-width: 16px; height: 16px; margin-left: auto; } +#rwStoryDialog { width: min(440px,95vw); max-height: 90dvh; overflow: auto; background: var(--pd-elevated); color: var(--pd-text); border: 1px solid var(--pd-border); border-radius: 6px; padding: 15px; } +#rwStoryDialog::backdrop { background: rgb(0 0 0 / 45%); } +#rwStoryDialog h2 { font-size: 17px; margin-bottom: 12px; } diff --git a/PlotLine/wwwroot/js/application-page-context.js b/PlotLine/wwwroot/js/application-page-context.js index 6beef292..b266d858 100644 --- a/PlotLine/wwwroot/js/application-page-context.js +++ b/PlotLine/wwwroot/js/application-page-context.js @@ -259,7 +259,7 @@ for (const source of fields) { const label = source.dataset.pwaLabel || source.getAttribute('aria-label') || source.labels?.[0]?.textContent.trim() || source.placeholder || source.name; const wrapper = make(isSearch ? 'div' : 'label', 'pd-context-field'); - if (isSearch) wrapper.append(make('span', '', label)); else decorate(wrapper, label, source.matches('select') ? /project/i.test(source.name) ? 'projects' : /book/i.test(source.name) ? 'bible' : 'point' : 'search'); + if (isSearch) wrapper.append(make('span', '', label)); else decorate(wrapper, label, source.dataset.ribbonIcon || (source.matches('select') ? /project/i.test(source.name) ? 'projects' : /book/i.test(source.name) ? 'bible' : 'point' : 'search')); const target = make(source.tagName.toLowerCase(), source.matches('select') ? 'pd-context-select' : 'pd-context-input'); if (source.matches('select')) [...source.options].forEach(option => { const copy = new Option(option.text, option.value, false, option.selected); copy.disabled = option.disabled; target.add(copy); }); else { target.type = source.type === 'checkbox' ? 'checkbox' : source.type === 'search' ? 'search' : 'text'; target.placeholder = source.placeholder; } @@ -344,6 +344,7 @@ for (const region of contributions) { if (region.parentElement?.closest('[data-pwa-header], [data-pwa-context]')) continue; const label = region.dataset.pwaContext || region.dataset.pwaTools || 'Page tools'; + if (region.dataset.pwaMenuIcon) group(label, 50, region.dataset.pwaCompact === 'true').icon = region.dataset.pwaMenuIcon; if (region.matches('[data-pwa-help]')) { helpSource ||= region.querySelector(region.matches('h1') ? '[data-help-icon]' : 'h1 [data-help-icon]'); continue; } const commands = region.matches('a, button') ? [region] : region.matches('[data-pwa-context]') ? [...region.querySelectorAll('a, button')] : [...region.querySelectorAll('a.btn, a.dropdown-item, button.btn, button.dropdown-item')]; const supported = commands.filter(node => !node.matches('[data-bs-toggle="dropdown"]')); @@ -353,7 +354,7 @@ helpSource ||= region.querySelector(region.matches('h1') ? '[data-help-icon]' : 'h1 [data-help-icon]'); const formFields = new Set(forms.filter(form => { if (!form.querySelector('select, input:not([type="hidden"]), textarea')) return false; - const scopeLabel = form.querySelector('select') ? region.dataset.pwaScope || 'Scope' : 'Find'; + const scopeLabel = region.dataset.pwaScope || (form.querySelector('select') ? 'Scope' : 'Find'); const target = group(scopeLabel, 10, region.dataset.pwaCompact === 'true').element; target.parentElement.dataset.essential = 'true'; return renderForm(form, target); @@ -383,7 +384,7 @@ } else region.dataset.pwaAccounted = 'true'; } for (const [label, entry] of groups) { - if (label !== 'Jump to' && label !== 'Export') { const icon = entry.element.querySelector('.pd-icon'); if (icon) entry.element.parentElement.querySelector(':scope > summary .pd-icon')?.replaceWith(icon.cloneNode(true)); } + if (label !== 'Jump to' && label !== 'Export') { const icon = entry.icon ? icons?.querySelector(`[data-icon-key="${entry.icon}"]`) : entry.element.querySelector('.pd-icon'); if (icon) { const copy = icon.cloneNode(true); copy.removeAttribute('data-icon-key'); entry.element.parentElement.querySelector(':scope > summary .pd-icon')?.replaceWith(copy); } } if (!entry.element.childElementCount) { entry.element.closest('.pd-context-group').remove(); groups.delete(label); } } if (helpSource?.dataset.helpUrl) { diff --git a/PlotLine/wwwroot/js/relationship-workspace.js b/PlotLine/wwwroot/js/relationship-workspace.js index 27312e01..9e95e7fd 100644 --- a/PlotLine/wwwroot/js/relationship-workspace.js +++ b/PlotLine/wwwroot/js/relationship-workspace.js @@ -8,6 +8,9 @@ if (!app.classList.contains('rw-maximised')) app.style.height = `${Math.max(260, window.innerHeight - app.getBoundingClientRect().top - 5)}px`; resizeGraph(); }; + document.getElementById('rwStoryPoint').addEventListener('click', () => document.getElementById('rwStoryDialog').showModal()); + document.getElementById('rwCloseStory').addEventListener('click', () => document.getElementById('rwStoryDialog').close()); + document.getElementById('rwNetworkForm').addEventListener('submit', event => event.preventDefault()); sizeWorkspace(); window.addEventListener('resize', sizeWorkspace); const chromeObserver = new ResizeObserver(sizeWorkspace);