mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-16 20:15:44 +00:00
Improve PartDetail
- Add more data - Add icons
This commit is contained in:
@ -108,6 +108,7 @@ const icons: { [key: string]: (props: TablerIconsProps) => React.JSX.Element } =
|
|||||||
delete: IconTrash,
|
delete: IconTrash,
|
||||||
|
|
||||||
// Part Icons
|
// Part Icons
|
||||||
|
active: IconCheck,
|
||||||
template: IconCopy,
|
template: IconCopy,
|
||||||
assembly: IconTool,
|
assembly: IconTool,
|
||||||
component: IconGridDots,
|
component: IconGridDots,
|
||||||
|
@ -60,7 +60,7 @@ import { useEditApiFormModal } from '../../hooks/UseForm';
|
|||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
import { apiUrl } from '../../states/ApiState';
|
import { apiUrl } from '../../states/ApiState';
|
||||||
import { useUserState } from '../../states/UserState';
|
import { useUserState } from '../../states/UserState';
|
||||||
import { DetailsField, DetailsTable } from '../../tables/Details';
|
import { DetailsField, DetailsTable, PartIcons } from '../../tables/Details';
|
||||||
import { BomTable } from '../../tables/bom/BomTable';
|
import { BomTable } from '../../tables/bom/BomTable';
|
||||||
import { UsedInTable } from '../../tables/bom/UsedInTable';
|
import { UsedInTable } from '../../tables/bom/UsedInTable';
|
||||||
import { BuildOrderTable } from '../../tables/build/BuildOrderTable';
|
import { BuildOrderTable } from '../../tables/build/BuildOrderTable';
|
||||||
@ -116,6 +116,55 @@ export default function PartDetail() {
|
|||||||
label: t`Variant of`,
|
label: t`Variant of`,
|
||||||
model: ModelType.part,
|
model: ModelType.part,
|
||||||
hidden: !part.variant_of
|
hidden: !part.variant_of
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'link',
|
||||||
|
name: 'category',
|
||||||
|
label: t`Category`,
|
||||||
|
model: ModelType.partcategory
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'link',
|
||||||
|
name: 'default_location',
|
||||||
|
label: t`Default Location`,
|
||||||
|
model: ModelType.stocklocation,
|
||||||
|
hidden: !part.default_location
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
name: 'IPN',
|
||||||
|
label: t`IPN`,
|
||||||
|
copy: true,
|
||||||
|
hidden: !part.IPN
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
name: 'revision',
|
||||||
|
label: t`Revision`,
|
||||||
|
copy: true,
|
||||||
|
hidden: !part.revision
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
name: 'units',
|
||||||
|
label: t`Units`,
|
||||||
|
copy: true,
|
||||||
|
hidden: !part.units
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
name: 'keywords',
|
||||||
|
label: t`Keywords`,
|
||||||
|
copy: true,
|
||||||
|
hidden: !part.keywords
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'link',
|
||||||
|
name: 'link',
|
||||||
|
label: t`Link`,
|
||||||
|
external: true,
|
||||||
|
copy: true,
|
||||||
|
hidden: !part.link
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -186,53 +235,44 @@ export default function PartDetail() {
|
|||||||
|
|
||||||
let bl: DetailsField[] = [
|
let bl: DetailsField[] = [
|
||||||
{
|
{
|
||||||
type: 'link',
|
type: 'boolean',
|
||||||
name: 'category',
|
name: 'active',
|
||||||
label: t`Category`,
|
label: t`Active`
|
||||||
model: ModelType.partcategory
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'link',
|
type: 'boolean',
|
||||||
name: 'default_location',
|
name: 'template',
|
||||||
label: t`Default Location`,
|
label: t`Template Part`
|
||||||
model: ModelType.stocklocation,
|
|
||||||
hidden: !part.default_location
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'string',
|
type: 'boolean',
|
||||||
name: 'IPN',
|
name: 'assembly',
|
||||||
label: t`IPN`,
|
label: t`Assembled Part`
|
||||||
copy: true,
|
|
||||||
hidden: !part.IPN
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'string',
|
type: 'boolean',
|
||||||
name: 'revision',
|
name: 'component',
|
||||||
label: t`Revision`,
|
label: t`Component Part`
|
||||||
copy: true,
|
|
||||||
hidden: !part.revision
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'string',
|
type: 'boolean',
|
||||||
name: 'units',
|
name: 'trackable',
|
||||||
label: t`Units`,
|
label: t`Trackable Part`
|
||||||
copy: true,
|
|
||||||
hidden: !part.units
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'string',
|
type: 'boolean',
|
||||||
name: 'keywords',
|
name: 'purchaseable',
|
||||||
label: t`Keywords`,
|
label: t`Purchaseable Part`
|
||||||
copy: true,
|
|
||||||
hidden: !part.keywords
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'link',
|
type: 'boolean',
|
||||||
name: 'link',
|
name: 'saleable',
|
||||||
label: t`Link`,
|
label: t`Saleable Part`
|
||||||
external: true,
|
},
|
||||||
copy: true,
|
{
|
||||||
hidden: !part.link
|
type: 'boolean',
|
||||||
|
name: 'virtual',
|
||||||
|
label: t`Virtual Part`
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -387,7 +427,10 @@ export default function PartDetail() {
|
|||||||
/>
|
/>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={8}>
|
<Grid.Col span={8}>
|
||||||
|
<Stack spacing="xs">
|
||||||
|
<PartIcons part={part} />
|
||||||
<DetailsTable fields={tl} item={part} />
|
<DetailsTable fields={tl} item={part} />
|
||||||
|
</Stack>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
<DetailsTable fields={tr} item={part} />
|
<DetailsTable fields={tr} item={part} />
|
||||||
|
@ -118,20 +118,11 @@ function PartIcon(icon: string) {
|
|||||||
* Generates a table cell with Part icons.
|
* Generates a table cell with Part icons.
|
||||||
* Only used for Part Model Details
|
* Only used for Part Model Details
|
||||||
*/
|
*/
|
||||||
function PartIcons({
|
export function PartIcons({ part }: { part: any }) {
|
||||||
assembly,
|
|
||||||
template,
|
|
||||||
component,
|
|
||||||
trackable,
|
|
||||||
purchaseable,
|
|
||||||
saleable,
|
|
||||||
virtual,
|
|
||||||
active
|
|
||||||
}: PartIconsType) {
|
|
||||||
return (
|
return (
|
||||||
<td colSpan={2}>
|
<td colSpan={2}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
|
||||||
{!active && (
|
{!part.active && (
|
||||||
<Tooltip label={t`Part is not active`}>
|
<Tooltip label={t`Part is not active`}>
|
||||||
<Badge color="red" variant="filled">
|
<Badge color="red" variant="filled">
|
||||||
<div
|
<div
|
||||||
@ -143,43 +134,43 @@ function PartIcons({
|
|||||||
</Badge>
|
</Badge>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
{template && (
|
{part.template && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
label={t`Part is a template part (variants can be made from this part)`}
|
label={t`Part is a template part (variants can be made from this part)`}
|
||||||
children={PartIcon('template')}
|
children={PartIcon('template')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{assembly && (
|
{part.assembly && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
label={t`Part can be assembled from other parts`}
|
label={t`Part can be assembled from other parts`}
|
||||||
children={PartIcon('assembly')}
|
children={PartIcon('assembly')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{component && (
|
{part.component && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
label={t`Part can be used in assemblies`}
|
label={t`Part can be used in assemblies`}
|
||||||
children={PartIcon('component')}
|
children={PartIcon('component')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{trackable && (
|
{part.trackable && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
label={t`Part stock is tracked by serial number`}
|
label={t`Part stock is tracked by serial number`}
|
||||||
children={PartIcon('trackable')}
|
children={PartIcon('trackable')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{purchaseable && (
|
{part.purchaseable && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
label={t`Part can be purchased from external suppliers`}
|
label={t`Part can be purchased from external suppliers`}
|
||||||
children={PartIcon('purchaseable')}
|
children={PartIcon('purchaseable')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{saleable && (
|
{part.saleable && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
label={t`Part can be sold to customers`}
|
label={t`Part can be sold to customers`}
|
||||||
children={PartIcon('saleable')}
|
children={PartIcon('saleable')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{virtual && (
|
{part.virtual && (
|
||||||
<Tooltip label={t`Part is virtual (not a physical part)`}>
|
<Tooltip label={t`Part is virtual (not a physical part)`}>
|
||||||
<Badge color="yellow" variant="filled">
|
<Badge color="yellow" variant="filled">
|
||||||
<div
|
<div
|
||||||
|
Reference in New Issue
Block a user