feat: ask replace vs save-to-archive on regenerate recipe

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.
This commit is contained in:
dadaloop82
2026-05-25 10:11:56 +00:00
parent 52afdd6bfa
commit 4e4a736dba
8 changed files with 74 additions and 2 deletions
+18
View File
@@ -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; }
+34 -1
View File
@@ -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 = `<h2>${r.title}</h2>`;
// 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();
+7 -1
View File
@@ -1816,9 +1816,15 @@
</div>
<div id="recipe-result" style="display:none" class="recipe-result">
<div id="recipe-content"></div>
<button class="btn btn-large btn-secondary full-width mt-2" onclick="regenerateRecipe()" data-i18n="recipes.regenerate">
<button id="recipe-regen-btn" class="btn btn-large btn-secondary full-width mt-2" onclick="showRegenChoice()" data-i18n="recipes.regenerate">
🔄 Generane un'altra
</button>
<div id="recipe-regen-choice" style="display:none" class="recipe-regen-choice">
<p class="recipe-regen-choice-title" data-i18n="recipes.regen_choice_title">Cosa vuoi fare con questa ricetta?</p>
<button class="btn btn-large btn-warning full-width" onclick="doRegenerateReplace()" data-i18n="recipes.regen_replace">🔄 Genera un'altra (scarta questa)</button>
<button class="btn btn-large btn-success full-width mt-2" onclick="doRegenerateSave()" data-i18n="recipes.regen_save_new">💾 Salva nell'archivio e genera nuova</button>
<button class="btn btn-large btn-ghost full-width mt-2" onclick="cancelRegenChoice()" data-i18n="action.cancel">Annulla</button>
</div>
<button class="btn btn-large btn-primary full-width mt-2" onclick="closeRecipeDialog()" data-i18n="recipes.close_btn">
✅ Chiudi
</button>
+3
View File
@@ -361,6 +361,9 @@
"loading_msg": "Rezept wird vorbereitet...",
"start_cooking": "👨‍🍳 Kochmodus",
"regenerate": "🔄 Noch eins generieren",
"regen_choice_title": "Was möchtest du mit diesem Rezept machen?",
"regen_replace": "🔄 Neues generieren (dieses verwerfen)",
"regen_save_new": "💾 Im Archiv speichern & neues generieren",
"close_btn": "✅ Schließen",
"ingredients_title": "🧾 Zutaten",
"tools_title": "Benötigte Geräte",
+3
View File
@@ -361,6 +361,9 @@
"loading_msg": "Preparing your recipe...",
"start_cooking": "👨‍🍳 Cooking Mode",
"regenerate": "🔄 Generate another one",
"regen_choice_title": "What do you want to do with this recipe?",
"regen_replace": "🔄 Generate another (discard this one)",
"regen_save_new": "💾 Save to archive & generate a new one",
"close_btn": "✅ Close",
"ingredients_title": "🧾 Ingredients",
"tools_title": "Equipment needed",
+3
View File
@@ -357,6 +357,9 @@
"loading_msg": "Preparando tu receta...",
"start_cooking": "👨‍🍳 Modo cocina",
"regenerate": "🔄 Generar otra",
"regen_choice_title": "¿Qué quieres hacer con esta receta?",
"regen_replace": "🔄 Generar otra (descartar esta)",
"regen_save_new": "💾 Guardar en el archivo y generar una nueva",
"close_btn": "✅ Cerrar",
"ingredients_title": "🧾 Ingredientes",
"tools_title": "Equipo necesario",
+3
View File
@@ -357,6 +357,9 @@
"loading_msg": "Préparation de votre recette...",
"start_cooking": "👨‍🍳 Mode cuisine",
"regenerate": "🔄 En générer une autre",
"regen_choice_title": "Que veux-tu faire de cette recette ?",
"regen_replace": "🔄 En générer une autre (ignorer celle-ci)",
"regen_save_new": "💾 Sauvegarder dans l'archive et en générer une nouvelle",
"close_btn": "✅ Fermer",
"ingredients_title": "🧾 Ingrédients",
"tools_title": "Matériel nécessaire",
+3
View File
@@ -361,6 +361,9 @@
"loading_msg": "Sto preparando la ricetta...",
"start_cooking": "👨‍🍳 Modalità Cucina",
"regenerate": "🔄 Generane un'altra",
"regen_choice_title": "Cosa vuoi fare con questa ricetta?",
"regen_replace": "🔄 Genera un'altra (scarta questa)",
"regen_save_new": "💾 Salva nell'archivio e genera una nuova",
"close_btn": "✅ Chiudi",
"ingredients_title": "🧾 Ingredienti",
"tools_title": "Strumenti necessari",