mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
recipe rating component
This commit is contained in:
parent
11b264e8eb
commit
701f05e758
1 changed files with 63 additions and 0 deletions
63
frontend/src/components/Recipe/Parts/Rating.vue
Normal file
63
frontend/src/components/Recipe/Parts/Rating.vue
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<template>
|
||||||
|
<div @click.prevent>
|
||||||
|
<v-rating
|
||||||
|
:readonly="!loggedIn"
|
||||||
|
color="secondary"
|
||||||
|
background-color="secondary lighten-3"
|
||||||
|
length="5"
|
||||||
|
:dense="small ? true : undefined"
|
||||||
|
:size="small ? 15 : undefined"
|
||||||
|
hover
|
||||||
|
v-model="rating"
|
||||||
|
:value="value"
|
||||||
|
@input="updateRating"
|
||||||
|
@click="updateRating"
|
||||||
|
></v-rating>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { api } from "@/api";
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
emitOnly: {
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
name: String,
|
||||||
|
slug: String,
|
||||||
|
value: Number,
|
||||||
|
small: {
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.rating = this.value;
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
rating: 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
loggedIn() {
|
||||||
|
return this.$store.getters.getIsLoggedIn;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateRating(val) {
|
||||||
|
if (this.emitOnly) {
|
||||||
|
this.$emit("input", val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
api.recipes.patch({
|
||||||
|
name: this.name,
|
||||||
|
slug: this.slug,
|
||||||
|
rating: val,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
Loading…
Add table
Add a link
Reference in a new issue