Skip to content

Commit

Permalink
Client: Made decimals more consistent
Browse files Browse the repository at this point in the history
Closes #58
  • Loading branch information
Donkie committed Aug 12, 2023
1 parent 7bdde57 commit 0631c5f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
6 changes: 3 additions & 3 deletions client/src/pages/filaments/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const FilamentCreate: React.FC<IResourceComponentsProps & CreateOrClonePr
},
]}
>
<InputNumber min={0} addonAfter="g/cm³" precision={3} formatter={numberFormatter} parser={numberParser} />
<InputNumber min={0} addonAfter="g/cm³" precision={2} formatter={numberFormatter} parser={numberParser} />
</Form.Item>
<Form.Item
label={t("filament.fields.diameter")}
Expand All @@ -128,7 +128,7 @@ export const FilamentCreate: React.FC<IResourceComponentsProps & CreateOrClonePr
},
]}
>
<InputNumber min={0} addonAfter="g" precision={0} />
<InputNumber min={0} addonAfter="g" precision={1} />
</Form.Item>
<Form.Item
label={t("filament.fields.spool_weight")}
Expand All @@ -140,7 +140,7 @@ export const FilamentCreate: React.FC<IResourceComponentsProps & CreateOrClonePr
},
]}
>
<InputNumber min={0} addonAfter="g" precision={0} />
<InputNumber min={0} addonAfter="g" precision={1} />
</Form.Item>
<Form.Item
label={t("filament.fields.settings_extruder_temp")}
Expand Down
6 changes: 3 additions & 3 deletions client/src/pages/filaments/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const FilamentEdit: React.FC<IResourceComponentsProps> = () => {
},
]}
>
<InputNumber min={0} addonAfter="g/cm³" precision={3} formatter={numberFormatter} parser={numberParser} />
<InputNumber min={0} addonAfter="g/cm³" precision={2} formatter={numberFormatter} parser={numberParser} />
</Form.Item>
<Form.Item
label={t("filament.fields.diameter")}
Expand All @@ -150,7 +150,7 @@ export const FilamentEdit: React.FC<IResourceComponentsProps> = () => {
},
]}
>
<InputNumber min={0} addonAfter="g" precision={0} />
<InputNumber min={0} addonAfter="g" precision={1} />
</Form.Item>
<Form.Item
label={t("filament.fields.spool_weight")}
Expand All @@ -162,7 +162,7 @@ export const FilamentEdit: React.FC<IResourceComponentsProps> = () => {
},
]}
>
<InputNumber min={0} addonAfter="g" precision={0} />
<InputNumber min={0} addonAfter="g" precision={1} />
</Form.Item>
<Form.Item
label={t("filament.fields.settings_extruder_temp")}
Expand Down
4 changes: 4 additions & 0 deletions client/src/pages/filaments/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const FilamentShow: React.FC<IResourceComponentsProps> = () => {
unit="g/cm³"
options={{
maximumFractionDigits: 2,
minimumFractionDigits: 2,
}}
/>
<Title level={5}>{t("filament.fields.diameter")}</Title>
Expand All @@ -53,6 +54,7 @@ export const FilamentShow: React.FC<IResourceComponentsProps> = () => {
unit="mm"
options={{
maximumFractionDigits: 2,
minimumFractionDigits: 2,
}}
/>
<Title level={5}>{t("filament.fields.weight")}</Title>
Expand All @@ -61,6 +63,7 @@ export const FilamentShow: React.FC<IResourceComponentsProps> = () => {
unit="g"
options={{
maximumFractionDigits: 1,
minimumFractionDigits: 1,
}}
/>
<Title level={5}>{t("filament.fields.spool_weight")}</Title>
Expand All @@ -69,6 +72,7 @@ export const FilamentShow: React.FC<IResourceComponentsProps> = () => {
unit="g"
options={{
maximumFractionDigits: 1,
minimumFractionDigits: 1,
}}
/>
<Title level={5}>{t("filament.fields.settings_extruder_temp")}</Title>
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/spools/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -107,7 +108,7 @@ export const SpoolCreate: React.FC<IResourceComponentsProps & CreateOrCloneProps
},
]}
>
<InputNumber min={0} addonAfter="g" precision={0} />
<InputNumber min={0} addonAfter="g" precision={1} formatter={numberFormatter} parser={numberParser} />
</Form.Item>
<Form.Item
label={t("spool.fields.location")}
Expand Down
13 changes: 9 additions & 4 deletions client/src/pages/spools/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

export const SpoolEdit: React.FC<IResourceComponentsProps> = () => {
const t = useTranslate();
Expand Down Expand Up @@ -118,10 +119,14 @@ export const SpoolEdit: React.FC<IResourceComponentsProps> = () => {
},
]}
>
<InputNumber min={0} addonAfter="g" precision={0} />
{/* 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. */}
<InputNumber
min={0}
addonAfter="g"
precision={1}
max={1e6}
formatter={numberFormatter}
parser={numberParser}
/>
</Form.Item>
<Form.Item
label={t("spool.fields.location")}
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/spools/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
id: "used_length",
i18ncat: "spool",
unit: "mm",
decimals: 0,
decimals: 1,
dataSource,
tableState,
})}
{NumberColumn({
id: "remaining_length",
i18ncat: "spool",
unit: "mm",
decimals: 0,
decimals: 1,
defaultText: t("unknown"),
dataSource,
tableState,
Expand Down
2 changes: 2 additions & 0 deletions client/src/pages/spools/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const SpoolShow: React.FC<IResourceComponentsProps> = () => {
unit="g"
options={{
maximumFractionDigits: 1,
minimumFractionDigits: 1,
}}
/>
<Title level={5}>{t("spool.fields.used_weight")}</Title>
Expand All @@ -63,6 +64,7 @@ export const SpoolShow: React.FC<IResourceComponentsProps> = () => {
unit="g"
options={{
maximumFractionDigits: 1,
minimumFractionDigits: 1,
}}
/>
<Title level={5}>{t("spool.fields.location")}</Title>
Expand Down

0 comments on commit 0631c5f

Please sign in to comment.