1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-02 20:15:24 +02:00

feat(frontend): 👷 Add image operations to recipe page

Added/Fixed image upload/get process on the recipe pages as well as some additional styling
This commit is contained in:
hay-kot 2021-08-03 21:38:45 -08:00
parent afcad2f701
commit 5ee0a57163
15 changed files with 238 additions and 114 deletions

View file

@ -22,7 +22,9 @@
<script>
import { api } from "@/api";
export default {
import { defineComponent } from "@nuxtjs/composition-api";
import { useApiSingleton } from "~/composables/use-api";
export default defineComponent({
props: {
slug: {
type: String,
@ -37,6 +39,11 @@ export default {
default: false,
},
},
setup() {
const api = useApiSingleton();
return { api };
},
computed: {
user() {
return this.$auth.user;
@ -48,14 +55,14 @@ export default {
methods: {
async toggleFavorite() {
if (!this.isFavorite) {
await api.users.addFavorite(this.$auth.user.id, this.slug);
await this.api.users.addFavorite(this.$auth.user.id, this.slug);
} else {
await api.users.removeFavorite(this.$auth.user.id, this.slug);
await this.api.users.removeFavorite(this.$auth.user.id, this.slug);
}
this.$store.dispatch("requestUserData");
this.$auth.fetchUser();
},
},
};
});
</script>
<style lang="scss" scoped>

View file

@ -40,12 +40,21 @@
</template>
<script>
import { api } from "@/api";
import { defineComponent } from "@nuxtjs/composition-api";
import { useApiSingleton } from "~/composables/use-api";
const REFRESH_EVENT = "refresh";
const UPLOAD_EVENT = "upload";
export default {
export default defineComponent({
props: {
slug: String,
slug: {
type: String,
required: true,
},
},
setup() {
const api = useApiSingleton();
return { api };
},
data: () => ({
url: "",
@ -57,7 +66,7 @@ export default {
},
async getImageFromURL() {
this.loading = true;
if (await api.recipes.updateImagebyURL(this.slug, this.url)) {
if (await this.api.recipes.updateImagebyURL(this.slug, this.url)) {
this.$emit(REFRESH_EVENT);
}
this.loading = false;
@ -66,7 +75,7 @@ export default {
return this.slug ? [""] : [this.$i18n.t("recipe.save-recipe-before-use")];
},
},
};
});
</script>
<style lang="scss" scoped></style>

View file

@ -17,8 +17,9 @@
</template>
<script>
import { api } from "@/api";
export default {
import { defineComponent } from "@nuxtjs/composition-api";
import { useApiSingleton } from "~/composables/use-api";
export default defineComponent({
props: {
emitOnly: {
type: Boolean,
@ -41,6 +42,11 @@ export default {
default: false,
},
},
setup() {
const api = useApiSingleton();
return { api };
},
data() {
return {
rating: 0,
@ -60,14 +66,14 @@ export default {
this.$emit("input", val);
return;
}
api.recipes.patch({
this.api.recipes.patchOne(this.slug, {
name: this.name,
slug: this.slug,
rating: val,
});
},
},
};
});
</script>
<style lang="scss" scoped></style>