mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
nutrition display
This commit is contained in:
parent
6b730d012c
commit
15369b7945
4 changed files with 52 additions and 21 deletions
|
@ -1,7 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div v-if="valueNotNull || edit">
|
||||||
<h2 class="my-4">Nutrition</h2>
|
<h2 class="my-4">Nutrition</h2>
|
||||||
<div v-for="(item, key, index) in nutrition" :key="index">
|
<div v-if="edit">
|
||||||
|
<div v-for="(item, key, index) in value" :key="index">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
dense
|
dense
|
||||||
:value="value[key]"
|
:value="value[key]"
|
||||||
|
@ -13,23 +14,35 @@
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="showViewer">
|
||||||
|
<v-list dense>
|
||||||
|
<v-list-item-group color="primary">
|
||||||
|
<v-list-item v-for="(item, key, index) in labels" :key="index">
|
||||||
|
<v-list-item-content>
|
||||||
|
<v-list-item-title class="pl-4 text-subtitle-1 flex row ">
|
||||||
|
<div>{{ item.label }}</div>
|
||||||
|
<div class="ml-auto mr-1">{{ value[key] }}</div>
|
||||||
|
<div>{{ item.suffix }}</div>
|
||||||
|
</v-list-item-title>
|
||||||
|
</v-list-item-content>
|
||||||
|
</v-list-item>
|
||||||
|
</v-list-item-group>
|
||||||
|
</v-list>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
value: {},
|
value: {},
|
||||||
|
edit: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
nutrition: {
|
|
||||||
calories: null,
|
|
||||||
fatContent: null,
|
|
||||||
fiberContent: null,
|
|
||||||
proteinContent: null,
|
|
||||||
sodiumContent: null,
|
|
||||||
sugarContent: null,
|
|
||||||
},
|
|
||||||
labels: {
|
labels: {
|
||||||
calories: {
|
calories: {
|
||||||
label: "Calories",
|
label: "Calories",
|
||||||
|
@ -43,6 +56,18 @@ export default {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
showViewer() {
|
||||||
|
return !this.edit && this.valueNotNull;
|
||||||
|
},
|
||||||
|
valueNotNull() {
|
||||||
|
for (const property in this.value) {
|
||||||
|
const valueProperty = this.value[property];
|
||||||
|
if (valueProperty && valueProperty !== "") return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
updateValue(key, value) {
|
updateValue(key, value) {
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
auto-grow
|
auto-grow
|
||||||
solo
|
solo
|
||||||
dense
|
dense
|
||||||
rows="2"
|
rows="1"
|
||||||
>
|
>
|
||||||
<v-icon
|
<v-icon
|
||||||
class="mr-n1"
|
class="mr-n1"
|
||||||
|
@ -165,7 +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" />
|
<NutritionEditor v-model="value.nutrition" :edit="true" />
|
||||||
<ExtrasEditor :extras="value.extras" @save="saveExtras" />
|
<ExtrasEditor :extras="value.extras" @save="saveExtras" />
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
:isCategory="false"
|
:isCategory="false"
|
||||||
/>
|
/>
|
||||||
<Notes :notes="notes" />
|
<Notes :notes="notes" />
|
||||||
|
<NutritionEditor :value="nutrition" :edit="false" />
|
||||||
</div>
|
</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-divider
|
<v-divider
|
||||||
|
@ -56,6 +57,7 @@
|
||||||
<RecipeChips :title="$t('recipe.categories')" :items="categories" />
|
<RecipeChips :title="$t('recipe.categories')" :items="categories" />
|
||||||
<RecipeChips :title="$t('recipe.tags')" :items="tags" />
|
<RecipeChips :title="$t('recipe.tags')" :items="tags" />
|
||||||
<Notes :notes="notes" />
|
<Notes :notes="notes" />
|
||||||
|
<NutritionEditor :value="nutrition" :edit="false" />
|
||||||
</div>
|
</div>
|
||||||
<v-row class="mt-2 mb-1">
|
<v-row class="mt-2 mb-1">
|
||||||
<v-col></v-col>
|
<v-col></v-col>
|
||||||
|
@ -80,6 +82,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import NutritionEditor from "@/components/Recipe/RecipeEditor/NutritionEditor";
|
||||||
import VueMarkdown from "@adapttive/vue-markdown";
|
import VueMarkdown from "@adapttive/vue-markdown";
|
||||||
import utils from "@/utils";
|
import utils from "@/utils";
|
||||||
import RecipeChips from "./RecipeChips";
|
import RecipeChips from "./RecipeChips";
|
||||||
|
@ -93,6 +96,7 @@ export default {
|
||||||
Steps,
|
Steps,
|
||||||
Notes,
|
Notes,
|
||||||
Ingredients,
|
Ingredients,
|
||||||
|
NutritionEditor,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
name: String,
|
name: String,
|
||||||
|
@ -105,6 +109,7 @@ export default {
|
||||||
rating: Number,
|
rating: Number,
|
||||||
yields: String,
|
yields: String,
|
||||||
orgURL: String,
|
orgURL: String,
|
||||||
|
nutrition: Object,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
:rating="recipeDetails.rating"
|
:rating="recipeDetails.rating"
|
||||||
:yields="recipeDetails.recipeYield"
|
:yields="recipeDetails.recipeYield"
|
||||||
:orgURL="recipeDetails.orgURL"
|
:orgURL="recipeDetails.orgURL"
|
||||||
|
:nutrition="recipeDetails.nutrition"
|
||||||
/>
|
/>
|
||||||
<VJsoneditor
|
<VJsoneditor
|
||||||
@error="logError()"
|
@error="logError()"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue