mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
Basic nutrition editor
This commit is contained in:
parent
2a158ab290
commit
803839e3a1
2 changed files with 59 additions and 0 deletions
|
@ -0,0 +1,56 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h2 class="my-4">Nutrition</h2>
|
||||||
|
<div v-for="(item, key, index) in nutrition" :key="index">
|
||||||
|
<v-text-field
|
||||||
|
dense
|
||||||
|
:value="value[key]"
|
||||||
|
:label="labels[key].label"
|
||||||
|
:suffix="labels[key].suffix"
|
||||||
|
type="number"
|
||||||
|
autocomplete="off"
|
||||||
|
@input="updateValue(key, $event)"
|
||||||
|
></v-text-field>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
value: {},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
nutrition: {
|
||||||
|
calories: null,
|
||||||
|
fatContent: null,
|
||||||
|
fiberContent: null,
|
||||||
|
proteinContent: null,
|
||||||
|
sodiumContent: null,
|
||||||
|
sugarContent: null,
|
||||||
|
},
|
||||||
|
labels: {
|
||||||
|
calories: {
|
||||||
|
label: "Calories",
|
||||||
|
suffix: "calories",
|
||||||
|
},
|
||||||
|
fatContent: { label: "Fat Content", suffix: "grams" },
|
||||||
|
fiberContent: { label: "Fiber Content", suffix: "grams" },
|
||||||
|
proteinContent: { label: "Protein Content", suffix: "grams" },
|
||||||
|
sodiumContent: { label: "Sodium Content", suffix: "milligrams" },
|
||||||
|
sugarContent: { label: "Sugar Content", suffix: "grams" },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
updateValue(key, value) {
|
||||||
|
this.$emit("input", { ...this.value, [key]: value });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
|
@ -165,6 +165,7 @@
|
||||||
<v-btn class="mt-1" color="secondary" fab dark small @click="addNote">
|
<v-btn class="mt-1" color="secondary" fab dark small @click="addNote">
|
||||||
<v-icon>mdi-plus</v-icon>
|
<v-icon>mdi-plus</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
<NutritionEditor v-model="value.nutrition" />
|
||||||
<ExtrasEditor :extras="value.extras" @save="saveExtras" />
|
<ExtrasEditor :extras="value.extras" @save="saveExtras" />
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
|
@ -227,12 +228,14 @@ import utils from "@/utils";
|
||||||
import BulkAdd from "./BulkAdd";
|
import BulkAdd from "./BulkAdd";
|
||||||
import ExtrasEditor from "./ExtrasEditor";
|
import ExtrasEditor from "./ExtrasEditor";
|
||||||
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
||||||
|
import NutritionEditor from "./NutritionEditor";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
BulkAdd,
|
BulkAdd,
|
||||||
ExtrasEditor,
|
ExtrasEditor,
|
||||||
draggable,
|
draggable,
|
||||||
CategoryTagSelector,
|
CategoryTagSelector,
|
||||||
|
NutritionEditor,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
value: Object,
|
value: Object,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue