From 4d2d4e729683a3af529bd903908839e9e2d85a71 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Fri, 15 May 2026 15:34:40 -0400 Subject: [PATCH] Update preview modal with design-type-specific buttons - For disc designs: show 'Import into Disk 1' and 'Import into Disk 2' buttons - For templates: show 'Print / Save PDF' button - Buttons are built dynamically based on design type - Disc imports automatically switch to template mode - Both designs still have 'Save JSON' option Co-Authored-By: Claude Sonnet 4.6 --- src/index.html | 90 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 24 deletions(-) diff --git a/src/index.html b/src/index.html index da736a1..5069520 100644 --- a/src/index.html +++ b/src/index.html @@ -2151,8 +2151,7 @@

Design Preview

-
- +
@@ -4901,6 +4900,71 @@ $('designPreviewModal')._row = row; const p = row.payload || {}; + const isDiscDesign = !!p.discDesign && !p.slots; + + // Rebuild action buttons based on design type + const actionsDiv = $('previewModalActions'); + const saveJsonBtn = $('previewSaveJsonBtn'); + const closeBtn = $('previewModalClose'); + + // Clear dynamic buttons, keep Save JSON and Close + while (actionsDiv.children.length > 2) { + actionsDiv.removeChild(actionsDiv.children[0]); + } + + if (isDiscDesign) { + // For disc designs, show import buttons + const import1Btn = document.createElement('button'); + import1Btn.type = 'button'; + import1Btn.textContent = 'Import into Disk 1'; + import1Btn.id = 'previewImport1Btn'; + import1Btn.addEventListener('click', () => { + importDiscDesignFromPayload(p, 'top', { openDesigner: false }); + state.appMode = 'template'; + syncInputs(); + render(); + $('designPreviewModal').classList.remove('open'); + $('nostrModal').classList.remove('open'); + }); + + const import2Btn = document.createElement('button'); + import2Btn.type = 'button'; + import2Btn.textContent = 'Import into Disk 2'; + import2Btn.id = 'previewImport2Btn'; + import2Btn.addEventListener('click', () => { + importDiscDesignFromPayload(p, 'bottom', { openDesigner: false }); + state.appMode = 'template'; + syncInputs(); + render(); + $('designPreviewModal').classList.remove('open'); + $('nostrModal').classList.remove('open'); + }); + + actionsDiv.insertBefore(import2Btn, saveJsonBtn); + actionsDiv.insertBefore(import1Btn, saveJsonBtn); + } else { + // For templates, show print button + const printBtn = document.createElement('button'); + printBtn.type = 'button'; + printBtn.textContent = 'Print / Save PDF'; + printBtn.id = 'previewPrintBtn'; + printBtn.addEventListener('click', () => { + const stateSnapshot = JSON.parse(JSON.stringify(state)); + try { loadProjectFromText(JSON.stringify(p)); } catch(e) { console.error(e); } + $('designPreviewModal').classList.remove('open'); + $('nostrModal').classList.remove('open'); + function onAfterPrint() { + window.removeEventListener('afterprint', onAfterPrint); + Object.assign(state, stateSnapshot); + syncInputs(); + render(); + } + window.addEventListener('afterprint', onAfterPrint); + setTimeout(() => { render(); window.print(); }, 350); + }); + actionsDiv.insertBefore(printBtn, saveJsonBtn); + } + if (p.discDesign) { renderDiscPreviewDOM(content, p); } else { @@ -5317,28 +5381,6 @@ }); // Preview modal event listeners - $('previewPrintBtn').addEventListener('click', () => { - const row = $('designPreviewModal')._row; - if (!row) return; - const stateSnapshot = JSON.parse(JSON.stringify(state)); - const p = row.payload || {}; - if (p.discDesign) { - importDiscDesignFromPayload(p, 'a', { openDesigner: false }); - } else { - try { loadProjectFromText(JSON.stringify(p)); } catch(e) { console.error(e); } - } - $('designPreviewModal').classList.remove('open'); - $('nostrModal').classList.remove('open'); - function onAfterPrint() { - window.removeEventListener('afterprint', onAfterPrint); - Object.assign(state, stateSnapshot); - syncInputs(); - render(); - } - window.addEventListener('afterprint', onAfterPrint); - setTimeout(() => { render(); window.print(); }, 350); - }); - $('previewSaveJsonBtn').addEventListener('click', () => { const row = $('designPreviewModal')._row; if (!row) return;