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>
57 lines
1.5 KiB
Vue
57 lines
1.5 KiB
Vue
<template>
|
|
<div>
|
|
|
|
<log-edit v-if="log.recipe !== null" :log="log" :validation-errors="validationErrors">
|
|
<div class="buttons">
|
|
<button type="button" class="button is-primary" @click="save">Save Log</button>
|
|
<router-link class="button is-secondary" to="/">Cancel</router-link>
|
|
</div>
|
|
</log-edit>
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
|
|
import { computed, onBeforeMount, reactive, ref } from "vue";
|
|
import { useRoute, useRouter } from "vue-router";
|
|
import LogEdit from "./LogEdit";
|
|
import api from "../lib/Api";
|
|
import * as Errors from '../lib/Errors';
|
|
import { useLoadResource } from "../lib/useLoadResource";
|
|
|
|
const { loadResource } = useLoadResource();
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
|
|
const validationErrors = ref({});
|
|
const log = reactive({
|
|
date: null,
|
|
rating: null,
|
|
notes: null,
|
|
recipe: null
|
|
});
|
|
|
|
const recipeId = computed(() => route.params.recipeId);
|
|
|
|
onBeforeMount(() => {
|
|
loadResource(
|
|
api.getRecipe(recipeId.value, null, null, null, data => log.recipe = data)
|
|
);
|
|
});
|
|
|
|
function save() {
|
|
log.original_recipe_id = recipeId.value;
|
|
validationErrors.value = {};
|
|
|
|
loadResource(
|
|
api.postLog(log)
|
|
.then(data => router.push({ name: 'log', params: { id: data.id } }))
|
|
.catch(Errors.onlyFor(Errors.ApiValidationError, err => validationErrors.value = err.validationErrors()))
|
|
);
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
</style> |