From d0703f963928e38e84e49d0b08f719d484723d6d Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sat, 1 Feb 2025 08:51:13 +0100 Subject: [PATCH] support fraction display --- vue3/src/components/display/IngredientsTable.vue | 4 +++- vue3/src/components/display/ScalableNumber.vue | 4 +++- vue3/src/utils/number_utils.ts | 10 +++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vue3/src/components/display/IngredientsTable.vue b/vue3/src/components/display/IngredientsTable.vue index 1d72ca837..3ec583c77 100644 --- a/vue3/src/components/display/IngredientsTable.vue +++ b/vue3/src/components/display/IngredientsTable.vue @@ -36,7 +36,7 @@ - {{ i.amount * props.ingredientFactor }} + @@ -59,6 +59,8 @@ diff --git a/vue3/src/utils/number_utils.ts b/vue3/src/utils/number_utils.ts index a7521a1d0..598e2a8c3 100644 --- a/vue3/src/utils/number_utils.ts +++ b/vue3/src/utils/number_utils.ts @@ -1,8 +1,3 @@ -function getUserPreference(pref: string) { - return false // TODO only placeholder, add real function -} - - /** * round to the number of decimals specified in user preferences * @param num number to round @@ -16,9 +11,10 @@ export function roundDecimals(num: number) { * calculates the amount of food, based on the factor and converts it to a fraction if that is the users preference * @param amount food amount to calculate based upon * @param factor factor to scale food amount by + * @param useFractions if the returned value should be a fraction or not */ -export function calculateFoodAmount(amount: number, factor: number) { - if (getUserPreference("use_fractions")) { +export function calculateFoodAmount(amount: number, factor: number, useFractions: boolean = false) { + if (useFractions) { let return_string = "" let fraction = frac(amount * factor, 16, true)