mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-03 13:19:16 -05:00
Set calories heading based on user preference
This commit is contained in:
@@ -108,7 +108,7 @@
|
|||||||
|
|
||||||
<b-collapse id="id_nutrition_collapse" class="mt-2">
|
<b-collapse id="id_nutrition_collapse" class="mt-2">
|
||||||
<div class="card-body " v-if="recipe.nutrition">
|
<div class="card-body " v-if="recipe.nutrition">
|
||||||
<label for="id_name"> {{ $t('Calories') }}</label>
|
<label for="id_name"> {{ energy() }}</label>
|
||||||
<input class="form-control" id="id_calories" v-model="recipe.nutrition.calories">
|
<input class="form-control" id="id_calories" v-model="recipe.nutrition.calories">
|
||||||
|
|
||||||
<label for="id_name"> {{ $t('Carbohydrates') }}</label>
|
<label for="id_name"> {{ $t('Carbohydrates') }}</label>
|
||||||
@@ -481,7 +481,7 @@ import {BootstrapVue} from 'bootstrap-vue'
|
|||||||
import 'bootstrap-vue/dist/bootstrap-vue.css'
|
import 'bootstrap-vue/dist/bootstrap-vue.css'
|
||||||
|
|
||||||
import draggable from 'vuedraggable'
|
import draggable from 'vuedraggable'
|
||||||
import {ApiMixin, resolveDjangoUrl, ResolveUrlMixin, StandardToasts, convertEnergyToCalories} from "@/utils/utils";
|
import {ApiMixin, resolveDjangoUrl, ResolveUrlMixin, StandardToasts, convertEnergyToCalories, energyHeading} from "@/utils/utils";
|
||||||
import Multiselect from "vue-multiselect";
|
import Multiselect from "vue-multiselect";
|
||||||
import {ApiApiFactory} from "@/utils/openapi/api";
|
import {ApiApiFactory} from "@/utils/openapi/api";
|
||||||
import LoadingSpinner from "@/components/LoadingSpinner";
|
import LoadingSpinner from "@/components/LoadingSpinner";
|
||||||
@@ -819,6 +819,9 @@ export default {
|
|||||||
if (this.recipe.nutrition && this.recipe.nutrition.calories) {
|
if (this.recipe.nutrition && this.recipe.nutrition.calories) {
|
||||||
this.recipe.nutrition.calories = convertEnergyToCalories(this.recipe.nutrition.calories)
|
this.recipe.nutrition.calories = convertEnergyToCalories(this.recipe.nutrition.calories)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
energy: function () {
|
||||||
|
return energyHeading()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<i class="fas fa-fire fa-fw text-primary"></i> {{ $t('Calories') }}
|
<i class="fas fa-fire fa-fw text-primary"></i> {{ energy() }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span v-html="calculateEnergy(recipe.nutrition.calories)"></span>
|
<span v-html="calculateEnergy(recipe.nutrition.calories)"></span>
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import {calculateAmount, calculateEnergy} from "@/utils/utils";
|
import {calculateAmount, calculateEnergy, energyHeading} from "@/utils/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Nutrition',
|
name: 'Nutrition',
|
||||||
@@ -68,6 +68,9 @@ export default {
|
|||||||
},
|
},
|
||||||
calculateEnergy: function (x) {
|
calculateEnergy: function (x) {
|
||||||
return calculateEnergy(x, this.ingredient_factor)
|
return calculateEnergy(x, this.ingredient_factor)
|
||||||
|
},
|
||||||
|
energy: function (x) {
|
||||||
|
return energyHeading()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,6 +175,14 @@ export function convertEnergyToCalories(amount) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function energyHeading() {
|
||||||
|
if (getUserPreference('use_kj')) {
|
||||||
|
return 'Energy'
|
||||||
|
} else {
|
||||||
|
return 'Calories'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utility functions to use OpenAPIs generically
|
* Utility functions to use OpenAPIs generically
|
||||||
* */
|
* */
|
||||||
|
|||||||
Reference in New Issue
Block a user