parsley/app/javascript/components/TheRecipe.vue

55 lines
1.1 KiB
Vue
Raw Normal View History

2018-04-01 21:43:23 -05:00
<template>
<div>
<div v-if="recipe === null">
Loading...
</div>
<div v-else>
2018-04-14 15:04:08 -05:00
<h1 class="title">{{ recipe.name }}</h1>
<div class="subtitle tags">
<span v-for="tag in recipe.tags" :key="tag" class="tag is-medium">{{tag}}</span>
</div>
<hr>
2018-04-01 21:43:23 -05:00
<recipe-show :recipe="recipe"></recipe-show>
</div>
2018-04-03 18:31:20 -05:00
<router-link v-if="isLoggedIn" class="button" :to="{name: 'edit_recipe', params: { id: recipeId }}">Edit</router-link>
2018-04-01 22:32:13 -05:00
<router-link class="button" to="/">Back</router-link>
2018-04-01 21:43:23 -05:00
</div>
</template>
<script>
import RecipeShow from "./RecipeShow";
import { mapState } from "vuex";
import api from "../lib/Api";
export default {
data: function () {
return {
recipe: null,
showNutrition: false
}
},
computed: {
...mapState({
recipeId: state => state.route.params.id,
})
},
created() {
this.loadResource(
api.getRecipe(this.recipeId)
.then(data => { this.recipe = data; return data; })
);
},
components: {
RecipeShow
}
}
</script>
<style lang="scss" scoped>
</style>