Compact location hierarchy controls and preserve drag workflows

This commit is contained in:
Nick Beckley 2026-11-03 20:24:57 +00:00
parent 7f193192e8
commit d6be496a93
6 changed files with 65 additions and 19 deletions

View File

@ -14,8 +14,8 @@
## Durable queue
1. Completed: B1 ribbon order and regression coverage.
2. In progress: B2 compact Locations drag controls and PWA width.
3. B3 clickable project/book covers and titles.
2. Completed: B2 compact Locations drag controls and PWA width.
3. In progress: B3 clickable project/book covers and titles.
4. B4 investigate and retire obsolete Phase 1 Checklist safely.
5. C shared workspace resizing and maximisation, starting with Relationships reference.
6. D UX audit and repairs.
@ -38,3 +38,11 @@ Verification: `dotnet build PlotLine.slnx` passed (0 warnings/errors); full exec
## Deployment
Not deployed.
### B2 — Locations hierarchy controls
Replaced the standalone dropdown panel with compact Change parent / Create relationship buttons, published through the existing contextual command bindings under Location hierarchy. Browser toolbar remains immediately above the list. Preserved parent confirmations and relationship editing; persisted mode in local storage with graceful storage failure handling. Removed only the Locations PWA shell width cap. Ribbon proxies now preserve source button help tooltips.
Verification: solution build passed (0 warnings/errors); location browser regression passed, including keyboard activation, persistence, both drag modes, confirmation/cancellation, invalid targets, concurrent server rejection and scroll preservation. Repaired a stale fixture to read the shared confirmation partial, and explicitly scrolled the dragged source into view after toolbar keyboard use. Full harness rerun in progress.
B1 commit: 7f19319.

View File

@ -11,13 +11,13 @@ const repo = path.resolve(__dirname, '../..');
page.on('pageerror', error => errors.push(error.message));
await page.route('https://plotdirector.test/**', route => route.fulfill({ contentType: 'text/html', body: '<html><body></body></html>' }));
await page.goto('https://plotdirector.test/Locations');
const layout = fs.readFileSync(path.join(repo, 'PlotLine/Views/Shared/_Layout.cshtml'), 'utf8');
const modalStart = layout.indexOf(' <div class="modal fade" id="plotlineConfirmModal"');
const modal = layout.slice(modalStart, layout.indexOf(' <script', modalStart));
const modal = fs.readFileSync(path.join(repo, 'PlotLine/Views/Shared/_ConfirmationDialog.cshtml'), 'utf8');
const rows = [ ['1','Room','',''], ['2','Building','',''], ['3','Cupboard','1','Room'], ['4','Annex','2','Building'] ]
.map(([id,name,parent,parentName]) => `<div style="padding:24px;border:1px solid" draggable="true" data-drag-type="location" data-drag-id="${id}" data-drag-label="${name}" data-parent-location-id="${parent}" data-parent-location-name="${parentName}"><a href="/Locations/Details/${id}">${name}</a></div>`).join('');
await page.setContent(`<select data-location-drag-action><option value="parent">Change parent</option><option value="relationship">Create relationship</option></select>
<p data-location-move-error></p><p data-location-move-status></p>
const locationsView = fs.readFileSync(path.join(repo, 'PlotLine/Views/Locations/Index.cshtml'), 'utf8');
const toolbarStart = locationsView.indexOf(' <div class="location-hierarchy-toolbar"');
const toolbar = locationsView.slice(toolbarStart, locationsView.indexOf(' <form asp-action="Reparent"', toolbarStart));
await page.setContent(`${toolbar}
<form action="/Locations/Reparent" method="post" data-location-reparent-form data-confirm-message="Change parent?" data-confirm-button-text="Move location" data-confirm-button-class="btn-primary">
<input type="hidden" name="projectId" value="1"><input type="hidden" name="locationId"><input type="hidden" name="parentLocationId"><input type="hidden" name="expectedParentLocationId">
</form>
@ -51,8 +51,12 @@ const repo = path.resolve(__dirname, '../..');
return new Response(tree.outerHTML, {headers:{'Content-Type':'text/html'}});
};
});
const drag = async (source, target) => page.locator(`[data-drag-id="${source}"]`).dragTo(page.locator(`[data-drag-id="${target}"]`));
const drag = async (source, target) => {
await page.locator(`[data-drag-id="${source}"]`).scrollIntoViewIfNeeded();
await page.locator(`[data-drag-id="${source}"]`).dragTo(page.locator(`[data-drag-id="${target}"]`));
};
const confirm = page.locator('#plotlineConfirmModal');
assert.deepEqual(errors,[]);
await drag(1,2);
await confirm.waitFor({state:'visible'});
assert.match(await confirm.innerText(), /from top level to “Building”/);
@ -89,7 +93,11 @@ const repo = path.resolve(__dirname, '../..');
await page.locator('.modal-backdrop').waitFor({state:'hidden'});
assert.match(await page.locator('[data-location-move-error]').innerText(), /parent has changed/);
assert.equal(await page.locator('[data-drag-id="4"]').getAttribute('data-parent-location-id'),'1');
await page.selectOption('[data-location-drag-action]','relationship');
await page.locator('[data-location-drag-choice="relationship"]').focus();
await page.keyboard.press('Enter');
assert.equal(await page.locator('[data-location-drag-choice="relationship"]').getAttribute('aria-pressed'), 'true');
assert.equal(await page.locator('[data-location-drag-choice="parent"]').getAttribute('aria-pressed'), 'false');
assert.equal(await page.evaluate(() => localStorage.getItem('plotdirector.locations.dragAction')), 'relationship');
await drag(1,2);
await page.locator('[data-drag-drop-panel]').waitFor({state:'visible'});
assert.equal(await page.locator('[name="FromLocationID"]').inputValue(),'1');

