2018-03-30 14:31:09 -05:00
|
|
|
<template>
|
2018-04-01 21:43:23 -05:00
|
|
|
<div>
|
|
|
|
<h1 class="title">{{ action }} {{ recipe.name || "[Unamed Recipe]" }}</h1>
|
2018-03-30 14:31:09 -05:00
|
|
|
|
2018-04-01 21:43:23 -05:00
|
|
|
<div class="columns">
|
|
|
|
<div class="column">
|
|
|
|
<div class="field">
|
|
|
|
<label class="label is-small-mobile">Name</label>
|
|
|
|
<div class="control">
|
|
|
|
<input class="input is-small-mobile" type="text" placeholder="name" v-model="recipe.name">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="column">
|
|
|
|
<div class="field">
|
|
|
|
<label class="label is-small-mobile">Source</label>
|
|
|
|
<div class="control">
|
|
|
|
<input class="input is-small-mobile" type="text" placeholder="source" v-model="recipe.source">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
<label class="label is-small-mobile">Description</label>
|
|
|
|
<div class="control">
|
|
|
|
<textarea class="textarea is-small-mobile" placeholder="description" v-model="recipe.description"></textarea>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
<label class="label is-small-mobile">Tags</label>
|
2018-04-03 18:31:20 -05:00
|
|
|
<app-tag-editor v-model="recipe.tags"></app-tag-editor>
|
2018-04-01 21:43:23 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="columns">
|
|
|
|
<div class="column">
|
|
|
|
<div class="field">
|
|
|
|
<label class="label is-small-mobile">Yields</label>
|
|
|
|
<div class="control">
|
|
|
|
<input class="input is-small-mobile" type="text" placeholder="servings" v-model="recipe.yields">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="column">
|
|
|
|
<div class="field">
|
|
|
|
<label class="label is-small-mobile">Total Time</label>
|
|
|
|
<div class="control">
|
|
|
|
<input class="input is-small-mobile" type="number" placeholder="minutes" v-model="recipe.total_time">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="column">
|
|
|
|
<div class="field">
|
|
|
|
<label class="label is-small-mobile">Active Time</label>
|
|
|
|
<div class="control">
|
|
|
|
<input class="input is-small-mobile" type="number" placeholder="minutes" v-model="recipe.active_time">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<h3 class="title is-4">Ingredients</h3>
|
|
|
|
|
|
|
|
<recipe-edit-ingredient-editor :ingredients="recipe.ingredients"></recipe-edit-ingredient-editor>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
<label class="label title is-4">Directions</label>
|
|
|
|
<div class="control columns">
|
|
|
|
<div class="column">
|
2018-04-04 19:46:02 -05:00
|
|
|
<textarea ref="step_text_area" class="textarea directions-input" v-model="recipe.step_text"></textarea>
|
2018-04-01 21:43:23 -05:00
|
|
|
</div>
|
|
|
|
<div class="column">
|
|
|
|
<div class="box content" v-html="stepPreview">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
2018-03-30 14:31:09 -05:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
2018-04-01 21:43:23 -05:00
|
|
|
import autosize from "autosize";
|
|
|
|
import debounce from "lodash/debounce";
|
|
|
|
import api from "../lib/Api";
|
|
|
|
|
|
|
|
import RecipeEditIngredientEditor from "./RecipeEditIngredientEditor";
|
|
|
|
|
2018-03-30 14:31:09 -05:00
|
|
|
export default {
|
2018-04-01 21:43:23 -05:00
|
|
|
props: {
|
|
|
|
recipe: {
|
|
|
|
required: true,
|
|
|
|
type: Object
|
|
|
|
},
|
|
|
|
action: {
|
|
|
|
required: false,
|
|
|
|
type: String,
|
|
|
|
default: "Editing"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
stepPreviewCache: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
stepPreview() {
|
|
|
|
if (this.stepPreviewCache === null) {
|
|
|
|
return this.recipe.rendered_steps;
|
|
|
|
} else {
|
|
|
|
return this.stepPreviewCache;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-03-30 14:31:09 -05:00
|
|
|
|
2018-04-01 21:43:23 -05:00
|
|
|
methods: {
|
|
|
|
|
|
|
|
updatePreview: debounce(function() {
|
|
|
|
api.postPreviewSteps(this.recipe.step_text)
|
|
|
|
.then(data => this.stepPreviewCache = data.rendered_steps)
|
|
|
|
.catch(err => this.stepPreviewCache = "?? Error ??");
|
|
|
|
}, 750)
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
'recipe.step_text': function() {
|
|
|
|
this.updatePreview();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2018-04-04 19:46:02 -05:00
|
|
|
//autosize(this.$refs.step_text_area);
|
2018-04-01 21:43:23 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
|
|
|
RecipeEditIngredientEditor
|
|
|
|
}
|
2018-03-30 14:31:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2018-04-01 21:43:23 -05:00
|
|
|
.bulk-input {
|
|
|
|
height: 100%;
|
|
|
|
}
|
2018-04-04 19:46:02 -05:00
|
|
|
|
|
|
|
.directions-input {
|
|
|
|
height: 100%;
|
|
|
|
}
|
2018-03-30 14:31:09 -05:00
|
|
|
</style>
|