mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-02 02:01:20 +00:00
[plugin] Render tables (#11733)
* Move useFilterSet state to the @lib * Refactor useTable hook into @lib * Refactor string helper functions * Refactor constructFormUrl func * Refactor Boundary component * Refactor StoredTableState * More refactoring * Refactor CopyButton and CopyableCell * Pass table render func to plugins * Provide internal wrapper function, while allowing the "api" and "navigate" functions to be provided by the caller * Adds <InvenTreeTable /> component which is exposed to plugins * Update frontend versioning * Update docs * Handle condition where UI does not provide table rendering function * Move queryFilters out of custom state * Fix exported type * Extract searchParams - Cannot be used outside of router component - Only provide when the table is generated internally * Bump UI version * Fix for right-click context menu - Function needs to be defined with the context menu provider
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { ActionIcon, Checkbox, Divider, Menu, Tooltip } from '@mantine/core';
|
||||
import { IconAdjustments } from '@tabler/icons-react';
|
||||
|
||||
export function TableColumnSelect({
|
||||
columns,
|
||||
onToggleColumn
|
||||
}: Readonly<{
|
||||
columns: any[];
|
||||
onToggleColumn: (columnName: string) => void;
|
||||
}>) {
|
||||
return (
|
||||
<Menu shadow='xs' closeOnItemClick={false}>
|
||||
<Menu.Target>
|
||||
<ActionIcon variant='transparent' aria-label='table-select-columns'>
|
||||
<Tooltip label={t`Select Columns`} position='top-end'>
|
||||
<IconAdjustments />
|
||||
</Tooltip>
|
||||
</ActionIcon>
|
||||
</Menu.Target>
|
||||
|
||||
<Menu.Dropdown style={{ maxHeight: '400px', overflowY: 'auto' }}>
|
||||
<Menu.Label>{t`Select Columns`}</Menu.Label>
|
||||
<Divider />
|
||||
{columns
|
||||
.filter((col) => col.switchable ?? true)
|
||||
.map((col) => (
|
||||
<Menu.Item key={col.accessor}>
|
||||
<Checkbox
|
||||
checked={!col.hidden}
|
||||
label={col.title || col.accessor}
|
||||
onChange={() => onToggleColumn(col.accessor)}
|
||||
radius='sm'
|
||||
/>
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu.Dropdown>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user