parsley/app/javascript/components/TheLogEditor.vue
Dan Elbert 233cea022a
All checks were successful
parsley/pipeline/head This commit looks good
Fix usability bugs and USDA importer performance
- 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>
2026-04-20 14:42:22 -05:00

51 lines
1.3 KiB
Vue

<template>
<div>
<log-edit v-if="log !== 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, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import api from "../lib/Api";
import * as Errors from "../lib/Errors";
import LogEdit from "./LogEdit";
import { useLoadResource } from "../lib/useLoadResource";
const { loadResource } = useLoadResource();
const route = useRoute();
const router = useRouter();
const validationErrors = ref({});
const log = ref(null);
const logId = computed(() => route.params.id);
onBeforeMount(() => {
loadResource(
api.getLog(logId.value)
.then(data => { log.value = data; return data; })
);
});
function save() {
validationErrors.value = {};
loadResource(
api.patchLog(log.value)
.then(() => router.push({ name: 'log', params: { id: log.value.id } }))
.catch(Errors.onlyFor(Errors.ApiValidationError, err => validationErrors.value = err.validationErrors()))
);
}
</script>
<style lang="scss" scoped>
</style>