1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-31 02:59:42 +02:00
mealie/frontend/src/pages/Recipe/NewRecipe.vue
sephrat 1e5edc7434
More localization (#358)
* Translate missing items on About page

* Localize import summary dialog

* Make site menu translation reactive

* Localize import options

* Include semi colon in string

* Move API texts to frontend + better status codes

* Provide feedback to user when no meal is planned

* Fix API tests after latest rework

* Add warning for API changes in changelog

* Refactor API texts handling

* Refactor API texts handling #2

* Better API feedback

* Rearrange strings hierarchy

* Add messages upon recipe updated

* Fix 'recipe effected' typo

* Remove snackbar usage in backend

* Translate toolbox

* Provide feedback for tags CRUD

* Fix messed up merge

* Translate sign-up form

* Better feedback for sign-up CRUD

* Refactor log-in API texts handling

* No error message when user is not authenticated

* Remove unimportant console log
2021-04-29 08:22:45 -08:00

121 lines
No EOL
2.6 KiB
Vue

<template>
<v-container>
<v-card :loading="isLoading">
<v-img v-if="image" height="400" :src="image">
<template v-slot:placeholder>
<v-row class="fill-height ma-0" align="center" justify="center">
<v-progress-circular
indeterminate
color="grey lighten-5"
></v-progress-circular>
</v-row>
</template>
</v-img>
<br v-else />
<EditorButtonRow
@json="jsonEditor = true"
@editor="jsonEditor = false"
@save="createRecipe"
/>
<div v-if="jsonEditor">
<!-- Probably not the best way, but it works! -->
<br />
<br />
<VJsoneditor
v-model="recipeDetails"
height="1500px"
:options="jsonEditorOptions"
/>
</div>
<RecipeEditor
ref="recipeEditor"
v-else
v-model="recipeDetails"
@upload="getImage"
/>
</v-card>
</v-container>
</template>
<script>
import { api } from "@/api";
import RecipeEditor from "@/components/Recipe/RecipeEditor";
import VJsoneditor from "v-jsoneditor";
import EditorButtonRow from "@/components/Recipe/EditorButtonRow";
export default {
components: {
VJsoneditor,
RecipeEditor,
EditorButtonRow,
},
data() {
return {
isLoading: false,
fileObject: null,
selectedFile: null,
image: null,
jsonEditor: false,
jsonEditorOptions: {
mode: "code",
search: false,
mainMenuBar: false,
},
recipeDetails: {
name: "",
description: "",
image: "",
recipeYield: "",
recipeIngredient: [],
recipeInstructions: [],
slug: "",
filePath: "",
tags: [],
categories: [],
// dateAdded: "",
notes: [],
extras: [],
},
};
},
methods: {
getImage(fileObject) {
this.fileObject = fileObject;
this.onFileChange();
},
onFileChange() {
this.image = URL.createObjectURL(this.fileObject);
},
async createRecipe() {
if (this.$refs.recipeEditor.validateRecipe()) {
this.isLoading = true;
if (this.fileObject) {
this.recipeDetails.image = this.fileObject.name;
}
let slug = await api.recipes.create(this.recipeDetails);
if (this.fileObject) {
api.recipes.updateImage(slug, this.fileObject, true);
}
this.isLoading = false;
this.$router.push(`/recipe/${slug}`);
}
},
},
};
</script>
<style>
.img-input {
position: absolute;
bottom: 0;
}
</style>