mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-13 08:21:26 +00:00
[React] Update part parameters table (#5731)
* Implement simple "PartVariantTable" component - Not yet nested - More work needed for table nesting * Fix issue rendering same image multiple times - Use useId hook to generate random key * Update PartParameter list API endpoint - Allow part_detail extra field - Add FilterSet class - Allow filter to include variants * Update PartParameterTable - Display part column - Allow returned parts to include templates of base part - Hide actions for templated parameters * Fix some code smells
This commit is contained in:
@ -3,8 +3,6 @@ import { Group, Text } from '@mantine/core';
|
||||
import { useMemo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { editPart } from '../../../functions/forms/PartForms';
|
||||
import { notYetImplemented } from '../../../functions/notifications';
|
||||
import { shortenString } from '../../../functions/tables';
|
||||
import { useTableRefresh } from '../../../hooks/TableRefresh';
|
||||
import { ApiPaths, apiUrl } from '../../../states/ApiState';
|
||||
@ -12,7 +10,6 @@ import { Thumbnail } from '../../images/Thumbnail';
|
||||
import { TableColumn } from '../Column';
|
||||
import { TableFilter } from '../Filter';
|
||||
import { InvenTreeTable, InvenTreeTableProps } from '../InvenTreeTable';
|
||||
import { RowAction } from '../RowActions';
|
||||
|
||||
/**
|
||||
* Construct a list of columns for the part table
|
||||
@ -193,33 +190,6 @@ export function PartListTable({ props }: { props: InvenTreeTableProps }) {
|
||||
|
||||
const { tableKey, refreshTable } = useTableRefresh('part');
|
||||
|
||||
// Callback function for generating set of row actions
|
||||
function partTableRowActions(record: any): RowAction[] {
|
||||
let actions: RowAction[] = [];
|
||||
|
||||
actions.push({
|
||||
title: t`Edit`,
|
||||
onClick: () => {
|
||||
editPart({
|
||||
part_id: record.pk,
|
||||
callback: () => {
|
||||
// TODO: Reload the table, somehow?
|
||||
notYetImplemented();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
actions.push({
|
||||
title: t`Detail`,
|
||||
onClick: () => {
|
||||
navigate(`/part/${record.pk}/`);
|
||||
}
|
||||
});
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
@ -231,10 +201,12 @@ export function PartListTable({ props }: { props: InvenTreeTableProps }) {
|
||||
...props,
|
||||
enableDownload: true,
|
||||
customFilters: tableFilters,
|
||||
rowActions: partTableRowActions,
|
||||
params: {
|
||||
...props.params,
|
||||
category_detail: true
|
||||
},
|
||||
onRowClick: (record, _index, _event) => {
|
||||
navigate(`/part/${record.pk}/`);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user