mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
fix ingredient checkbox
This commit is contained in:
parent
4400bff4b4
commit
5270ee671b
1 changed files with 19 additions and 11 deletions
|
@ -3,23 +3,22 @@
|
||||||
<h2 class="mb-4">{{ $t("recipe.ingredients") }}</h2>
|
<h2 class="mb-4">{{ $t("recipe.ingredients") }}</h2>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
dense
|
dense
|
||||||
v-for="(ingredient, index) in displayIngredients"
|
v-for="(ingredient, index) in ingredients"
|
||||||
:key="generateKey('ingredient', index)"
|
:key="generateKey('ingredient', index)"
|
||||||
@click="ingredient.checked = !ingredient.checked"
|
@click="toggleChecked(index)"
|
||||||
>
|
>
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
hide-details
|
hide-details
|
||||||
v-model="ingredient.checked"
|
:value="checked[index]"
|
||||||
class="pt-0 my-auto py-auto"
|
class="pt-0 my-auto py-auto"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
:readonly="true"
|
|
||||||
>
|
>
|
||||||
</v-checkbox>
|
</v-checkbox>
|
||||||
|
|
||||||
<v-list-item-content>
|
<v-list-item-content>
|
||||||
<vue-markdown
|
<vue-markdown
|
||||||
class="ma-0 pa-0 text-subtitle-1 dense-markdown"
|
class="ma-0 pa-0 text-subtitle-1 dense-markdown"
|
||||||
:source="ingredient.text"
|
:source="ingredient"
|
||||||
>
|
>
|
||||||
</vue-markdown>
|
</vue-markdown>
|
||||||
</v-list-item-content>
|
</v-list-item-content>
|
||||||
|
@ -37,18 +36,27 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
ingredients: Array,
|
ingredients: Array,
|
||||||
},
|
},
|
||||||
computed: {
|
data() {
|
||||||
displayIngredients() {
|
return {
|
||||||
return this.ingredients.map(x => ({
|
checked: [],
|
||||||
text: x,
|
};
|
||||||
checked: false,
|
},
|
||||||
}));
|
mounted() {
|
||||||
|
this.checked = this.ingredients.map(() => false);
|
||||||
|
console.log(this.checked);
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
ingredients(val) {
|
||||||
|
console.log(val);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
generateKey(item, index) {
|
generateKey(item, index) {
|
||||||
return utils.generateUniqueKey(item, index);
|
return utils.generateUniqueKey(item, index);
|
||||||
},
|
},
|
||||||
|
toggleChecked(index) {
|
||||||
|
this.$set(this.checked, index, !this.checked[index]);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue