[object Object]

← back to Interiordesignershowroom

moodboard drawer: Pieces tab defaults open (board visible on open); Project/Create stay collapsed; explicit collapse still persists

e72a006b48ec43d19e0e7d38a2d0a79635bed3e5 · 2026-08-03 08:45:20 -0700 · Steve

Files touched

Diff

commit e72a006b48ec43d19e0e7d38a2d0a79635bed3e5
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon Aug 3 08:45:20 2026 -0700

    moodboard drawer: Pieces tab defaults open (board visible on open); Project/Create stay collapsed; explicit collapse still persists
---
 lib/adminview.js       | 32 ++++++++++++++++++++++++++++++++
 public/js/moodboard.js |  5 ++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/lib/adminview.js b/lib/adminview.js
new file mode 100644
index 0000000..89d961b
--- /dev/null
+++ b/lib/adminview.js
@@ -0,0 +1,32 @@
+// Shared admin-view helpers: dependency-free cookie parsing + the backend
+// "see more detail" preference. Express can SET cookies natively (res.cookie);
+// only READING them needs parsing, so we keep the repo's "no deps beyond
+// express" rule and parse the Cookie header by hand.
+
+function parseCookies(req) {
+  const out = {};
+  const raw = req.headers.cookie || '';
+  for (const part of raw.split(';')) {
+    const i = part.indexOf('=');
+    if (i < 0) continue;
+    const k = part.slice(0, i).trim();
+    if (!k) continue;
+    try { out[k] = decodeURIComponent(part.slice(i + 1).trim()); }
+    catch (_) { out[k] = part.slice(i + 1).trim(); }
+  }
+  return out;
+}
+
+// Backend "Show details" preference. A ?details=1|0 query overrides AND persists
+// to a cookie so the choice sticks across admin pages. ABSENCE = collapsed — Steve
+// gets the tight view by default and expands to the raw fields when he wants them.
+function detailPref(req, res) {
+  if (req.query && req.query.details != null) {
+    const on = String(req.query.details) === '1';
+    res.cookie('ids_details', on ? '1' : '0', { maxAge: 180 * 24 * 3600e3, sameSite: 'lax', path: '/admin' });
+    return on;
+  }
+  return parseCookies(req).ids_details === '1';
+}
+
+module.exports = { parseCookies, detailPref };
diff --git a/public/js/moodboard.js b/public/js/moodboard.js
index a41da81..98893c8 100644
--- a/public/js/moodboard.js
+++ b/public/js/moodboard.js
@@ -213,8 +213,11 @@
             + '<div class="mb-tile-t">' + esc(x.title) + '</div></div>';
         }).join('') + '</div>'
       : '<p class="mb-empty">This project is empty.<br>While you shop, tap <strong>◇ Mood Board</strong> on any piece to collect it here.</p>';
+    // Pieces defaults OPEN (board visible on drawer open); Project/Create default
+    // collapsed. All respect an explicit user toggle once one is recorded.
+    var piecesOpen = (ts.pieces === undefined) ? true : ts.pieces;
     var piecesTab =
-      '<details class="mb-tab" data-tab="pieces"' + (ts.pieces ? ' open' : '') + '>'
+      '<details class="mb-tab" data-tab="pieces"' + (piecesOpen ? ' open' : '') + '>'
       + '<summary>Pieces (' + b.length + ')</summary>'
       + '<div class="mb-tabbody">' + piecesInner + '</div></details>';
 

← d44578c Switch Honiture affiliate OFF (kept, hidden) + drop its inge  ·  back to Interiordesignershowroom  ·  IDS admin: 'Suggested lines to join' affiliate tab (TK-10171 95495fd →