Client: Improved the lists a bit

This commit is contained in:
Donkie
2023-05-16 21:50:09 +02:00
parent 9a063fcf5d
commit 166c6fa0d1
2 changed files with 75 additions and 38 deletions

View File

@@ -56,32 +56,42 @@ export const FilamentList: React.FC<IResourceComponentsProps> = () => {
<Table.Column <Table.Column
dataIndex="weight" dataIndex="weight"
title="Weight" title="Weight"
render={(value) => ( render={(value) => {
<NumberField if (value === null || value === undefined) {
value={value} return <></>;
options={{ }
unitDisplay: "short", return (
unit: "gram", <NumberField
style: "unit", value={value}
maximumFractionDigits: 1, options={{
}} unitDisplay: "short",
/> unit: "gram",
)} style: "unit",
maximumFractionDigits: 1,
}}
/>
);
}}
/> />
<Table.Column <Table.Column
dataIndex="spool_weight" dataIndex="spool_weight"
title="Spool Weight" title="Spool Weight"
render={(value) => ( render={(value) => {
<NumberField if (value === null || value === undefined) {
value={value} return <></>;
options={{ }
unitDisplay: "short", return (
unit: "gram", <NumberField
style: "unit", value={value}
maximumFractionDigits: 1, options={{
}} unitDisplay: "short",
/> unit: "gram",
)} style: "unit",
maximumFractionDigits: 1,
}}
/>
);
}}
/> />
<Table.Column dataIndex="article_number" title="Article Number" /> <Table.Column dataIndex="article_number" title="Article Number" />
<Table.Column <Table.Column

View File

@@ -7,6 +7,7 @@ import {
ShowButton, ShowButton,
DateField, DateField,
NumberField, NumberField,
TextField,
} from "@refinedev/antd"; } from "@refinedev/antd";
import { Table, Space } from "antd"; import { Table, Space } from "antd";
@@ -15,30 +16,58 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
syncWithLocation: true, syncWithLocation: true,
}); });
tableProps.dataSource?.forEach((element) => {
if ("vendor" in element.filament) {
element.filament_name = `${element.filament.vendor.name} - ${element.filament.name}`;
} else {
element.filament_name = element.filament.name;
}
});
return ( return (
<List> <List>
<Table {...tableProps} rowKey="id"> <Table {...tableProps} rowKey="id">
<Table.Column dataIndex="id" title="Id" /> <Table.Column dataIndex="id" title="Id" />
<Table.Column dataIndex="filament_name" title="Filament" />
<Table.Column <Table.Column
dataIndex={["filament", "vendor", "name"]} dataIndex="used_weight"
title="Vendor" title="Used Weight"
render={(value) => {
return (
<NumberField
value={value}
options={{
unitDisplay: "short",
unit: "gram",
style: "unit",
maximumFractionDigits: 1,
}}
/>
);
}}
/> />
<Table.Column dataIndex={["filament", "name"]} title="Filament Name" />
<Table.Column <Table.Column
dataIndex="remaining_weight" dataIndex="remaining_weight"
title="Estimated Remaining Weight" title="Estimated Remaining Weight"
render={(value) => ( render={(value) => {
<NumberField if (value === null || value === undefined) {
value={value} return <TextField value="Unknown" />;
options={{ }
unitDisplay: "short", return (
unit: "gram", <NumberField
style: "unit", value={Math.max(value, 0)}
maximumFractionDigits: 1, options={{
}} unitDisplay: "short",
/> unit: "gram",
)} style: "unit",
maximumFractionDigits: 1,
}}
/>
);
}}
/> />
<Table.Column dataIndex="location" title="Location" />
<Table.Column dataIndex="lot_nr" title="Lot Nr" />
<Table.Column <Table.Column
dataIndex={["first_used"]} dataIndex={["first_used"]}
title="First Used" title="First Used"
@@ -53,8 +82,6 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
<DateField value={value} format="YYYY-MM-DD HH:mm:ss" /> <DateField value={value} format="YYYY-MM-DD HH:mm:ss" />
)} )}
/> />
<Table.Column dataIndex="location" title="Location" />
<Table.Column dataIndex="lot_nr" title="Lot Nr" />
<Table.Column dataIndex={["comment"]} title="Comment" /> <Table.Column dataIndex={["comment"]} title="Comment" />
<Table.Column <Table.Column
title="Actions" title="Actions"