diff --git a/src/frontend/src/hooks/UseTable.tsx b/src/frontend/src/hooks/UseTable.tsx index b1bf2ce735..4ce0800f28 100644 --- a/src/frontend/src/hooks/UseTable.tsx +++ b/src/frontend/src/hooks/UseTable.tsx @@ -39,6 +39,8 @@ export type TableState = { records: any[]; setRecords: (records: any[]) => void; updateRecord: (record: any) => void; + editable: boolean; + setEditable: (value: boolean) => void; }; /** @@ -131,6 +133,8 @@ export function useTable(tableName: string): TableState { const [isLoading, setIsLoading] = useState(false); + const [editable, setEditable] = useState(false); + return { tableKey, refreshTable, @@ -156,6 +160,8 @@ export function useTable(tableName: string): TableState { setPage, records, setRecords, - updateRecord + updateRecord, + editable, + setEditable }; } diff --git a/src/frontend/src/tables/Column.tsx b/src/frontend/src/tables/Column.tsx index b2ea9fcccd..03366ca1fb 100644 --- a/src/frontend/src/tables/Column.tsx +++ b/src/frontend/src/tables/Column.tsx @@ -1,3 +1,5 @@ +import { ApiFormFieldType } from '../components/forms/fields/ApiFormField'; + export type TableColumnProps = { accessor?: string; // The key in the record to access title?: string; // The title of the column - Note: this may be supplied by the API, and is not required, but it can be overridden if required @@ -5,6 +7,8 @@ export type TableColumnProps = { sortable?: boolean; // Whether the column is sortable switchable?: boolean; // Whether the column is switchable hidden?: boolean; // Whether the column is hidden + editable?: boolean; // Whether the value of this column can be edited + definition?: ApiFormFieldType; // Optional field definition for the column render?: (record: T, index?: number) => any; // A custom render function filter?: any; // A custom filter function filtering?: boolean; // Whether the column is filterable diff --git a/src/frontend/src/tables/InvenTreeTable.tsx b/src/frontend/src/tables/InvenTreeTable.tsx index 8da06a22e1..7585a7670e 100644 --- a/src/frontend/src/tables/InvenTreeTable.tsx +++ b/src/frontend/src/tables/InvenTreeTable.tsx @@ -697,6 +697,7 @@ export function InvenTreeTable({