feat: add recipes module with CRUD functionality and integrate with meals

- Implemented new recipes page with UI for managing recipes.
- Added REST API routes for recipes including create, read, update, and delete operations.
- Introduced database schema for recipes and recipe ingredients.
- Updated meals to link with recipes, allowing meals to reference specific recipes.
- Enhanced validation for recipe-related fields in meals.
- Added styles for the recipes page and components.
This commit is contained in:
Serhiy Bobrov
2026-04-21 13:43:42 +03:00
committed by Ulas Kalayci
parent 41467a84b6
commit 0b54fe255b
25 changed files with 1421 additions and 48 deletions
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "الإعدادات",
"main": "القائمة الرئيسية",
"navigation": "التنقل",
"quickActions": "الإجراءات السريعة"
"quickActions": "الإجراءات السريعة",
"recipes": "Recipes"
},
"dashboard": {
"title": "لوحة التحكم",
@@ -242,7 +243,11 @@
"loadingIndicator": "جارٍ التحميل…",
"recipeUrlLabel": "رابط الوصفة (اختياري)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "فتح الوصفة"
"openRecipe": "فتح الوصفة",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "التقويم",
@@ -604,5 +609,29 @@
"unitWeeks": "أسابيع",
"unitMonth": "شهر",
"unitMonths": "أشهر"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -43,7 +43,8 @@
"main": "Hauptnavigation",
"navigation": "Navigation",
"quickActions": "Schnellaktionen",
"more": "Mehr"
"more": "Mehr",
"recipes": "Recipes"
},
"search": {
"title": "Suche",
@@ -256,7 +257,11 @@
"loadingIndicator": "Lade…",
"recipeUrlLabel": "Rezept-Link (optional)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Rezept öffnen"
"openRecipe": "Rezept öffnen",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Kalender",
@@ -676,5 +681,29 @@
"notificationHint": "Erhalte Benachrichtigungen auch wenn die App geöffnet ist.",
"pendingBadgeTitle": "{{count}} fällige Erinnerung",
"pendingBadgeTitlePlural": "{{count}} fällige Erinnerungen"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "Ρυθμίσεις",
"main": "Κύρια πλοήγηση",
"navigation": "Πλοήγηση",
"quickActions": "Γρήγορες ενέργειες"
"quickActions": "Γρήγορες ενέργειες",
"recipes": "Recipes"
},
"dashboard": {
"title": "Επισκόπηση",
@@ -242,7 +243,11 @@
"loadingIndicator": "Φόρτωση…",
"recipeUrlLabel": "Σύνδεσμος συνταγής (προαιρετικό)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Άνοιγμα συνταγής"
"openRecipe": "Άνοιγμα συνταγής",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Ημερολόγιο",
@@ -604,5 +609,29 @@
"unitWeeks": "εβδομάδες",
"unitMonth": "μήνα",
"unitMonths": "μήνες"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "Settings",
"main": "Main navigation",
"navigation": "Navigation",
"quickActions": "Quick actions"
"quickActions": "Quick actions",
"recipes": "Recipes"
},
"dashboard": {
"title": "Overview",
@@ -242,7 +243,11 @@
"loadingIndicator": "Loading…",
"recipeUrlLabel": "Recipe link (optional)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Open recipe"
"openRecipe": "Open recipe",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Calendar",
@@ -625,5 +630,29 @@
"notificationHint": "Receive notifications while the app is open.",
"pendingBadgeTitle": "{{count}} reminder due",
"pendingBadgeTitlePlural": "{{count}} reminders due"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "Ajustes",
"main": "Navegación principal",
"navigation": "Navegación",
"quickActions": "Acciones rápidas"
"quickActions": "Acciones rápidas",
"recipes": "Recipes"
},
"dashboard": {
"title": "Inicio",
@@ -242,7 +243,11 @@
"loadingIndicator": "Cargando…",
"recipeUrlLabel": "Enlace a la receta (opcional)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Abrir receta"
"openRecipe": "Abrir receta",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Calendario",
@@ -604,5 +609,29 @@
"unitWeeks": "semanas",
"unitMonth": "mes",
"unitMonths": "meses"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "Paramètres",
"main": "Navigation principale",
"navigation": "Navigation",
"quickActions": "Actions rapides"
"quickActions": "Actions rapides",
"recipes": "Recipes"
},
"dashboard": {
"title": "Accueil",
@@ -242,7 +243,11 @@
"loadingIndicator": "Chargement…",
"recipeUrlLabel": "Lien recette (optionnel)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Ouvrir la recette"
"openRecipe": "Ouvrir la recette",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Calendrier",
@@ -604,5 +609,29 @@
"unitWeeks": "semaines",
"unitMonth": "mois",
"unitMonths": "mois"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "सेटिंग्स",
"main": "मुख्य नेविगेशन",
"navigation": "नेविगेशन",
"quickActions": "त्वरित क्रियाएं"
"quickActions": "त्वरित क्रियाएं",
"recipes": "Recipes"
},
"dashboard": {
"title": "डैशबोर्ड",
@@ -242,7 +243,11 @@
"loadingIndicator": "लोड हो रहा है…",
"recipeUrlLabel": "रेसिपी लिंक (वैकल्पिक)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "रेसिपी खोलें"
"openRecipe": "रेसिपी खोलें",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "कैलेंडर",
@@ -604,5 +609,29 @@
"unitWeeks": "सप्ताह",
"unitMonth": "माह",
"unitMonths": "माह"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "Impostazioni",
"main": "Navigazione principale",
"navigation": "Navigazione",
"quickActions": "Azioni rapide"
"quickActions": "Azioni rapide",
"recipes": "Recipes"
},
"dashboard": {
"title": "Panoramica",
@@ -242,7 +243,11 @@
"loadingIndicator": "Caricamento…",
"recipeUrlLabel": "Link ricetta (opzionale)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Apri ricetta"
"openRecipe": "Apri ricetta",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Calendario",
@@ -604,5 +609,29 @@
"unitWeeks": "settimane",
"unitMonth": "mese",
"unitMonths": "mesi"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "設定",
"main": "メインナビゲーション",
"navigation": "ナビゲーション",
"quickActions": "クイックアクション"
"quickActions": "クイックアクション",
"recipes": "Recipes"
},
"dashboard": {
"title": "ダッシュボード",
@@ -242,7 +243,11 @@
"loadingIndicator": "読み込み中…",
"recipeUrlLabel": "レシピリンク(任意)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "レシピを開く"
"openRecipe": "レシピを開く",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "カレンダー",
@@ -604,5 +609,29 @@
"unitWeeks": "週",
"unitMonth": "ヶ月",
"unitMonths": "ヶ月"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "Configurações",
"main": "Navegação principal",
"navigation": "Navegação",
"quickActions": "Ações rápidas"
"quickActions": "Ações rápidas",
"recipes": "Recipes"
},
"dashboard": {
"title": "Painel",
@@ -242,7 +243,11 @@
"loadingIndicator": "Carregando…",
"recipeUrlLabel": "Link da receita (opcional)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Abrir receita"
"openRecipe": "Abrir receita",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Calendário",
@@ -604,5 +609,29 @@
"unitWeeks": "semanas",
"unitMonth": "mês",
"unitMonths": "meses"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "Настройки",
"main": "Главная навигация",
"navigation": "Навигация",
"quickActions": "Быстрые действия"
"quickActions": "Быстрые действия",
"recipes": "Recipes"
},
"dashboard": {
"title": "Обзор",
@@ -242,7 +243,11 @@
"loadingIndicator": "Загрузка…",
"recipeUrlLabel": "Ссылка на рецепт (необязательно)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Открыть рецепт"
"openRecipe": "Открыть рецепт",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Календарь",
@@ -604,5 +609,29 @@
"unitWeeks": "недель",
"unitMonth": "месяц",
"unitMonths": "месяцев"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "Inställningar",
"main": "Huvudnavigering",
"navigation": "Navigering",
"quickActions": "Snabba åtgärder"
"quickActions": "Snabba åtgärder",
"recipes": "Recipes"
},
"dashboard": {
"title": "Översikt",
@@ -242,7 +243,11 @@
"loadingIndicator": "Laddar…",
"recipeUrlLabel": "Receptlänk (valfri)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Öppna recept"
"openRecipe": "Öppna recept",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Kalender",
@@ -604,5 +609,29 @@
"unitWeeks": "veckor",
"unitMonth": "månad",
"unitMonths": "månader"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "Ayarlar",
"main": "Ana gezinme",
"navigation": "Gezinme",
"quickActions": "Hızlı işlemler"
"quickActions": "Hızlı işlemler",
"recipes": "Recipes"
},
"dashboard": {
"title": "Genel Bakış",
@@ -242,7 +243,11 @@
"loadingIndicator": "Yükleniyor…",
"recipeUrlLabel": "Tarif bağlantısı (isteğe bağlı)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Tarifi aç"
"openRecipe": "Tarifi aç",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Takvim",
@@ -604,5 +609,29 @@
"unitWeeks": "hafta",
"unitMonth": "ay",
"unitMonths": "ay"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "Налаштування",
"main": "Головна навігація",
"navigation": "Навігація",
"quickActions": "Швидкі дії"
"quickActions": "Швидкі дії",
"recipes": "Recipes"
},
"dashboard": {
"title": "Огляд",
@@ -242,7 +243,11 @@
"loadingIndicator": "Завантаження…",
"recipeUrlLabel": "Посилання на рецепт (необов'язково)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "Відкрити рецепт"
"openRecipe": "Відкрити рецепт",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "Календар",
@@ -625,5 +630,29 @@
"notificationHint": "Отримуйте сповіщення, поки додаток відкрито.",
"pendingBadgeTitle": "{{count}} нагадування",
"pendingBadgeTitlePlural": "{{count}} нагадувань"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+31 -2
View File
@@ -42,7 +42,8 @@
"settings": "设置",
"main": "主导航",
"navigation": "导航",
"quickActions": "快捷操作"
"quickActions": "快捷操作",
"recipes": "Recipes"
},
"dashboard": {
"title": "概览",
@@ -242,7 +243,11 @@
"loadingIndicator": "加载中…",
"recipeUrlLabel": "食谱链接(可选)",
"recipeUrlPlaceholder": "https://…",
"openRecipe": "打开食谱"
"openRecipe": "打开食谱",
"savedRecipeLabel": "Saved recipe",
"savedRecipePlaceholder": "Select recipe",
"saveAsRecipe": "Save as recipe",
"recipeScaleLabel": "Scale ingredients"
},
"calendar": {
"title": "日历",
@@ -604,5 +609,29 @@
"unitWeeks": "周",
"unitMonth": "个月",
"unitMonths": "个月"
},
"recipes": {
"title": "Recipes",
"addRecipe": "Add recipe",
"editRecipe": "Edit recipe",
"emptyTitle": "No recipes yet",
"emptyDescription": "Save your favorite recipes and reuse them in meal planning.",
"titleLabel": "Title *",
"titlePlaceholder": "e.g. Pasta Carbonara",
"notesLabel": "Notes",
"notesPlaceholder": "Optional...",
"urlLabel": "Recipe link",
"urlPlaceholder": "https://...",
"ingredientsLabel": "Ingredients",
"addToMeals": "Add to meal plan",
"openLink": "Open recipe link",
"deleteConfirm": "Delete recipe \"{{title}}\"?",
"created": "Recipe saved.",
"updated": "Recipe updated.",
"deleted": "Recipe deleted.",
"titleRequired": "Title is required",
"duplicate": "Duplicate",
"duplicated": "Recipe duplicated.",
"copySuffix": "copy"
}
}
+194 -11
View File
@@ -36,6 +36,7 @@ const EXCLUDED_MEAL_CATEGORY_NAMES = new Set(['Haushalt', 'Drogerie']);
let state = {
currentWeek: null, // YYYY-MM-DD (Montag)
meals: [],
recipes: [],
lists: [], // Einkaufslisten für Transfer-Dropdown
categories: [], // Einkaufskategorien für Zutaten
modal: null,
@@ -115,6 +116,15 @@ async function loadCategories() {
}
}
async function loadRecipes() {
try {
const res = await api.get('/recipes');
state.recipes = res.data;
} catch {
state.recipes = [];
}
}
async function loadPreferences() {
try {
const res = await api.get('/preferences');
@@ -157,10 +167,19 @@ export async function render(container, { user }) {
const today = new Date().toISOString().slice(0, 10);
const monday = getMondayOf(today);
await Promise.all([loadWeek(monday), loadLists(), loadPreferences(), loadCategories()]);
await Promise.all([loadWeek(monday), loadLists(), loadPreferences(), loadCategories(), loadRecipes()]);
renderWeekGrid();
wireNav();
const selectedRecipeId = Number(new URLSearchParams(window.location.search).get('recipe'));
if (selectedRecipeId) {
const selectedRecipe = state.recipes.find((r) => r.id === selectedRecipeId);
if (selectedRecipe) {
const firstType = state.visibleMealTypes[0] ?? 'lunch';
openMealModal({ mode: 'create', date: today, mealType: firstType, presetRecipeId: selectedRecipe.id });
}
}
container.querySelector('#fab-new-meal').addEventListener('click', () => {
const firstType = state.visibleMealTypes[0] ?? 'lunch';
openMealModal({ mode: 'create', date: today, mealType: firstType });
@@ -473,7 +492,7 @@ async function moveMeal(mealId, sourceDate, sourceType, targetDate, targetType,
function openMealModal(opts) {
state.modal = opts;
const { mode, date, mealType, meal } = opts;
const { mode, date, mealType, meal, presetRecipeId = null } = opts;
const isEdit = mode === 'edit';
const content = buildModalContent(opts);
@@ -523,6 +542,144 @@ function openMealModal(opts) {
// Zutaten
const ingList = panel.querySelector('#ingredient-list');
const addIngBtn = panel.querySelector('#add-ingredient-btn');
const recipeSelect = panel.querySelector('#modal-recipe-id');
const recipeScaleInput = panel.querySelector('#modal-recipe-scale');
const saveAsRecipeBtn = panel.querySelector('#modal-save-as-recipe');
let currentAppliedRecipe = null;
const scaleQuantityText = (quantity, factor) => {
if (!quantity || factor === 1) return quantity;
const formatNumber = (num, useComma = false) => {
const rounded = Math.round(num * 100) / 100;
if (Number.isInteger(rounded)) return String(rounded);
const text = String(rounded);
return useComma ? text.replace('.', ',') : text;
};
const mixed = quantity.match(/^(\d+)\s+(\d+)\/(\d+)(.*)$/);
if (mixed) {
const whole = Number(mixed[1]);
const num = Number(mixed[2]);
const den = Number(mixed[3]);
if (den > 0) {
const value = (whole + (num / den)) * factor;
return `${formatNumber(value)}${mixed[4]}`;
}
}
const frac = quantity.match(/^(\d+)\/(\d+)(.*)$/);
if (frac) {
const num = Number(frac[1]);
const den = Number(frac[2]);
if (den > 0) {
const value = (num / den) * factor;
return `${formatNumber(value)}${frac[3]}`;
}
}
const dec = quantity.match(/^(\d+(?:[.,]\d+)?)(.*)$/);
if (dec) {
const useComma = dec[1].includes(',');
const base = Number(dec[1].replace(',', '.'));
if (Number.isFinite(base)) {
return `${formatNumber(base * factor, useComma)}${dec[2]}`;
}
}
return quantity;
};
const applyRecipe = (recipeId) => {
const id = Number(recipeId);
const factor = Math.max(Number(recipeScaleInput?.value || 1), 0.1);
if (!id) {
currentAppliedRecipe = null;
return;
}
const recipe = state.recipes.find((r) => r.id === id);
if (!recipe) return;
currentAppliedRecipe = recipe;
panel.querySelector('#modal-title').value = recipe.title || '';
panel.querySelector('#modal-notes').value = recipe.notes || '';
panel.querySelector('#modal-recipe-url').value = recipe.recipe_url || '';
ingList.innerHTML = (recipe.ingredients || [])
.map((ing) => {
const scaledQty = scaleQuantityText(ing.quantity ?? '', factor);
return ingredientRowHTML(ing.name, scaledQty, null, ing.category ?? DEFAULT_CATEGORY_NAME);
})
.join('');
if (window.lucide) lucide.createIcons();
};
recipeSelect?.addEventListener('change', () => {
if (recipeScaleInput) recipeScaleInput.value = '1';
applyRecipe(recipeSelect.value);
});
recipeScaleInput?.addEventListener('input', () => {
const currentRecipeId = Number(recipeSelect?.value || 0);
if (!currentRecipeId || !currentAppliedRecipe) return;
const factor = Number(recipeScaleInput.value || 1);
if (!Number.isFinite(factor) || factor <= 0) return;
ingList.innerHTML = (currentAppliedRecipe.ingredients || [])
.map((ing) => ingredientRowHTML(
ing.name,
scaleQuantityText(ing.quantity ?? '', Math.max(factor, 0.1)),
null,
ing.category ?? DEFAULT_CATEGORY_NAME
))
.join('');
if (window.lucide) lucide.createIcons();
});
saveAsRecipeBtn?.addEventListener('click', async () => {
const title = panel.querySelector('#modal-title').value.trim();
if (!title) {
window.oikos?.showToast(t('meals.titleRequired'), 'error');
return;
}
const notes = panel.querySelector('#modal-notes').value.trim() || null;
const recipe_url = panel.querySelector('#modal-recipe-url').value.trim() || null;
const ingredients = collectModalIngredients(panel).map((ing) => ({
name: ing.name,
quantity: ing.quantity,
category: ing.category,
}));
saveAsRecipeBtn.disabled = true;
try {
const created = await api.post('/recipes', { title, notes, recipe_url, ingredients });
state.recipes.push(created.data);
if (recipeSelect) {
const option = document.createElement('option');
option.value = String(created.data.id);
option.textContent = created.data.title;
recipeSelect.appendChild(option);
recipeSelect.value = String(created.data.id);
}
window.oikos?.showToast(t('recipes.created'), 'success');
} catch (err) {
window.oikos?.showToast(err.data?.error ?? t('common.errorGeneric'), 'error');
} finally {
saveAsRecipeBtn.disabled = false;
}
});
if (presetRecipeId && recipeSelect) {
recipeSelect.value = String(presetRecipeId);
applyRecipe(presetRecipeId);
}
addIngBtn.addEventListener('click', () => {
const tmp = document.createElement('div');
@@ -584,6 +741,11 @@ function buildModalContent({ mode, date, mealType, meal }) {
const hasIngOpen = isEdit && meal.ingredients?.some((i) => !i.on_shopping_list);
const recipeOptions = [
`<option value="">${t('meals.savedRecipePlaceholder')}</option>`,
...state.recipes.map((r) => `<option value="${r.id}" ${isEdit && meal.recipe_id === r.id ? 'selected' : ''}>${esc(r.title)}</option>`),
].join('');
return `
<div class="modal-grid modal-grid--2">
<div class="form-group">
@@ -605,6 +767,21 @@ function buildModalContent({ mode, date, mealType, meal }) {
<div id="modal-autocomplete" class="meal-modal__autocomplete" hidden></div>
</div>
<div class="form-group">
<label class="form-label" for="modal-recipe-id">${t('meals.savedRecipeLabel')}</label>
<select class="form-input" id="modal-recipe-id">${recipeOptions}</select>
</div>
<div class="modal-grid modal-grid--2">
<div class="form-group">
<label class="form-label" for="modal-recipe-scale">${t('meals.recipeScaleLabel')}</label>
<input type="number" class="form-input" id="modal-recipe-scale" min="0.1" step="0.1" value="1">
</div>
<div class="form-group" style="display:flex;align-items:flex-end;">
<button class="btn btn--secondary" id="modal-save-as-recipe" type="button">${t('meals.saveAsRecipe')}</button>
</div>
</div>
<div class="form-group">
<label class="form-label" for="modal-notes">${t('meals.notesLabel')}</label>
<textarea class="form-input" id="modal-notes" rows="2"
@@ -678,19 +855,14 @@ async function saveModal(overlay) {
const title = overlay.querySelector('#modal-title').value.trim();
const notes = overlay.querySelector('#modal-notes').value.trim() || null;
const recipe_url = overlay.querySelector('#modal-recipe-url').value.trim() || null;
const recipe_id = overlay.querySelector('#modal-recipe-id')?.value || null;
if (!title) {
window.oikos?.showToast(t('meals.titleRequired'), 'error');
return;
}
const ingredients = [];
overlay.querySelectorAll('.ingredient-row').forEach((row) => {
const name = row.querySelector('.ingredient-row__name').value.trim();
const qty = row.querySelector('.ingredient-row__qty').value.trim() || null;
const category = row.querySelector('.ingredient-row__cat')?.value || DEFAULT_CATEGORY_NAME;
if (name) ingredients.push({ name, quantity: qty, category, id: row.dataset.ingId || null });
});
const ingredients = collectModalIngredients(overlay);
saveBtn.disabled = true;
saveBtn.textContent = '…';
@@ -699,11 +871,11 @@ async function saveModal(overlay) {
const { mode, meal } = state.modal;
if (mode === 'create') {
const res = await api.post('/meals', { date, meal_type, title, notes, recipe_url, ingredients });
const res = await api.post('/meals', { date, meal_type, title, notes, recipe_url, recipe_id, ingredients });
state.meals.push(res.data);
} else {
// Update meal meta
await api.put(`/meals/${meal.id}`, { date, meal_type, title, notes, recipe_url });
await api.put(`/meals/${meal.id}`, { date, meal_type, title, notes, recipe_url, recipe_id });
// Sync ingredients
const existingIds = new Set((meal.ingredients ?? []).map((i) => i.id));
@@ -732,6 +904,17 @@ async function saveModal(overlay) {
}
}
function collectModalIngredients(overlay) {
const ingredients = [];
overlay.querySelectorAll('.ingredient-row').forEach((row) => {
const name = row.querySelector('.ingredient-row__name').value.trim();
const qty = row.querySelector('.ingredient-row__qty').value.trim() || null;
const category = row.querySelector('.ingredient-row__cat')?.value || DEFAULT_CATEGORY_NAME;
if (name) ingredients.push({ name, quantity: qty, category, id: row.dataset.ingId || null });
});
return ingredients;
}
// --------------------------------------------------------
// Mahlzeit löschen
// --------------------------------------------------------
+372
View File
@@ -0,0 +1,372 @@
/**
* Modul: Rezepte (Recipes)
* Zweck: Gespeicherte Rezepte verwalten und in den Essensplan uebernehmen
*/
import { api } from '/api.js';
import { t } from '/i18n.js';
import { esc } from '/utils/html.js';
import { openModal as openSharedModal, closeModal as closeSharedModal, confirmModal } from '/components/modal.js';
import { DEFAULT_CATEGORY_NAME, categoryLabel } from '/utils/shopping-categories.js';
let _container = null;
const state = {
recipes: [],
categories: [],
};
function mealCategories() {
return state.categories.filter((c) => c.name !== 'Haushalt' && c.name !== 'Drogerie');
}
async function loadRecipes() {
const res = await api.get('/recipes');
state.recipes = res.data;
}
async function loadCategories() {
try {
const res = await api.get('/shopping/categories');
state.categories = res.data;
} catch {
state.categories = [];
}
}
export async function render(container) {
_container = container;
const page = document.createElement('div');
page.className = 'recipes-page';
const header = document.createElement('div');
header.className = 'recipes-header';
const title = document.createElement('h1');
title.className = 'recipes-header__title';
title.textContent = t('recipes.title');
const addBtn = document.createElement('button');
addBtn.className = 'btn btn--primary';
addBtn.type = 'button';
addBtn.id = 'recipes-add';
addBtn.textContent = t('recipes.addRecipe');
header.append(title, addBtn);
const list = document.createElement('div');
list.className = 'recipes-list';
list.id = 'recipes-list';
const fab = document.createElement('button');
fab.className = 'page-fab';
fab.type = 'button';
fab.id = 'recipes-fab';
fab.setAttribute('aria-label', t('recipes.addRecipe'));
const fabIcon = document.createElement('i');
fabIcon.dataset.lucide = 'plus';
fabIcon.setAttribute('aria-hidden', 'true');
fab.appendChild(fabIcon);
page.append(header, list, fab);
container.replaceChildren(page);
if (window.lucide) window.lucide.createIcons();
await Promise.all([loadRecipes(), loadCategories()]);
renderRecipeList();
addBtn.addEventListener('click', () => openRecipeModal('create'));
fab.addEventListener('click', () => openRecipeModal('create'));
list.addEventListener('click', async (e) => {
const actionBtn = e.target.closest('[data-action]');
if (!actionBtn) return;
const recipeId = Number(actionBtn.dataset.id);
const recipe = state.recipes.find((r) => r.id === recipeId);
if (!recipe) return;
if (actionBtn.dataset.action === 'edit') {
openRecipeModal('edit', recipe);
return;
}
if (actionBtn.dataset.action === 'delete') {
await removeRecipe(recipe);
return;
}
if (actionBtn.dataset.action === 'duplicate') {
await duplicateRecipe(recipe);
return;
}
if (actionBtn.dataset.action === 'add-to-meals') {
window.oikos?.navigate(`/meals?recipe=${recipe.id}`);
}
});
}
function renderRecipeList() {
const list = _container.querySelector('#recipes-list');
if (!list) return;
list.replaceChildren();
if (!state.recipes.length) {
const empty = document.createElement('div');
empty.className = 'empty-state';
const emptyTitle = document.createElement('div');
emptyTitle.className = 'empty-state__title';
emptyTitle.textContent = t('recipes.emptyTitle');
const emptyDesc = document.createElement('div');
emptyDesc.className = 'empty-state__description';
emptyDesc.textContent = t('recipes.emptyDescription');
empty.append(emptyTitle, emptyDesc);
list.appendChild(empty);
return;
}
for (const recipe of state.recipes) {
const card = document.createElement('article');
card.className = 'recipe-card';
const h = document.createElement('h2');
h.className = 'recipe-card__title';
h.textContent = recipe.title;
card.appendChild(h);
if (recipe.notes) {
const notes = document.createElement('p');
notes.className = 'recipe-card__notes';
notes.textContent = recipe.notes;
card.appendChild(notes);
}
if (recipe.recipe_url) {
const link = document.createElement('a');
link.className = 'btn btn--ghost';
link.href = recipe.recipe_url;
link.target = '_blank';
link.rel = 'noopener noreferrer';
link.textContent = t('recipes.openLink');
card.appendChild(link);
}
const ingredients = recipe.ingredients ?? [];
if (ingredients.length) {
const ul = document.createElement('ul');
ul.className = 'recipe-card__ingredients';
for (const ing of ingredients) {
const li = document.createElement('li');
li.className = 'recipe-card__ingredient';
const qty = ing.quantity ? `${ing.quantity} · ` : '';
li.textContent = `${qty}${ing.name}`;
ul.appendChild(li);
}
card.appendChild(ul);
}
const actions = document.createElement('div');
actions.className = 'recipe-card__actions';
const addToMeals = document.createElement('button');
addToMeals.className = 'btn btn--secondary';
addToMeals.type = 'button';
addToMeals.dataset.action = 'add-to-meals';
addToMeals.dataset.id = String(recipe.id);
addToMeals.textContent = t('recipes.addToMeals');
const edit = document.createElement('button');
edit.className = 'btn btn--secondary';
edit.type = 'button';
edit.dataset.action = 'edit';
edit.dataset.id = String(recipe.id);
edit.textContent = t('common.edit');
const del = document.createElement('button');
del.className = 'btn btn--danger';
del.type = 'button';
del.dataset.action = 'delete';
del.dataset.id = String(recipe.id);
del.textContent = t('common.delete');
const duplicate = document.createElement('button');
duplicate.className = 'btn btn--secondary';
duplicate.type = 'button';
duplicate.dataset.action = 'duplicate';
duplicate.dataset.id = String(recipe.id);
duplicate.textContent = t('recipes.duplicate');
actions.append(addToMeals, edit, duplicate, del);
card.appendChild(actions);
list.appendChild(card);
}
}
function recipeIngredientRowHTML(name, qty, category = DEFAULT_CATEGORY_NAME) {
const categories = mealCategories();
const resolvedCategory = categories.some((c) => c.name === category)
? category
: (categories[0]?.name ?? DEFAULT_CATEGORY_NAME);
const catOptions = categories.length
? categories.map((c) => `<option value="${esc(c.name)}" ${c.name === resolvedCategory ? 'selected' : ''}>${esc(categoryLabel(c.name))}</option>`).join('')
: `<option value="${DEFAULT_CATEGORY_NAME}" selected>${t('meals.ingredientCategoryDefault')}</option>`;
return `
<div class="recipe-ingredient-row">
<input type="text" class="form-input recipe-ingredient-row__name" placeholder="${t('meals.ingredientNamePlaceholder')}" value="${esc(name)}">
<input type="text" class="form-input recipe-ingredient-row__qty" placeholder="${t('meals.ingredientQtyPlaceholder')}" value="${esc(qty)}">
<select class="form-input recipe-ingredient-row__cat" aria-label="${t('meals.ingredientCategoryLabel')}">${catOptions}</select>
<button class="recipe-ingredient-row__remove" data-action="remove-ingredient" type="button" aria-label="${t('meals.removeIngredient')}">
<i data-lucide="x" style="width:14px;height:14px;" aria-hidden="true"></i>
</button>
</div>
`;
}
function openRecipeModal(mode, recipe = null) {
const isEdit = mode === 'edit';
const ingredientRows = isEdit && recipe.ingredients?.length
? recipe.ingredients.map((i) => recipeIngredientRowHTML(i.name, i.quantity ?? '', i.category ?? DEFAULT_CATEGORY_NAME)).join('')
: '';
openSharedModal({
title: isEdit ? t('recipes.editRecipe') : t('recipes.addRecipe'),
size: 'md',
content: `
<div class="form-group">
<label class="form-label" for="recipe-title">${t('recipes.titleLabel')}</label>
<input id="recipe-title" class="form-input" type="text" value="${esc(isEdit ? recipe.title : '')}" placeholder="${t('recipes.titlePlaceholder')}">
</div>
<div class="form-group">
<label class="form-label" for="recipe-notes">${t('recipes.notesLabel')}</label>
<textarea id="recipe-notes" class="form-input" rows="3" placeholder="${t('recipes.notesPlaceholder')}">${esc(isEdit && recipe.notes ? recipe.notes : '')}</textarea>
</div>
<div class="form-group">
<label class="form-label" for="recipe-url">${t('recipes.urlLabel')}</label>
<input id="recipe-url" class="form-input" type="url" value="${esc(isEdit && recipe.recipe_url ? recipe.recipe_url : '')}" placeholder="${t('recipes.urlPlaceholder')}">
</div>
<div class="form-group">
<label class="form-label">${t('recipes.ingredientsLabel')}</label>
<div class="recipe-ingredient-list" id="recipe-ingredient-list">${ingredientRows}</div>
<button class="btn btn--secondary recipe-add-ingredient" type="button" id="recipe-add-ingredient">${t('meals.addIngredient')}</button>
</div>
<div class="modal-panel__footer" style="border:none;padding:0;margin-top:var(--space-4)">
<button class="btn btn--secondary" id="recipe-cancel">${t('common.cancel')}</button>
<button class="btn btn--primary" id="recipe-save">${isEdit ? t('common.save') : t('common.add')}</button>
</div>
`,
onSave(panel) {
const ingList = panel.querySelector('#recipe-ingredient-list');
panel.querySelector('#recipe-add-ingredient')?.addEventListener('click', () => {
const tmp = document.createElement('div');
tmp.innerHTML = recipeIngredientRowHTML('', '', null);
const row = tmp.firstElementChild;
ingList.appendChild(row);
if (window.lucide) window.lucide.createIcons();
});
ingList.addEventListener('click', (e) => {
const btn = e.target.closest('[data-action="remove-ingredient"]');
if (!btn) return;
btn.closest('.recipe-ingredient-row')?.remove();
});
panel.querySelector('#recipe-cancel')?.addEventListener('click', closeModal);
panel.querySelector('#recipe-save')?.addEventListener('click', () => saveRecipe(panel, mode, recipe));
if (window.lucide) window.lucide.createIcons();
},
});
}
function closeModal() {
closeSharedModal();
}
async function saveRecipe(panel, mode, recipe) {
const saveBtn = panel.querySelector('#recipe-save');
const title = panel.querySelector('#recipe-title')?.value.trim() || '';
const notes = panel.querySelector('#recipe-notes')?.value.trim() || null;
const recipe_url = panel.querySelector('#recipe-url')?.value.trim() || null;
if (!title) {
window.oikos?.showToast(t('recipes.titleRequired'), 'error');
return;
}
const ingredients = [];
panel.querySelectorAll('.recipe-ingredient-row').forEach((row) => {
const name = row.querySelector('.recipe-ingredient-row__name')?.value.trim() || '';
const quantity = row.querySelector('.recipe-ingredient-row__qty')?.value.trim() || null;
const category = row.querySelector('.recipe-ingredient-row__cat')?.value || DEFAULT_CATEGORY_NAME;
if (name) ingredients.push({ name, quantity, category });
});
saveBtn.disabled = true;
try {
if (mode === 'create') {
const res = await api.post('/recipes', { title, notes, recipe_url, ingredients });
state.recipes.push(res.data);
} else {
const res = await api.put(`/recipes/${recipe.id}`, { title, notes, recipe_url, ingredients });
const idx = state.recipes.findIndex((r) => r.id === recipe.id);
if (idx >= 0) state.recipes[idx] = res.data;
}
closeModal();
renderRecipeList();
window.oikos?.showToast(mode === 'create' ? t('recipes.created') : t('recipes.updated'), 'success');
} catch (err) {
saveBtn.disabled = false;
window.oikos?.showToast(err.data?.error ?? t('common.errorGeneric'), 'error');
}
}
async function removeRecipe(recipe) {
const ok = await confirmModal(t('recipes.deleteConfirm', { title: recipe.title }), {
danger: true,
confirmLabel: t('common.delete'),
});
if (!ok) return;
try {
await api.delete(`/recipes/${recipe.id}`);
state.recipes = state.recipes.filter((r) => r.id !== recipe.id);
renderRecipeList();
window.oikos?.showToast(t('recipes.deleted'), 'success');
} catch (err) {
window.oikos?.showToast(err.data?.error ?? t('common.errorGeneric'), 'error');
}
}
async function duplicateRecipe(recipe) {
const copySuffix = t('recipes.copySuffix');
const title = `${recipe.title} (${copySuffix})`;
const notes = recipe.notes || null;
const recipe_url = recipe.recipe_url || null;
const ingredients = (recipe.ingredients || []).map((ing) => ({
name: ing.name,
quantity: ing.quantity || null,
category: ing.category || DEFAULT_CATEGORY_NAME,
}));
try {
await api.post('/recipes', { title, notes, recipe_url, ingredients });
await loadRecipes();
renderRecipeList();
window.oikos?.showToast(t('recipes.duplicated'), 'success');
} catch (err) {
window.oikos?.showToast(err.data?.error ?? t('common.errorGeneric'), 'error');
}
}
+3 -1
View File
@@ -20,6 +20,7 @@ const ROUTES = [
{ path: '/meals', page: '/pages/meals.js', requiresAuth: true, module: 'meals' },
{ path: '/calendar', page: '/pages/calendar.js', requiresAuth: true, module: 'calendar' },
{ path: '/notes', page: '/pages/notes.js', requiresAuth: true, module: 'notes' },
{ path: '/recipes', page: '/pages/recipes.js', requiresAuth: true, module: 'recipes' },
{ path: '/contacts', page: '/pages/contacts.js', requiresAuth: true, module: 'contacts' },
{ path: '/budget', page: '/pages/budget.js', requiresAuth: true, module: 'budget' },
{ path: '/settings', page: '/pages/settings.js', requiresAuth: true, module: 'settings' },
@@ -123,7 +124,7 @@ let _pendingLoginRedirect = false;
// Router
// --------------------------------------------------------
const ROUTE_ORDER = ['/', '/tasks', '/calendar', '/meals', '/shopping',
const ROUTE_ORDER = ['/', '/tasks', '/calendar', '/meals', '/recipes', '/shopping',
'/notes', '/contacts', '/budget', '/settings'];
const PRIMARY_NAV = 4;
@@ -581,6 +582,7 @@ function navItems() {
{ path: '/tasks', label: t('nav.tasks'), icon: 'check-square' },
{ path: '/calendar', label: t('nav.calendar'), icon: 'calendar' },
{ path: '/meals', label: t('nav.meals'), icon: 'utensils' },
{ path: '/recipes', label: t('nav.recipes'), icon: 'book-open-text' },
{ path: '/shopping', label: t('nav.shopping'), icon: 'shopping-cart' },
{ path: '/notes', label: t('nav.notes'), icon: 'sticky-note' },
{ path: '/contacts', label: t('nav.contacts'), icon: 'book-user' },
+119
View File
@@ -0,0 +1,119 @@
/**
* Modul: Rezepte (Recipes)
* Zweck: Styles fuer gespeicherte Rezepte und Aktionskarten
*/
.recipes-page {
--module-accent: var(--module-recipes);
display: flex;
flex-direction: column;
height: calc(100dvh - var(--safe-area-inset-top) - var(--nav-bottom-height) - var(--safe-area-inset-bottom));
max-width: var(--content-max-width);
margin: 0 auto;
overflow: hidden;
}
@media (min-width: 1024px) {
.recipes-page {
height: 100dvh;
}
}
.recipes-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-3);
padding: var(--space-4);
border-top: 3px solid var(--module-accent);
border-bottom: 1px solid var(--color-border);
background-color: var(--color-surface);
}
.recipes-header__title {
margin: 0;
font-size: var(--text-xl);
}
.recipes-list {
flex: 1;
overflow-y: auto;
padding: var(--space-4);
display: grid;
gap: var(--space-3);
align-content: start;
}
.recipe-card {
border: 1px solid var(--color-border);
border-radius: var(--radius-md);
background: var(--color-surface);
box-shadow: var(--shadow-sm);
padding: var(--space-4);
display: grid;
gap: var(--space-2);
}
.recipe-card__title {
margin: 0;
font-size: var(--text-base);
color: var(--color-text-primary);
}
.recipe-card__notes {
margin: 0;
color: var(--color-text-secondary);
font-size: var(--text-sm);
white-space: pre-wrap;
}
.recipe-card__ingredients {
margin: 0;
padding: 0;
list-style: none;
display: grid;
gap: var(--space-1);
}
.recipe-card__ingredient {
font-size: var(--text-sm);
color: var(--color-text-secondary);
}
.recipe-card__actions {
display: flex;
gap: var(--space-2);
flex-wrap: wrap;
}
.recipe-ingredient-list {
display: grid;
gap: var(--space-2);
}
.recipe-ingredient-row {
display: flex;
gap: var(--space-2);
align-items: center;
}
.recipe-ingredient-row__name {
flex: 2;
}
.recipe-ingredient-row__qty,
.recipe-ingredient-row__cat {
flex: 1;
min-width: 0;
}
.recipe-ingredient-row__remove {
border: none;
background: none;
color: var(--color-text-secondary);
cursor: pointer;
}
.recipe-add-ingredient {
align-self: flex-start;
}
+2
View File
@@ -154,6 +154,8 @@
--module-calendar: var(--_module-calendar); /* Violett - Termine, Zeit */
--_module-meals: #C2410C;
--module-meals: var(--_module-meals); /* Orange-700 - Essen, Wärme */
--_module-recipes: #0D9488;
--module-recipes: var(--_module-recipes); /* Teal-600 - Rezepte */
--_module-shopping: #DB2777;
--module-shopping: var(--_module-shopping); /* Pink-600 - Einkaufen (trennt von Meals) */
--_module-notes: #A16207;