From 0631c5f7a16d487e2882fbb71bc8e435e1c549cc Mon Sep 17 00:00:00 2001 From: Donkie Date: Sat, 12 Aug 2023 20:20:25 +0200 Subject: [PATCH] Client: Made decimals more consistent Closes #58 --- client/src/pages/filaments/create.tsx | 6 +++--- client/src/pages/filaments/edit.tsx | 6 +++--- client/src/pages/filaments/show.tsx | 4 ++++ client/src/pages/spools/create.tsx | 3 ++- client/src/pages/spools/edit.tsx | 13 +++++++++---- client/src/pages/spools/list.tsx | 4 ++-- client/src/pages/spools/show.tsx | 2 ++ 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/client/src/pages/filaments/create.tsx b/client/src/pages/filaments/create.tsx index 274d95d..fb7dc7e 100644 --- a/client/src/pages/filaments/create.tsx +++ b/client/src/pages/filaments/create.tsx @@ -105,7 +105,7 @@ export const FilamentCreate: React.FC - + - + - + = () => { }, ]} > - + = () => { }, ]} > - + = () => { }, ]} > - + = () => { unit="g/cm³" options={{ maximumFractionDigits: 2, + minimumFractionDigits: 2, }} /> {t("filament.fields.diameter")} @@ -53,6 +54,7 @@ export const FilamentShow: React.FC = () => { unit="mm" options={{ maximumFractionDigits: 2, + minimumFractionDigits: 2, }} /> {t("filament.fields.weight")} @@ -61,6 +63,7 @@ export const FilamentShow: React.FC = () => { unit="g" options={{ maximumFractionDigits: 1, + minimumFractionDigits: 1, }} /> {t("filament.fields.spool_weight")} @@ -69,6 +72,7 @@ export const FilamentShow: React.FC = () => { unit="g" options={{ maximumFractionDigits: 1, + minimumFractionDigits: 1, }} /> {t("filament.fields.settings_extruder_temp")} diff --git a/client/src/pages/spools/create.tsx b/client/src/pages/spools/create.tsx index ba13d2c..9043646 100644 --- a/client/src/pages/spools/create.tsx +++ b/client/src/pages/spools/create.tsx @@ -6,6 +6,7 @@ import dayjs from "dayjs"; import TextArea from "antd/es/input/TextArea"; import { IFilament } from "../filaments/model"; import { ISpool } from "./model"; +import { numberFormatter, numberParser } from "../../utils/parsing"; interface CreateOrCloneProps { mode: "create" | "clone"; @@ -107,7 +108,7 @@ export const SpoolCreate: React.FC - + = () => { const t = useTranslate(); @@ -118,10 +119,14 @@ export const SpoolEdit: React.FC = () => { }, ]} > - - {/* TODO: Allow higher precision here. - However, that requires that we can handle the , -> . replacement in the number parser - more elegantly for locales which use , as a thousands separator. */} + = () => { id: "used_length", i18ncat: "spool", unit: "mm", - decimals: 0, + decimals: 1, dataSource, tableState, })} @@ -270,7 +270,7 @@ export const SpoolList: React.FC = () => { id: "remaining_length", i18ncat: "spool", unit: "mm", - decimals: 0, + decimals: 1, defaultText: t("unknown"), dataSource, tableState, diff --git a/client/src/pages/spools/show.tsx b/client/src/pages/spools/show.tsx index 1542915..547ebc2 100644 --- a/client/src/pages/spools/show.tsx +++ b/client/src/pages/spools/show.tsx @@ -55,6 +55,7 @@ export const SpoolShow: React.FC = () => { unit="g" options={{ maximumFractionDigits: 1, + minimumFractionDigits: 1, }} /> {t("spool.fields.used_weight")} @@ -63,6 +64,7 @@ export const SpoolShow: React.FC = () => { unit="g" options={{ maximumFractionDigits: 1, + minimumFractionDigits: 1, }} /> {t("spool.fields.location")}