mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-30 16:41:35 +00:00
Sticky headers (#9022)
* Add user setting * Use value of user setting * Fix user for global * Stickiness * Updated docs
This commit is contained in:
@@ -20,6 +20,7 @@ The *Display Settings* screen shows general display configuration options:
|
|||||||
| ---- | ----------- | ------- | ----- |
|
| ---- | ----------- | ------- | ----- |
|
||||||
{{ usersetting("ICONS_IN_NAVBAR") }}
|
{{ usersetting("ICONS_IN_NAVBAR") }}
|
||||||
{{ usersetting("STICKY_HEADER") }}
|
{{ usersetting("STICKY_HEADER") }}
|
||||||
|
{{ usersetting("STICKY_TABLE_HEADER") }}
|
||||||
{{ usersetting("DATE_DISPLAY_FORMAT") }}
|
{{ usersetting("DATE_DISPLAY_FORMAT") }}
|
||||||
{{ usersetting("FORMS_CLOSE_USING_ESCAPE") }}
|
{{ usersetting("FORMS_CLOSE_USING_ESCAPE") }}
|
||||||
{{ usersetting("DISPLAY_STOCKTAKE_TAB") }}
|
{{ usersetting("DISPLAY_STOCKTAKE_TAB") }}
|
||||||
|
@@ -185,6 +185,12 @@ USER_SETTINGS: dict[str, InvenTreeSettingsKeyType] = {
|
|||||||
'default': False,
|
'default': False,
|
||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
'STICKY_TABLE_HEADER': {
|
||||||
|
'name': _('Fixed Table Headers'),
|
||||||
|
'description': _('Table headers are fixed to the top of the table'),
|
||||||
|
'default': False,
|
||||||
|
'validator': bool,
|
||||||
|
},
|
||||||
'ICONS_IN_NAVBAR': {
|
'ICONS_IN_NAVBAR': {
|
||||||
'name': _('Navigation Icons'),
|
'name': _('Navigation Icons'),
|
||||||
'description': _('Display icons in the navigation bar'),
|
'description': _('Display icons in the navigation bar'),
|
||||||
|
@@ -57,6 +57,7 @@ export default function UserSettings() {
|
|||||||
keys={[
|
keys={[
|
||||||
'ICONS_IN_NAVBAR',
|
'ICONS_IN_NAVBAR',
|
||||||
'STICKY_HEADER',
|
'STICKY_HEADER',
|
||||||
|
'STICKY_TABLE_HEADER',
|
||||||
'DATE_DISPLAY_FORMAT',
|
'DATE_DISPLAY_FORMAT',
|
||||||
'FORMS_CLOSE_USING_ESCAPE',
|
'FORMS_CLOSE_USING_ESCAPE',
|
||||||
'DISPLAY_STOCKTAKE_TAB',
|
'DISPLAY_STOCKTAKE_TAB',
|
||||||
|
@@ -29,6 +29,7 @@ import { useApi } from '../contexts/ApiContext';
|
|||||||
import { extractAvailableFields, mapFields } from '../functions/forms';
|
import { extractAvailableFields, mapFields } from '../functions/forms';
|
||||||
import { showApiErrorMessage } from '../functions/notifications';
|
import { showApiErrorMessage } from '../functions/notifications';
|
||||||
import { useLocalState } from '../states/LocalState';
|
import { useLocalState } from '../states/LocalState';
|
||||||
|
import { useUserSettingsState } from '../states/SettingsStates';
|
||||||
import { useStoredTableState } from '../states/StoredTableState';
|
import { useStoredTableState } from '../states/StoredTableState';
|
||||||
import InvenTreeTableHeader from './InvenTreeTableHeader';
|
import InvenTreeTableHeader from './InvenTreeTableHeader';
|
||||||
|
|
||||||
@@ -91,6 +92,12 @@ export function InvenTreeTable<T extends Record<string, any>>({
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { showContextMenu } = useContextMenu();
|
const { showContextMenu } = useContextMenu();
|
||||||
|
|
||||||
|
const userSettings = useUserSettingsState();
|
||||||
|
|
||||||
|
const stickyTableHeader = useMemo(() => {
|
||||||
|
return userSettings.isSet('STICKY_TABLE_HEADER');
|
||||||
|
}, [userSettings]);
|
||||||
|
|
||||||
// Key used for caching table data
|
// Key used for caching table data
|
||||||
const cacheKey = useMemo(() => {
|
const cacheKey = useMemo(() => {
|
||||||
const key: string = `table-${tableState.tableKey}`;
|
const key: string = `table-${tableState.tableKey}`;
|
||||||
@@ -742,6 +749,10 @@ export function InvenTreeTable<T extends Record<string, any>>({
|
|||||||
<Boundary label={`InvenTreeTable-${cacheKey}`}>
|
<Boundary label={`InvenTreeTable-${cacheKey}`}>
|
||||||
<Box pos='relative'>
|
<Box pos='relative'>
|
||||||
<DataTable
|
<DataTable
|
||||||
|
style={{
|
||||||
|
stickyHeader: stickyTableHeader ? 'top' : undefined
|
||||||
|
}}
|
||||||
|
height={stickyTableHeader ? '80vh' : undefined}
|
||||||
withTableBorder={!tableProps.noHeader}
|
withTableBorder={!tableProps.noHeader}
|
||||||
withColumnBorders
|
withColumnBorders
|
||||||
striped
|
striped
|
||||||
|
Reference in New Issue
Block a user