← back to Dw Collections Viewer
dw-collections-viewer: 'Preview sort' button — re-render with chosen sort but skip deploy/pm2-restart so user can eyeball the order before pushing live
cbb7a2021254b0239a58364e9e9637d0d3918d58 · 2026-05-06 20:58:49 -0700 · Steve
Files touched
Diff
commit cbb7a2021254b0239a58364e9e9637d0d3918d58
Author: Steve <steve@designerwallcoverings.com>
Date: Wed May 6 20:58:49 2026 -0700
dw-collections-viewer: 'Preview sort' button — re-render with chosen sort but skip deploy/pm2-restart so user can eyeball the order before pushing live
---
public/index.html | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/public/index.html b/public/index.html
index d608951..ecdc7be 100644
--- a/public/index.html
+++ b/public/index.html
@@ -924,6 +924,7 @@ function renderDetail() {
</select>
</label>
<button class="btn go" onclick="saveAndDeploy()" ${assigned.length === 0 ? 'disabled' : ''}>💾 Save & Deploy</button>
+ <button class="btn" onclick="previewSort()" ${assigned.length === 0 ? 'disabled' : ''} title="Re-render local products.json with the chosen sort, but do NOT deploy. Lets you see the order before pushing live.">👁 Preview sort</button>
<button class="btn" onclick="renderSite()" ${assigned.length === 0 ? 'disabled' : ''}>Render now (live)</button>
<a class="btn" href="https://${s.domain}" target="_blank" style="text-decoration:none">Open site ↗</a>
</div>
@@ -1045,6 +1046,23 @@ function getDeploySort() {
return (sel && sel.value) || localStorage.getItem('dwc_deploy_sort') || 'textures';
}
+// Preview a sort locally without deploying. Re-fetches Shopify with the chosen sort, writes
+// the local products.json (but skips scp + pm2 restart), then reloads the products slider so
+// the user can eyeball the new order before committing to a live deploy.
+async function previewSort() {
+ const sort = getDeploySort();
+ toast(`previewing ${CURRENT} (sort=${sort}, no deploy)…`);
+ const r = await fetch(`api/site/${CURRENT}/render`, {
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ deploy: false, sort })
+ });
+ const j = await r.json();
+ if (!r.ok) return toast('preview failed: ' + (j.error || r.status), false);
+ toast(`preview ready · ${j.total_unique} products in "${sort}" order (NOT deployed — hit Save & Deploy when ready)`);
+ await loadSites();
+ renderDetail();
+}
+
async function renderSite() {
const sort = getDeploySort();
if (!confirm(`Re-render ${CURRENT} from ${SITES[CURRENT].collections.length} Shopify collection(s), sorted "${sort}"? Overwrites products.json + scp + pm2 restart.`)) return;
← 15a2c8f dw-collections-viewer: stale-products pill (>30 days mtime)
·
back to Dw Collections Viewer
·
dw-collections-viewer: gold ↕<sort> pill on tiles when persi deda82f →