View File

@ -1,6 +1,7 @@
@model LocationListViewModel
@{
ViewData["DesktopLayout"] = "management";
ViewData["ShellClass"] = "location-workspace-shell";
ViewData["Title"] = "Locations";
ViewData["ProjectSection"] = "Locations";
}
@ -30,16 +31,16 @@
{
<div class="alert alert-danger" role="alert">@error</div>
}
<div class="edit-panel">
<label for="locationDragAction" class="form-label">Drag a location onto another location to:</label>
<select id="locationDragAction" class="form-select" data-location-drag-action>
<option value="parent">Change its parent</option>
<option value="relationship">Create a relationship</option>
</select>
<p class="muted mt-2 mb-0">Drop onto the new parent, then confirm the move. Child locations move with it. You can also change the parent using Edit.</p>
<p class="text-danger mb-0" role="alert" data-location-move-error></p>
<p class="mb-0" role="status" data-location-move-status></p>
<div class="location-hierarchy-toolbar" data-pwa-context="Location hierarchy">
<span class="fw-semibold">On drop:</span>
<div class="btn-group" role="group" aria-label="Location drag behaviour">
<button type="button" class="btn btn-outline-primary btn-sm" data-location-drag-choice="parent" aria-pressed="true" title="Move a location and its children beneath a new parent; confirmation required.">Change parent</button>
<button type="button" class="btn btn-outline-primary btn-sm" data-location-drag-choice="relationship" aria-pressed="false" title="Open the relationship editor for the two locations.">Create relationship</button>
</div>
<input type="hidden" value="parent" data-location-drag-action />
</div>
<p class="text-danger mb-0" role="alert" data-location-move-error></p>
<p class="mb-0" role="status" data-location-move-status></p>
<form asp-action="Reparent" method="post" data-location-reparent-form
data-confirm-message="Change location parent?" data-confirm-button-text="Move location" data-confirm-button-class="btn-primary">
<input type="hidden" name="projectId" value="@Model.Project.ProjectID" />

View File

@ -7636,3 +7636,15 @@ html[data-standalone="true"] .scene-workspace .scene-workspace-workbench { heigh
.responsive-rail-text strong { display: block; white-space: nowrap; overflow-wrap: normal; }
.lane-group-heading { overflow-wrap: anywhere; font-size: .65rem; padding-inline: 3px; }
}
.location-hierarchy-toolbar {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: .5rem;
margin-bottom: .75rem;
}
html[data-standalone="true"] .plotline-shell.location-workspace-shell {
max-width: none;
}

View File

@ -192,7 +192,7 @@
if (source.matches('button')) {
const label = caption(source);
if (target.querySelector('span').textContent !== label) target.querySelector('span').textContent = label;
target.title = label;
target.title = source.getAttribute('title') || label;
}
};
bindings.push(update); update();

View File

@ -2123,6 +2123,23 @@
const reparentForm = document.querySelector("[data-location-reparent-form]");
const locationDragAction = document.querySelector("[data-location-drag-action]");
const dragChoices = [...document.querySelectorAll("[data-location-drag-choice]")];
const setDragAction = value => {
if (!locationDragAction) return;
locationDragAction.value = value === "relationship" ? "relationship" : "parent";
dragChoices.forEach(button => {
const selected = button.dataset.locationDragChoice === locationDragAction.value;
button.setAttribute("aria-pressed", String(selected));
button.classList.toggle("active", selected);
});
};
if (dragChoices.length) {
try { setDragAction(localStorage.getItem("plotdirector.locations.dragAction")); } catch { setDragAction("parent"); }
dragChoices.forEach(button => button.addEventListener("click", () => {
setDragAction(button.dataset.locationDragChoice);
try { localStorage.setItem("plotdirector.locations.dragAction", locationDragAction.value); } catch { /* Storage may be disabled. */ }
}));
}
const locationMoveError = document.querySelector("[data-location-move-error]");
let locationRows = new Map([...document.querySelectorAll("[data-drag-type='location']")]
.map(row => [row.dataset.dragId, row]));