2020-12-24 16:37:38 -09:00
|
|
|
<template>
|
|
|
|
<div class="text-center">
|
|
|
|
<v-dialog v-model="addRecipe" width="650" @click:outside="reset">
|
|
|
|
<v-card :loading="processing">
|
2021-01-17 22:22:54 -09:00
|
|
|
<v-card-title class="headline"
|
|
|
|
>{{ $t("new-recipe.from-url") }}
|
|
|
|
</v-card-title>
|
2020-12-24 16:37:38 -09:00
|
|
|
|
|
|
|
<v-card-text>
|
|
|
|
<v-form>
|
2021-01-17 22:22:54 -09:00
|
|
|
<v-text-field
|
|
|
|
v-model="recipeURL"
|
|
|
|
:label="$t('new-recipe.recipe-url')"
|
|
|
|
></v-text-field>
|
2020-12-24 16:37:38 -09:00
|
|
|
</v-form>
|
2021-01-03 12:07:01 -09:00
|
|
|
|
|
|
|
<v-alert v-if="error" color="red" outlined type="success">
|
2021-01-17 22:22:54 -09:00
|
|
|
{{ $t("new-recipe.error-message") }}
|
2021-01-03 12:07:01 -09:00
|
|
|
</v-alert>
|
2020-12-24 16:37:38 -09:00
|
|
|
</v-card-text>
|
|
|
|
|
|
|
|
<v-divider></v-divider>
|
|
|
|
|
|
|
|
<v-card-actions>
|
|
|
|
<v-spacer></v-spacer>
|
2021-01-17 22:22:54 -09:00
|
|
|
<v-btn color="grey" text @click="reset">
|
|
|
|
{{ $t("general.close") }}
|
|
|
|
</v-btn>
|
|
|
|
<v-btn color="success" text @click="createRecipe">
|
|
|
|
{{ $t("general.submit") }}
|
|
|
|
</v-btn>
|
2020-12-24 16:37:38 -09:00
|
|
|
</v-card-actions>
|
|
|
|
</v-card>
|
|
|
|
</v-dialog>
|
|
|
|
<v-speed-dial v-model="fab" fixed right bottom open-on-hover>
|
|
|
|
<template v-slot:activator>
|
2021-01-05 17:54:37 -09:00
|
|
|
<v-btn v-model="fab" color="accent" dark fab>
|
2020-12-24 16:37:38 -09:00
|
|
|
<v-icon> mdi-plus </v-icon>
|
|
|
|
</v-btn>
|
|
|
|
</template>
|
2020-12-24 19:32:49 -09:00
|
|
|
<v-btn fab dark small color="primary" @click="addRecipe = true">
|
2020-12-24 16:37:38 -09:00
|
|
|
<v-icon>mdi-link</v-icon>
|
|
|
|
</v-btn>
|
2021-01-05 17:54:37 -09:00
|
|
|
<v-btn fab dark small color="accent" @click="navCreate">
|
|
|
|
<v-icon>mdi-square-edit-outline</v-icon>
|
|
|
|
</v-btn>
|
2020-12-24 16:37:38 -09:00
|
|
|
</v-speed-dial>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-02-10 19:39:46 -09:00
|
|
|
import api from "../../api";
|
2020-12-24 16:37:38 -09:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2021-01-03 12:07:01 -09:00
|
|
|
error: false,
|
2020-12-24 16:37:38 -09:00
|
|
|
fab: false,
|
|
|
|
addRecipe: false,
|
|
|
|
recipeURL: "",
|
|
|
|
processing: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async createRecipe() {
|
|
|
|
this.processing = true;
|
2021-01-03 12:07:01 -09:00
|
|
|
let response = await api.recipes.createByURL(this.recipeURL);
|
|
|
|
if (response.status !== 201) {
|
|
|
|
this.error = true;
|
|
|
|
this.processing = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-12-24 16:37:38 -09:00
|
|
|
this.addRecipe = false;
|
|
|
|
this.processing = false;
|
2021-01-17 22:22:54 -09:00
|
|
|
this.recipeURL = "";
|
2021-01-03 12:07:01 -09:00
|
|
|
this.$router.push(`/recipe/${response.data}`);
|
2020-12-24 16:37:38 -09:00
|
|
|
},
|
|
|
|
|
|
|
|
navCreate() {
|
|
|
|
this.$router.push("/new");
|
|
|
|
},
|
|
|
|
|
|
|
|
reset() {
|
2021-01-06 08:39:48 -09:00
|
|
|
this.fab = false;
|
|
|
|
this.error = false;
|
|
|
|
this.addRecipe = false;
|
|
|
|
this.recipeURL = "";
|
|
|
|
this.processing = false;
|
2020-12-24 16:37:38 -09:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|