2018-04-02 00:10:06 -05:00
|
|
|
<template>
|
|
|
|
<div>
|
2018-09-11 22:56:26 -05:00
|
|
|
<div v-if="food === null">
|
2018-04-02 00:10:06 -05:00
|
|
|
Loading...
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
2018-09-11 22:56:26 -05:00
|
|
|
<food-show :food="food"></food-show>
|
2018-04-02 00:10:06 -05:00
|
|
|
</div>
|
|
|
|
|
2018-09-11 22:56:26 -05:00
|
|
|
<router-link v-if="isLoggedIn" class="button" :to="{name: 'edit_food', params: { id: foodId }}">Edit</router-link>
|
|
|
|
<router-link class="button" to="/foods">Back</router-link>
|
2018-04-02 00:10:06 -05:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
2018-09-11 22:56:26 -05:00
|
|
|
import FoodShow from "./FoodShow";
|
2018-04-02 00:10:06 -05:00
|
|
|
import api from "../lib/Api";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data: function () {
|
|
|
|
return {
|
2018-09-11 22:56:26 -05:00
|
|
|
food: null
|
2018-04-02 00:10:06 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2024-09-28 20:58:25 -05:00
|
|
|
foodId() {
|
|
|
|
return this.$route.params.id;
|
|
|
|
}
|
2018-04-02 00:10:06 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.loadResource(
|
2018-09-11 22:56:26 -05:00
|
|
|
api.getFood(this.foodId)
|
|
|
|
.then(data => { this.food = data; return data; })
|
2018-04-02 00:10:06 -05:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
2018-09-11 22:56:26 -05:00
|
|
|
FoodShow
|
2018-04-02 00:10:06 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
</style>
|