From 4e4a736dba8236367bc81fd58c7e7ad04d0a722a Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Mon, 25 May 2026 10:11:56 +0000 Subject: [PATCH] feat: ask replace vs save-to-archive on regenerate recipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When user clicks 'Generate another', show a choice: - Replace (discard current, generate new) — former behavior - Save to archive & generate new — saves current recipe first All 5 languages (it/en/de/fr/es) with regen_choice_title, regen_replace, regen_save_new keys. --- assets/css/style.css | 18 ++++++++++++++++++ assets/js/app.js | 35 ++++++++++++++++++++++++++++++++++- index.html | 8 +++++++- translations/de.json | 3 +++ translations/en.json | 3 +++ translations/es.json | 3 +++ translations/fr.json | 3 +++ translations/it.json | 3 +++ 8 files changed, 74 insertions(+), 2 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index d953de5..a83e3a8 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -4290,6 +4290,22 @@ body.server-offline .bottom-nav { white-space: nowrap; } +/* Regen choice panel */ +.recipe-regen-choice { + background: #f8fafc; + border: 1px solid #e2e8f0; + border-radius: 12px; + padding: 14px; + margin-top: 10px; +} +.recipe-regen-choice-title { + font-size: 0.9rem; + font-weight: 600; + color: #475569; + margin: 0 0 10px 0; + text-align: center; +} + /* Recipe ingredient use buttons */ .recipe-ingredients { list-style: none; @@ -7667,6 +7683,8 @@ body.cooking-mode-active .app-header { [data-theme="dark"] .recipe-tools-banner { background: #1a1040; border-color: #3730a3; color: #c4b5fd; } [data-theme="dark"] .recipe-tool-chip { background: #2e1a4a; color: #c4b5fd; } [data-theme="dark"] .recipe-step-appliance { background: #052e16; border-color: #166534; color: #4ade80; } +[data-theme="dark"] .recipe-regen-choice { background: #1e293b; border-color: #334155; } +[data-theme="dark"] .recipe-regen-choice-title { color: #94a3b8; } [data-theme="dark"] .recipe-subtype-chip { background: #1c1300; border-color: #78350f; color: var(--text); } [data-theme="dark"] .recipe-subtype-chip:has(input:checked) { background: #2a1e00; border-color: #d97706; } diff --git a/assets/js/app.js b/assets/js/app.js index 160de47..d2aad53 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -13206,6 +13206,12 @@ function _extractToolsFromSteps(steps) { } function renderRecipe(r) { + // Reset regen choice panel (hide choice, show button) + const regenChoice = document.getElementById('recipe-regen-choice'); + const regenBtn = document.getElementById('recipe-regen-btn'); + if (regenChoice) regenChoice.style.display = 'none'; + if (regenBtn) regenBtn.style.display = ''; + let html = `

${r.title}

`; // Meta tags @@ -14692,7 +14698,30 @@ function _renderMealPlanHint(mealSlot) { }).catch(() => {/* ignore */}); } -function regenerateRecipe() { +function showRegenChoice() { + document.getElementById('recipe-regen-btn').style.display = 'none'; + document.getElementById('recipe-regen-choice').style.display = ''; +} + +function cancelRegenChoice() { + document.getElementById('recipe-regen-choice').style.display = 'none'; + document.getElementById('recipe-regen-btn').style.display = ''; +} + +function doRegenerateReplace() { + cancelRegenChoice(); + _doRegenerate(); +} + +async function doRegenerateSave() { + if (_cachedRecipe && _cachedRecipe.recipe) { + await saveRecipeToArchive(_cachedRecipe.recipe); + } + cancelRegenChoice(); + _doRegenerate(); +} + +function _doRegenerate() { // Collect main ingredients from the rejected recipe to exclude them if (_cachedRecipe && _cachedRecipe.recipe && _cachedRecipe.recipe.ingredients) { const mainIngs = _cachedRecipe.recipe.ingredients @@ -14708,6 +14737,10 @@ function regenerateRecipe() { document.getElementById('recipe-ask').style.display = ''; } +function regenerateRecipe() { + showRegenChoice(); +} + async function generateRecipe() { if (!_requireGemini()) return; const meal = getSelectedMealType(); diff --git a/index.html b/index.html index 3433085..0f3decc 100644 --- a/index.html +++ b/index.html @@ -1816,9 +1816,15 @@