Collapsible locations tree, sorting mode, and drag selection fix
The Locations page now shows only top-level locations by default; rows with children get a caret that reveals sub-locations inline, indented under their parent in the same table style. Rearranging is gated behind a new "Sorting mode" toggle next to "Show removed locations": when enabled, rows can be dragged onto another location (or a drop strip to move to top level). The same toggle appears on container array pages and gates drawer drag-to-swap. The state persists across reloads so it survives post-move refreshes. Dragging no longer selects text: drawer trays and draggable cards get user-select: none, the drawer drag suppresses selection globally for its duration, and mousedown on a tray prevents native selection. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
fa78bb02d4
commit
20c982755a
9 files changed
+273
-19
No files matched your search
@@ -1498,7 +1498,7 @@ tr:last-child .actions-dropdown-menu {
|
||||
inset: 0;
|
||||
transform-style: preserve-3d;
|
||||
transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
cursor: grab;
|
||||
cursor: pointer;
|
||||
touch-action: pan-y;
|
||||
}
|
||||
|
||||
@@ -1706,6 +1706,107 @@ tr:last-child .actions-dropdown-menu {
|
||||
border-color: #b91c1c;
|
||||
}
|
||||
|
||||
/* ==========================================
|
||||
Locations tree table & sorting mode
|
||||
========================================== */
|
||||
|
||||
.loc-name-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.loc-caret {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 1.4rem;
|
||||
height: 1.4rem;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--color-text-muted);
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
padding: 0;
|
||||
flex-shrink: 0;
|
||||
transition: transform 0.18s ease, background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.loc-caret:hover {
|
||||
background: var(--color-bg-base);
|
||||
color: var(--color-brand-primary);
|
||||
}
|
||||
|
||||
.loc-caret.expanded {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.loc-caret-spacer {
|
||||
display: inline-block;
|
||||
width: 1.4rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.loc-grid-badge {
|
||||
font-size: 0.68rem;
|
||||
font-weight: 700;
|
||||
color: var(--color-brand-primary);
|
||||
background: var(--color-brand-light);
|
||||
border: 1px solid var(--color-border-warm);
|
||||
border-radius: 4px;
|
||||
padding: 0.05rem 0.3rem;
|
||||
margin-left: 0.35rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Root drop strip, shown only while sorting */
|
||||
.sort-root-dropzone {
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
padding: 0.75rem;
|
||||
border: 2px dashed var(--color-border-warm);
|
||||
border-radius: 10px;
|
||||
color: var(--color-brand-primary);
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
background: var(--color-bg-surface);
|
||||
}
|
||||
|
||||
body.sorting-mode .sort-root-dropzone {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
body.sorting-mode .loc-row[draggable="true"] {
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
body.sorting-mode .drawer-tray {
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
body.sorting-mode .drawer-cabinet {
|
||||
outline: 2px dashed var(--color-brand-accent);
|
||||
outline-offset: 4px;
|
||||
}
|
||||
|
||||
/* Keep drags from selecting text */
|
||||
.folder-card[draggable="true"],
|
||||
.item-card[draggable="true"],
|
||||
.loc-row[draggable="true"],
|
||||
.drawer-tray {
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
body.drag-no-select,
|
||||
body.drag-no-select * {
|
||||
user-select: none !important;
|
||||
-webkit-user-select: none !important;
|
||||
}
|
||||
|
||||
/* 404 Not Found page */
|
||||
.notfound-container {
|
||||
display: flex;
|
||||
|
||||
@@ -21,10 +21,32 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
// 5. Mobile sidebar drawer interactions
|
||||
initMobileSidebar();
|
||||
|
||||
// 6. Container array drawer grid (3D view)
|
||||
// 6. Sorting mode (drag rearranging) toggle state
|
||||
initSortingMode();
|
||||
|
||||
// 7. Container array drawer grid (3D view)
|
||||
initDrawerArray();
|
||||
});
|
||||
|
||||
// Sorting mode gates all drag-to-rearrange interactions; persisted so it
|
||||
// survives the page reloads triggered after each successful move.
|
||||
function sortingModeEnabled() {
|
||||
return document.body.classList.contains("sorting-mode");
|
||||
}
|
||||
|
||||
function initSortingMode() {
|
||||
let enabled = false;
|
||||
try { enabled = localStorage.getItem("solisSortingMode") === "1"; } catch (e) { /* private mode */ }
|
||||
document.body.classList.toggle("sorting-mode", enabled);
|
||||
document.querySelectorAll(".sorting-mode-toggle").forEach(cb => { cb.checked = enabled; });
|
||||
}
|
||||
|
||||
function toggleSortingMode(checkbox) {
|
||||
document.body.classList.toggle("sorting-mode", checkbox.checked);
|
||||
document.querySelectorAll(".sorting-mode-toggle").forEach(cb => { cb.checked = checkbox.checked; });
|
||||
try { localStorage.setItem("solisSortingMode", checkbox.checked ? "1" : "0"); } catch (e) { /* private mode */ }
|
||||
}
|
||||
|
||||
// Mobile off-canvas sidebar drawer
|
||||
function toggleSidebar() {
|
||||
const sidebar = document.getElementById("sidebar");
|
||||
@@ -174,6 +196,11 @@ function initDragAndDrop() {
|
||||
|
||||
draggables.forEach(draggable => {
|
||||
draggable.addEventListener("dragstart", (e) => {
|
||||
// Elements marked sort-gated only drag while sorting mode is on
|
||||
if (draggable.classList.contains("sort-gated") && !sortingModeEnabled()) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
draggedElement = draggable;
|
||||
draggable.classList.add("dragging");
|
||||
|
||||
@@ -397,6 +424,11 @@ function initDrawerArray() {
|
||||
cell.classList.add("drag-source");
|
||||
hidePeek();
|
||||
|
||||
// Suppress text selection for the duration of the drag
|
||||
document.body.classList.add("drag-no-select");
|
||||
const selection = window.getSelection();
|
||||
if (selection) selection.removeAllRanges();
|
||||
|
||||
const front = cell.querySelector(".drawer-front");
|
||||
const rect = front.getBoundingClientRect();
|
||||
const ghost = front.cloneNode(true);
|
||||
@@ -442,6 +474,7 @@ function initDrawerArray() {
|
||||
dragState.suppressClick = true;
|
||||
setTimeout(() => { dragState.suppressClick = false; }, 50);
|
||||
|
||||
document.body.classList.remove("drag-no-select");
|
||||
cell.classList.remove("drag-source");
|
||||
if (ghost) ghost.remove();
|
||||
if (target) target.classList.remove("drop-target");
|
||||
@@ -480,14 +513,17 @@ function initDrawerArray() {
|
||||
cells.forEach(cell => {
|
||||
const tray = cell.querySelector(".drawer-tray");
|
||||
|
||||
// Mouse: drag starts after a small movement threshold; plain click navigates
|
||||
// Mouse: in sorting mode, drag starts after a small movement threshold;
|
||||
// plain click navigates either way
|
||||
tray.addEventListener("mousedown", (e) => {
|
||||
if (e.button !== 0) return;
|
||||
// Avoid native text selection from a press-and-move on the drawer
|
||||
e.preventDefault();
|
||||
const startX = e.clientX, startY = e.clientY;
|
||||
let started = false;
|
||||
|
||||
const onMove = (ev) => {
|
||||
if (!started && Math.hypot(ev.clientX - startX, ev.clientY - startY) > 6) {
|
||||
if (!started && sortingModeEnabled() && Math.hypot(ev.clientX - startX, ev.clientY - startY) > 6) {
|
||||
started = true;
|
||||
startDrag(cell, ev.clientX, ev.clientY);
|
||||
}
|
||||
@@ -502,13 +538,14 @@ function initDrawerArray() {
|
||||
document.addEventListener("mouseup", onUp);
|
||||
});
|
||||
|
||||
// Touch: long-press (450ms) starts drag; quick tap toggles the peek
|
||||
// Touch: in sorting mode, long-press (450ms) starts drag; quick tap
|
||||
// toggles the peek either way
|
||||
tray.addEventListener("touchstart", (e) => {
|
||||
const touch = e.touches[0];
|
||||
const startX = touch.clientX, startY = touch.clientY;
|
||||
let pressTimer = setTimeout(() => {
|
||||
pressTimer = null;
|
||||
startDrag(cell, startX, startY);
|
||||
if (sortingModeEnabled()) startDrag(cell, startX, startY);
|
||||
}, 450);
|
||||
|
||||
const onTouchMove = (ev) => {
|
||||
|
||||
Reference in new issue
Block a user