2020-12-24 16:37:38 -09:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<v-card-text>
|
|
|
|
<v-row dense>
|
|
|
|
<v-col cols="3"></v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-file-input
|
|
|
|
v-model="fileObject"
|
2021-01-17 22:22:54 -09:00
|
|
|
:label="$t('general.image-file')"
|
2020-12-24 16:37:38 -09:00
|
|
|
truncate-length="30"
|
|
|
|
@change="uploadImage"
|
|
|
|
></v-file-input>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="3"></v-col>
|
2021-01-17 22:22:54 -09:00
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-text-field
|
|
|
|
label="Total Time"
|
|
|
|
v-model="value.totalTime"
|
|
|
|
></v-text-field>
|
|
|
|
</v-col>
|
|
|
|
<v-col
|
|
|
|
><v-text-field
|
|
|
|
label="Prep Time"
|
|
|
|
v-model="value.prepTime"
|
|
|
|
></v-text-field
|
|
|
|
></v-col>
|
|
|
|
<v-col
|
|
|
|
><v-text-field
|
|
|
|
label="Cook Time / Perform Time"
|
|
|
|
v-model="value.performTime"
|
|
|
|
></v-text-field
|
|
|
|
></v-col>
|
|
|
|
</v-row>
|
2020-12-24 16:37:38 -09:00
|
|
|
</v-row>
|
2021-01-17 22:22:54 -09:00
|
|
|
<v-text-field class="my-3" :label="$t('recipe.recipe-name')" v-model="value.name">
|
2020-12-24 16:37:38 -09:00
|
|
|
</v-text-field>
|
2021-01-17 22:22:54 -09:00
|
|
|
<v-textarea height="100" :label="$t('recipe.description')" v-model="value.description">
|
2020-12-24 16:37:38 -09:00
|
|
|
</v-textarea>
|
|
|
|
<div class="my-2"></div>
|
|
|
|
<v-row dense disabled>
|
|
|
|
<v-col sm="5">
|
2021-01-17 22:22:54 -09:00
|
|
|
<v-text-field :label="$t('recipe.servings')" v-model="value.recipeYield">
|
2020-12-24 16:37:38 -09:00
|
|
|
</v-text-field>
|
|
|
|
</v-col>
|
|
|
|
<v-col></v-col>
|
|
|
|
<v-rating
|
|
|
|
class="mr-2 align-end"
|
2020-12-24 19:32:49 -09:00
|
|
|
color="secondary darken-1"
|
|
|
|
background-color="secondary lighten-3"
|
2020-12-24 16:37:38 -09:00
|
|
|
length="5"
|
|
|
|
v-model="value.rating"
|
|
|
|
></v-rating>
|
|
|
|
</v-row>
|
|
|
|
<v-row>
|
|
|
|
<v-col cols="12" sm="12" md="4" lg="4">
|
2021-01-17 22:22:54 -09:00
|
|
|
<h2 class="mb-4">{{$t('recipe.ingredients')}}</h2>
|
2020-12-24 16:37:38 -09:00
|
|
|
<div
|
|
|
|
v-for="(ingredient, index) in value.recipeIngredient"
|
|
|
|
:key="generateKey('ingredient', index)"
|
|
|
|
>
|
|
|
|
<v-row align="center">
|
|
|
|
<v-btn
|
|
|
|
fab
|
|
|
|
x-small
|
|
|
|
color="white"
|
|
|
|
class="mr-2"
|
|
|
|
elevation="0"
|
|
|
|
@click="removeIngredient(index)"
|
|
|
|
>
|
|
|
|
<v-icon color="error">mdi-delete</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-text-field
|
2021-01-17 22:22:54 -09:00
|
|
|
:label="$t('recipe.ingredient')"
|
2020-12-24 16:37:38 -09:00
|
|
|
v-model="value.recipeIngredient[index]"
|
|
|
|
></v-text-field>
|
|
|
|
</v-row>
|
|
|
|
</div>
|
|
|
|
<v-btn color="secondary" fab dark small @click="addIngredient">
|
|
|
|
<v-icon>mdi-plus</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<BulkAdd @bulk-data="appendIngredients" />
|
|
|
|
|
2021-01-17 22:22:54 -09:00
|
|
|
<h2 class="mt-6">{{$t('recipe.categories')}}</h2>
|
2020-12-24 16:37:38 -09:00
|
|
|
<v-combobox
|
|
|
|
dense
|
|
|
|
multiple
|
|
|
|
chips
|
|
|
|
item-color="secondary"
|
|
|
|
deletable-chips
|
|
|
|
v-model="value.categories"
|
|
|
|
>
|
|
|
|
<template v-slot:selection="data">
|
2021-01-03 10:01:49 -09:00
|
|
|
<v-chip
|
|
|
|
:input-value="data.selected"
|
|
|
|
close
|
|
|
|
@click:close="removeCategory(data.index)"
|
|
|
|
color="secondary"
|
|
|
|
dark
|
|
|
|
>
|
2020-12-24 16:37:38 -09:00
|
|
|
{{ data.item }}
|
|
|
|
</v-chip>
|
|
|
|
</template>
|
|
|
|
</v-combobox>
|
|
|
|
|
2021-01-17 22:22:54 -09:00
|
|
|
<h2 class="mt-4">{{$t('recipe.tags')}}</h2>
|
2020-12-24 16:37:38 -09:00
|
|
|
<v-combobox dense multiple chips deletable-chips v-model="value.tags">
|
|
|
|
<template v-slot:selection="data">
|
2021-01-03 10:01:49 -09:00
|
|
|
<v-chip
|
|
|
|
:input-value="data.selected"
|
|
|
|
close
|
|
|
|
@click:close="removeTags(data.index)"
|
|
|
|
color="secondary"
|
|
|
|
dark
|
|
|
|
>
|
2020-12-24 16:37:38 -09:00
|
|
|
{{ data.item }}
|
|
|
|
</v-chip>
|
|
|
|
</template>
|
|
|
|
</v-combobox>
|
|
|
|
|
2021-01-17 22:22:54 -09:00
|
|
|
<h2 class="my-4">{{$t('recipe.notes')}}</h2>
|
2020-12-24 16:37:38 -09:00
|
|
|
<v-card
|
|
|
|
class="mt-1"
|
|
|
|
v-for="(note, index) in value.notes"
|
|
|
|
:key="generateKey('note', index)"
|
|
|
|
>
|
|
|
|
<v-card-text>
|
|
|
|
<v-row align="center">
|
|
|
|
<v-btn
|
|
|
|
fab
|
|
|
|
x-small
|
|
|
|
color="white"
|
|
|
|
class="mr-2"
|
|
|
|
elevation="0"
|
|
|
|
@click="removeNote(index)"
|
|
|
|
>
|
|
|
|
<v-icon color="error">mdi-delete</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-text-field
|
|
|
|
label="Title"
|
|
|
|
v-model="value.notes[index]['title']"
|
|
|
|
></v-text-field>
|
|
|
|
</v-row>
|
|
|
|
|
2021-01-17 22:22:54 -09:00
|
|
|
<v-textarea :label="$t('recipe.note')" v-model="value.notes[index]['text']">
|
2020-12-24 16:37:38 -09:00
|
|
|
</v-textarea>
|
|
|
|
</v-card-text>
|
|
|
|
</v-card>
|
|
|
|
<v-btn class="mt-1" color="secondary" fab dark small @click="addNote">
|
|
|
|
<v-icon>mdi-plus</v-icon>
|
|
|
|
</v-btn>
|
2021-01-08 19:30:54 -09:00
|
|
|
<ExtrasEditor :extras="value.extras" @save="saveExtras" />
|
2020-12-24 16:37:38 -09:00
|
|
|
</v-col>
|
|
|
|
|
|
|
|
<v-divider class="my-divider" :vertical="true"></v-divider>
|
|
|
|
|
|
|
|
<v-col cols="12" sm="12" md="8" lg="8">
|
2021-01-17 22:22:54 -09:00
|
|
|
<h2 class="mb-4">{{$t('recipe.instructions')}}</h2>
|
2020-12-24 16:37:38 -09:00
|
|
|
<div v-for="(step, index) in value.recipeInstructions" :key="index">
|
|
|
|
<v-hover v-slot="{ hover }">
|
|
|
|
<v-card
|
|
|
|
class="ma-1"
|
|
|
|
:class="[{ 'on-hover': hover }]"
|
|
|
|
:elevation="hover ? 12 : 2"
|
|
|
|
>
|
|
|
|
<v-card-title>
|
|
|
|
<v-btn
|
|
|
|
fab
|
|
|
|
x-small
|
|
|
|
color="white"
|
|
|
|
class="mr-2"
|
|
|
|
elevation="0"
|
|
|
|
@click="removeStep(index)"
|
|
|
|
>
|
|
|
|
<v-icon color="error">mdi-delete</v-icon> </v-btn
|
2021-01-17 22:22:54 -09:00
|
|
|
>{{ $t('recipe.step-index', {step: index + 1}) }}</v-card-title
|
2020-12-24 16:37:38 -09:00
|
|
|
>
|
|
|
|
<v-card-text>
|
|
|
|
<v-textarea
|
|
|
|
dense
|
|
|
|
v-model="value.recipeInstructions[index]['text']"
|
|
|
|
:key="generateKey('instructions', index)"
|
|
|
|
></v-textarea>
|
|
|
|
</v-card-text>
|
|
|
|
</v-card>
|
|
|
|
</v-hover>
|
|
|
|
</div>
|
|
|
|
<v-btn color="secondary" fab dark small @click="addStep">
|
|
|
|
<v-icon>mdi-plus</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<BulkAdd @bulk-data="appendSteps" />
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-card-text>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-01-08 17:09:03 -09:00
|
|
|
import api from "../../../api";
|
|
|
|
import utils from "../../../utils";
|
2020-12-24 16:37:38 -09:00
|
|
|
import BulkAdd from "./BulkAdd";
|
2021-01-08 19:30:54 -09:00
|
|
|
import ExtrasEditor from "./ExtrasEditor";
|
2020-12-24 16:37:38 -09:00
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
BulkAdd,
|
2021-01-08 19:30:54 -09:00
|
|
|
ExtrasEditor,
|
2020-12-24 16:37:38 -09:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
value: Object,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fileObject: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
uploadImage() {
|
|
|
|
this.$emit("upload", this.fileObject);
|
|
|
|
},
|
|
|
|
async updateImage() {
|
|
|
|
let slug = this.value.slug;
|
|
|
|
api.recipes.updateImage(slug, this.fileObject);
|
|
|
|
},
|
|
|
|
toggleDisabled(stepIndex) {
|
|
|
|
if (this.disabledSteps.includes(stepIndex)) {
|
|
|
|
let index = this.disabledSteps.indexOf(stepIndex);
|
|
|
|
if (index !== -1) {
|
|
|
|
this.disabledSteps.splice(index, 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.disabledSteps.push(stepIndex);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
isDisabled(stepIndex) {
|
|
|
|
if (this.disabledSteps.includes(stepIndex)) {
|
|
|
|
return "disabled-card";
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
generateKey(item, index) {
|
|
|
|
return utils.generateUniqueKey(item, index);
|
|
|
|
},
|
|
|
|
deleteRecipe() {
|
|
|
|
this.$emit("delete");
|
|
|
|
},
|
|
|
|
|
|
|
|
appendIngredients(ingredients) {
|
|
|
|
this.value.recipeIngredient.push(...ingredients);
|
|
|
|
},
|
|
|
|
addIngredient() {
|
|
|
|
let list = this.value.recipeIngredient;
|
|
|
|
list.push("");
|
|
|
|
},
|
|
|
|
|
|
|
|
removeIngredient(index) {
|
|
|
|
this.value.recipeIngredient.splice(index, 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
appendSteps(steps) {
|
|
|
|
let processSteps = [];
|
|
|
|
steps.forEach((element) => {
|
|
|
|
processSteps.push({ text: element });
|
|
|
|
});
|
|
|
|
|
|
|
|
this.value.recipeInstructions.push(...processSteps);
|
|
|
|
},
|
|
|
|
addStep() {
|
|
|
|
let list = this.value.recipeInstructions;
|
|
|
|
list.push({ text: "" });
|
|
|
|
},
|
|
|
|
removeStep(index) {
|
|
|
|
this.value.recipeInstructions.splice(index, 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
addNote() {
|
|
|
|
let list = this.value.notes;
|
|
|
|
list.push({ text: "" });
|
|
|
|
},
|
|
|
|
removeNote(index) {
|
|
|
|
this.value.notes.splice(index, 1);
|
|
|
|
},
|
2021-01-03 10:01:49 -09:00
|
|
|
removeCategory(index) {
|
|
|
|
this.value.categories.splice(index, 1);
|
|
|
|
},
|
|
|
|
removeTags(index) {
|
|
|
|
this.value.tags.splice(index, 1);
|
|
|
|
},
|
2021-01-08 19:30:54 -09:00
|
|
|
saveExtras(extras) {
|
|
|
|
this.value.extras = extras;
|
|
|
|
},
|
2020-12-24 16:37:38 -09:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.disabled-card {
|
2021-01-03 17:41:18 -05:00
|
|
|
opacity: 0.5;
|
2020-12-24 16:37:38 -09:00
|
|
|
}
|
|
|
|
.my-divider {
|
|
|
|
margin: 0 -1px;
|
|
|
|
}
|
|
|
|
</style>
|