mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix parameter formatting (#7934)
This commit is contained in:
parent
5515e0762e
commit
8c6275b845
@ -30,7 +30,11 @@ export function formatDecimal(
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
let formatter = new Intl.NumberFormat(locale);
|
let formatter = new Intl.NumberFormat(locale, {
|
||||||
|
style: 'decimal',
|
||||||
|
maximumFractionDigits: options.digits ?? 6,
|
||||||
|
minimumFractionDigits: options.minDigits ?? 0
|
||||||
|
});
|
||||||
|
|
||||||
return formatter.format(value);
|
return formatter.format(value);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { YesNoButton } from '../../components/buttons/YesNoButton';
|
import { YesNoButton } from '../../components/buttons/YesNoButton';
|
||||||
import { ApiFormFieldSet } from '../../components/forms/fields/ApiFormField';
|
import { ApiFormFieldSet } from '../../components/forms/fields/ApiFormField';
|
||||||
|
import { formatDecimal } from '../../defaults/formatters';
|
||||||
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { ModelType } from '../../enums/ModelType';
|
import { ModelType } from '../../enums/ModelType';
|
||||||
import { UserRoles } from '../../enums/Roles';
|
import { UserRoles } from '../../enums/Roles';
|
||||||
@ -65,7 +66,8 @@ function ParameterCell({
|
|||||||
parameter.data_numeric &&
|
parameter.data_numeric &&
|
||||||
parameter.data_numeric != parameter.data
|
parameter.data_numeric != parameter.data
|
||||||
) {
|
) {
|
||||||
extra.push(`${parameter.data_numeric} [${template.units}]`);
|
const numeric = formatDecimal(parameter.data_numeric, { digits: 15 });
|
||||||
|
extra.push(`${numeric} [${template.units}]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hovered && canEdit) {
|
if (hovered && canEdit) {
|
||||||
@ -80,7 +82,7 @@ function ParameterCell({
|
|||||||
value={value ?? '-'}
|
value={value ?? '-'}
|
||||||
extra={extra}
|
extra={extra}
|
||||||
icon={hovered && canEdit ? 'edit' : 'info'}
|
icon={hovered && canEdit ? 'edit' : 'info'}
|
||||||
title={t`Internal Units`}
|
title={template.name}
|
||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
@ -6,6 +6,7 @@ import { useCallback, useMemo, useState } from 'react';
|
|||||||
import { AddItemButton } from '../../components/buttons/AddItemButton';
|
import { AddItemButton } from '../../components/buttons/AddItemButton';
|
||||||
import { YesNoButton } from '../../components/buttons/YesNoButton';
|
import { YesNoButton } from '../../components/buttons/YesNoButton';
|
||||||
import { ApiFormFieldSet } from '../../components/forms/fields/ApiFormField';
|
import { ApiFormFieldSet } from '../../components/forms/fields/ApiFormField';
|
||||||
|
import { formatDecimal } from '../../defaults/formatters';
|
||||||
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../../enums/ApiEndpoints';
|
||||||
import { UserRoles } from '../../enums/Roles';
|
import { UserRoles } from '../../enums/Roles';
|
||||||
import { usePartParameterFields } from '../../forms/PartForms';
|
import { usePartParameterFields } from '../../forms/PartForms';
|
||||||
@ -85,7 +86,8 @@ export function PartParameterTable({
|
|||||||
record.data_numeric &&
|
record.data_numeric &&
|
||||||
record.data_numeric != record.data
|
record.data_numeric != record.data
|
||||||
) {
|
) {
|
||||||
extra.push(`${record.data_numeric} [${template.units}]`);
|
const numeric = formatDecimal(record.data_numeric, { digits: 15 });
|
||||||
|
extra.push(`${numeric} [${template.units}]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user