mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-10 16:47:59 -05:00
decimal places setting
This commit is contained in:
@@ -22,8 +22,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="p in propertyList" :key="p.id">
|
<tr v-for="p in propertyList" :key="p.id">
|
||||||
<td>{{ p.name }}</td>
|
<td>{{ p.name }}</td>
|
||||||
<td>{{ $n(p.propertyAmountPerServing) }} {{ p.unit }}</td>
|
<td>{{ $n(roundDecimals(p.propertyAmountPerServing)) }} {{ p.unit }}</td>
|
||||||
<td>{{ $n(p.propertyAmountTotal) }} {{ p.unit }}</td>
|
<td>{{ $n(roundDecimals(p.propertyAmountTotal)) }} {{ p.unit }}</td>
|
||||||
<td v-if="sourceSelectedToShow == 'food'">
|
<td v-if="sourceSelectedToShow == 'food'">
|
||||||
<v-btn @click="dialogProperty = p; dialog = true" variant="plain" color="warning" icon="fa-solid fa-triangle-exclamation" size="small" class="d-print-none"
|
<v-btn @click="dialogProperty = p; dialog = true" variant="plain" color="warning" icon="fa-solid fa-triangle-exclamation" size="small" class="d-print-none"
|
||||||
v-if="p.missingValue"></v-btn>
|
v-if="p.missingValue"></v-btn>
|
||||||
@@ -86,6 +86,7 @@ import {ApiApi, PropertyType, Recipe} from "@/openapi";
|
|||||||
import VClosableCardTitle from "@/components/dialogs/VClosableCardTitle.vue";
|
import VClosableCardTitle from "@/components/dialogs/VClosableCardTitle.vue";
|
||||||
import ModelEditDialog from "@/components/dialogs/ModelEditDialog.vue";
|
import ModelEditDialog from "@/components/dialogs/ModelEditDialog.vue";
|
||||||
import {ErrorMessageType, useMessageStore} from "@/stores/MessageStore";
|
import {ErrorMessageType, useMessageStore} from "@/stores/MessageStore";
|
||||||
|
import {roundDecimals} from "@/utils/number_utils.ts";
|
||||||
|
|
||||||
type PropertyWrapper = {
|
type PropertyWrapper = {
|
||||||
id: number,
|
id: number,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<v-divider class="mb-3"></v-divider>
|
<v-divider class="mb-3"></v-divider>
|
||||||
|
|
||||||
<v-text-field v-model="useUserPreferenceStore().userSettings.defaultUnit" :label="$t('Default_Unit')"></v-text-field>
|
<v-text-field v-model="useUserPreferenceStore().userSettings.defaultUnit" :label="$t('Default_Unit')"></v-text-field>
|
||||||
<!-- <v-text-field v-model="useUserPreferenceStore().userSettings.ingredientDecimals" :label="$t('Decimals')"></v-text-field>-->
|
<v-number-input v-model="useUserPreferenceStore().userSettings.ingredientDecimals" :label="$t('Decimals')"></v-number-input>
|
||||||
|
|
||||||
<!-- <v-select-->
|
<!-- <v-select-->
|
||||||
<!-- :label="$t('DefaultPage')"-->
|
<!-- :label="$t('DefaultPage')"-->
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* round to the number of decimals specified in user preferences
|
* round to the number of decimals specified in user preferences
|
||||||
* @param num number to round
|
* @param num number to round
|
||||||
*/
|
*/
|
||||||
export function roundDecimals(num: number) {
|
export function roundDecimals(num: number) {
|
||||||
let decimals = 2 //TODO get user preference
|
let decimals = useUserPreferenceStore().userSettings.ingredientDecimals
|
||||||
return Number(num.toFixed(decimals))
|
return Number(num.toFixed(decimals))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user