mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -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-icon>mdi-plus</v-icon>
|
||||
</v-btn>
|
||||
<NutritionEditor v-model="value.nutrition" />
|
||||
<ExtrasEditor :extras="value.extras" @save="saveExtras" />
|
||||
</v-col>
|
||||
|
||||
|
@ -227,12 +228,14 @@ import utils from "@/utils";
|
|||
import BulkAdd from "./BulkAdd";
|
||||
import ExtrasEditor from "./ExtrasEditor";
|
||||
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
||||
import NutritionEditor from "./NutritionEditor";
|
||||
export default {
|
||||
components: {
|
||||
BulkAdd,
|
||||
ExtrasEditor,
|
||||
draggable,
|
||||
CategoryTagSelector,
|
||||
NutritionEditor,
|
||||
},
|
||||
props: {
|
||||
value: Object,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue