All checks were successful
parsley/pipeline/head This commit looks good
- Remove duplicate Save buttons in log creator/editor (fired with null data before recipe loaded) - Redirect to new resource after creating recipe/log instead of dropping back to list - Fix TheFoodCreator Cancel linking to dead route /food → /foods - Refactor AppSearchText to use defineModel; fix search box not initializing from URL - Fix TheCalculator variable shadowing bug (ingredient ref never updated on food select) - Refactor UsdaImporter to use insert_all! instead of per-record save! (~240k branded foods) - Fix string-based ndbn min comparison in build_enumerator (fragile on non-padded IDs) - Add CLAUDE.md with project overview and architecture notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
53 lines
1.3 KiB
Vue
53 lines
1.3 KiB
Vue
<template>
|
|
<div>
|
|
|
|
<h1 class="title">Creating {{ recipe.name || "[Unamed Recipe]" }}</h1>
|
|
|
|
<app-validation-errors :errors="validationErrors"></app-validation-errors>
|
|
|
|
<recipe-edit :recipe="recipe" action="Creating"></recipe-edit>
|
|
|
|
<button type="button" class="button is-primary" @click="save">Save</button>
|
|
<router-link class="button is-secondary" to="/">Cancel</router-link>
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
|
|
import { ref } from "vue";
|
|
import { useRouter } from "vue-router";
|
|
import RecipeEdit from "./RecipeEdit";
|
|
import api from "../lib/Api";
|
|
import * as Errors from '../lib/Errors';
|
|
import { useLoadResource } from "../lib/useLoadResource";
|
|
|
|
const router = useRouter();
|
|
const { loadResource } = useLoadResource();
|
|
|
|
const validationErrors = ref({});
|
|
const recipe = ref({
|
|
name: null,
|
|
source: null,
|
|
description: null,
|
|
yields: null,
|
|
total_time: null,
|
|
active_time: null,
|
|
step_text: null,
|
|
tags: [],
|
|
ingredients: []
|
|
});
|
|
|
|
function save() {
|
|
validationErrors.value = {};
|
|
loadResource(
|
|
api.postRecipe(recipe.value)
|
|
.then(data => router.push({ name: 'recipe', params: { id: data.id } }))
|
|
.catch(Errors.onlyFor(Errors.ApiValidationError, err => validationErrors.value = err.validationErrors()))
|
|
);
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
</style> |