mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-09 15:10:54 +00:00
Add setting to show location path as plain text in tables (#9960)
* Add setting to show location path as plain text in tables * Use the Location Path setting also for Default Location in the PartTable * Add setting to show PartCategoty as plain text * Set DefaultLocationColumn defaultVisible to false * Fix typo * Simplify settings keys * Simplify the name attribute * Fix typo --------- Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
@ -24,7 +24,9 @@ The *Display Settings* screen shows general display configuration options:
|
|||||||
{{ usersetting("FORMS_CLOSE_USING_ESCAPE") }}
|
{{ usersetting("FORMS_CLOSE_USING_ESCAPE") }}
|
||||||
{{ usersetting("PART_SHOW_QUANTITY_IN_FORMS") }}
|
{{ usersetting("PART_SHOW_QUANTITY_IN_FORMS") }}
|
||||||
{{ usersetting("DISPLAY_STOCKTAKE_TAB") }}
|
{{ usersetting("DISPLAY_STOCKTAKE_TAB") }}
|
||||||
|
{{ usersetting("SHOW_FULL_CATEGORY_IN_TABLES")}}
|
||||||
{{ usersetting("ENABLE_LAST_BREADCRUMB") }}
|
{{ usersetting("ENABLE_LAST_BREADCRUMB") }}
|
||||||
|
{{ usersetting("SHOW_FULL_LOCATION_IN_TABLES") }}
|
||||||
|
|
||||||
### Search Settings
|
### Search Settings
|
||||||
|
|
||||||
|
@ -225,6 +225,22 @@ USER_SETTINGS: dict[str, InvenTreeSettingsKeyType] = {
|
|||||||
'default': False,
|
'default': False,
|
||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
'SHOW_FULL_LOCATION_IN_TABLES': {
|
||||||
|
'name': _('Show full stock location in tables'),
|
||||||
|
'description': _(
|
||||||
|
'Disabled: The full location path is displayed as a hover tooltip. Enabled: The full location path is displayed as plain text.'
|
||||||
|
),
|
||||||
|
'default': False,
|
||||||
|
'validator': bool,
|
||||||
|
},
|
||||||
|
'SHOW_FULL_CATEGORY_IN_TABLES': {
|
||||||
|
'name': _('Show full part categories in tables'),
|
||||||
|
'description': _(
|
||||||
|
'Disabled: The full category path is displayed as a hover tooltip. Enabled: The full category path is displayed as plain text.'
|
||||||
|
),
|
||||||
|
'default': False,
|
||||||
|
'validator': bool,
|
||||||
|
},
|
||||||
'NOTIFICATION_ERROR_REPORT': {
|
'NOTIFICATION_ERROR_REPORT': {
|
||||||
'name': _('Receive error reports'),
|
'name': _('Receive error reports'),
|
||||||
'description': _('Receive notifications for system errors'),
|
'description': _('Receive notifications for system errors'),
|
||||||
|
@ -55,7 +55,9 @@ export default function UserSettings() {
|
|||||||
'FORMS_CLOSE_USING_ESCAPE',
|
'FORMS_CLOSE_USING_ESCAPE',
|
||||||
'PART_SHOW_QUANTITY_IN_FORMS',
|
'PART_SHOW_QUANTITY_IN_FORMS',
|
||||||
'DISPLAY_STOCKTAKE_TAB',
|
'DISPLAY_STOCKTAKE_TAB',
|
||||||
'ENABLE_LAST_BREADCRUMB'
|
'ENABLE_LAST_BREADCRUMB',
|
||||||
|
'SHOW_FULL_LOCATION_IN_TABLES',
|
||||||
|
'SHOW_FULL_CATEGORY_IN_TABLES'
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
@ -19,7 +19,10 @@ import { TableStatusRenderer } from '../components/render/StatusRenderer';
|
|||||||
import { RenderOwner, RenderUser } from '../components/render/User';
|
import { RenderOwner, RenderUser } from '../components/render/User';
|
||||||
import { formatCurrency, formatDate } from '../defaults/formatters';
|
import { formatCurrency, formatDate } from '../defaults/formatters';
|
||||||
import { resolveItem } from '../functions/conversion';
|
import { resolveItem } from '../functions/conversion';
|
||||||
import { useGlobalSettingsState } from '../states/SettingsStates';
|
import {
|
||||||
|
useGlobalSettingsState,
|
||||||
|
useUserSettingsState
|
||||||
|
} from '../states/SettingsStates';
|
||||||
import type { TableColumn, TableColumnProps } from './Column';
|
import type { TableColumn, TableColumnProps } from './Column';
|
||||||
import { ProjectCodeHoverCard, TableHoverCard } from './TableHoverCard';
|
import { ProjectCodeHoverCard, TableHoverCard } from './TableHoverCard';
|
||||||
|
|
||||||
@ -114,7 +117,34 @@ export function PathColumn(props: TableColumnProps): TableColumn {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function PathColumnPlainText(props: TableColumnProps): TableColumn {
|
||||||
|
return {
|
||||||
|
...props,
|
||||||
|
accessor: props.accessor ?? 'path',
|
||||||
|
render: (record: any) => {
|
||||||
|
const instance = resolveItem(record, props.accessor ?? '');
|
||||||
|
|
||||||
|
if (!instance || !instance.pathstring) {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Text>{instance.pathstring}</Text>;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function LocationColumn(props: TableColumnProps): TableColumn {
|
export function LocationColumn(props: TableColumnProps): TableColumn {
|
||||||
|
const userSettings = useUserSettingsState.getState();
|
||||||
|
const enabled = userSettings.isSet('SHOW_FULL_LOCATION_IN_TABLES', false);
|
||||||
|
if (enabled) {
|
||||||
|
return PathColumnPlainText({
|
||||||
|
accessor: 'location',
|
||||||
|
title: t`Location`,
|
||||||
|
sortable: true,
|
||||||
|
ordering: 'location',
|
||||||
|
...props
|
||||||
|
});
|
||||||
|
} else {
|
||||||
return PathColumn({
|
return PathColumn({
|
||||||
accessor: 'location',
|
accessor: 'location',
|
||||||
title: t`Location`,
|
title: t`Location`,
|
||||||
@ -123,8 +153,44 @@ export function LocationColumn(props: TableColumnProps): TableColumn {
|
|||||||
...props
|
...props
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DefaultLocationColumn(props: TableColumnProps): TableColumn {
|
||||||
|
const userSettings = useUserSettingsState.getState();
|
||||||
|
const enabled = userSettings.isSet('SHOW_FULL_LOCATION_IN_TABLES', false);
|
||||||
|
if (enabled) {
|
||||||
|
return PathColumnPlainText({
|
||||||
|
accessor: 'default_location',
|
||||||
|
title: t`Default Location`,
|
||||||
|
sortable: true,
|
||||||
|
defaultVisible: false,
|
||||||
|
ordering: 'default_location',
|
||||||
|
...props
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return PathColumn({
|
||||||
|
accessor: 'default_location',
|
||||||
|
title: t`Default Location`,
|
||||||
|
sortable: true,
|
||||||
|
defaultVisible: false,
|
||||||
|
ordering: 'default_location',
|
||||||
|
...props
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function CategoryColumn(props: TableColumnProps): TableColumn {
|
export function CategoryColumn(props: TableColumnProps): TableColumn {
|
||||||
|
const userSettings = useUserSettingsState.getState();
|
||||||
|
const enabled = userSettings.isSet('SHOW_FULL_CATEGORY_IN_TABLES', false);
|
||||||
|
if (enabled) {
|
||||||
|
return PathColumnPlainText({
|
||||||
|
accessor: 'category',
|
||||||
|
title: t`Category`,
|
||||||
|
sortable: true,
|
||||||
|
ordering: 'category',
|
||||||
|
...props
|
||||||
|
});
|
||||||
|
} else {
|
||||||
return PathColumn({
|
return PathColumn({
|
||||||
accessor: 'category',
|
accessor: 'category',
|
||||||
title: t`Category`,
|
title: t`Category`,
|
||||||
@ -133,6 +199,7 @@ export function CategoryColumn(props: TableColumnProps): TableColumn {
|
|||||||
...props
|
...props
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function BooleanColumn(props: TableColumn): TableColumn {
|
export function BooleanColumn(props: TableColumn): TableColumn {
|
||||||
return {
|
return {
|
||||||
|
@ -24,6 +24,7 @@ import { useUserState } from '../../states/UserState';
|
|||||||
import type { TableColumn } from '../Column';
|
import type { TableColumn } from '../Column';
|
||||||
import {
|
import {
|
||||||
CategoryColumn,
|
CategoryColumn,
|
||||||
|
DefaultLocationColumn,
|
||||||
DescriptionColumn,
|
DescriptionColumn,
|
||||||
LinkColumn,
|
LinkColumn,
|
||||||
PartColumn
|
PartColumn
|
||||||
@ -61,12 +62,9 @@ function partTableColumns(): TableColumn[] {
|
|||||||
CategoryColumn({
|
CategoryColumn({
|
||||||
accessor: 'category_detail'
|
accessor: 'category_detail'
|
||||||
}),
|
}),
|
||||||
{
|
DefaultLocationColumn({
|
||||||
accessor: 'default_location',
|
accessor: 'default_location_detail'
|
||||||
sortable: true,
|
}),
|
||||||
render: (record: any) => record.default_location_detail?.pathstring,
|
|
||||||
defaultVisible: false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
accessor: 'total_in_stock',
|
accessor: 'total_in_stock',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
|
@ -25,8 +25,8 @@ import type { TableColumn } from '../Column';
|
|||||||
import {
|
import {
|
||||||
DateColumn,
|
DateColumn,
|
||||||
DescriptionColumn,
|
DescriptionColumn,
|
||||||
|
LocationColumn,
|
||||||
PartColumn,
|
PartColumn,
|
||||||
PathColumn,
|
|
||||||
StatusColumn
|
StatusColumn
|
||||||
} from '../ColumnRenderers';
|
} from '../ColumnRenderers';
|
||||||
import {
|
import {
|
||||||
@ -223,10 +223,9 @@ function stockItemTableColumns({
|
|||||||
accessor: 'batch',
|
accessor: 'batch',
|
||||||
sortable: true
|
sortable: true
|
||||||
},
|
},
|
||||||
PathColumn({
|
LocationColumn({
|
||||||
accessor: 'location_detail',
|
hidden: !showLocation,
|
||||||
title: t`Location`,
|
accessor: 'location_detail'
|
||||||
hidden: !showLocation
|
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
accessor: 'purchase_order',
|
accessor: 'purchase_order',
|
||||||
|
Reference in New Issue
Block a user