diff --git a/docs/docs/settings/user.md b/docs/docs/settings/user.md index a49ee19f8f..674aef5197 100644 --- a/docs/docs/settings/user.md +++ b/docs/docs/settings/user.md @@ -24,7 +24,9 @@ The *Display Settings* screen shows general display configuration options: {{ usersetting("FORMS_CLOSE_USING_ESCAPE") }} {{ usersetting("PART_SHOW_QUANTITY_IN_FORMS") }} {{ usersetting("DISPLAY_STOCKTAKE_TAB") }} +{{ usersetting("SHOW_FULL_CATEGORY_IN_TABLES")}} {{ usersetting("ENABLE_LAST_BREADCRUMB") }} +{{ usersetting("SHOW_FULL_LOCATION_IN_TABLES") }} ### Search Settings diff --git a/src/backend/InvenTree/common/setting/user.py b/src/backend/InvenTree/common/setting/user.py index 644f75b75e..6f4c7ab0e0 100644 --- a/src/backend/InvenTree/common/setting/user.py +++ b/src/backend/InvenTree/common/setting/user.py @@ -225,6 +225,22 @@ USER_SETTINGS: dict[str, InvenTreeSettingsKeyType] = { 'default': False, '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': { 'name': _('Receive error reports'), 'description': _('Receive notifications for system errors'), diff --git a/src/frontend/src/pages/Index/Settings/UserSettings.tsx b/src/frontend/src/pages/Index/Settings/UserSettings.tsx index cda57dcbfb..e8500d607c 100644 --- a/src/frontend/src/pages/Index/Settings/UserSettings.tsx +++ b/src/frontend/src/pages/Index/Settings/UserSettings.tsx @@ -55,7 +55,9 @@ export default function UserSettings() { 'FORMS_CLOSE_USING_ESCAPE', 'PART_SHOW_QUANTITY_IN_FORMS', 'DISPLAY_STOCKTAKE_TAB', - 'ENABLE_LAST_BREADCRUMB' + 'ENABLE_LAST_BREADCRUMB', + 'SHOW_FULL_LOCATION_IN_TABLES', + 'SHOW_FULL_CATEGORY_IN_TABLES' ]} /> ) diff --git a/src/frontend/src/tables/ColumnRenderers.tsx b/src/frontend/src/tables/ColumnRenderers.tsx index c2a157d315..800d754c90 100644 --- a/src/frontend/src/tables/ColumnRenderers.tsx +++ b/src/frontend/src/tables/ColumnRenderers.tsx @@ -19,7 +19,10 @@ import { TableStatusRenderer } from '../components/render/StatusRenderer'; import { RenderOwner, RenderUser } from '../components/render/User'; import { formatCurrency, formatDate } from '../defaults/formatters'; import { resolveItem } from '../functions/conversion'; -import { useGlobalSettingsState } from '../states/SettingsStates'; +import { + useGlobalSettingsState, + useUserSettingsState +} from '../states/SettingsStates'; import type { TableColumn, TableColumnProps } from './Column'; import { ProjectCodeHoverCard, TableHoverCard } from './TableHoverCard'; @@ -114,24 +117,88 @@ 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 {instance.pathstring}; + } + }; +} + export function LocationColumn(props: TableColumnProps): TableColumn { - return PathColumn({ - accessor: 'location', - title: t`Location`, - sortable: true, - ordering: 'location', - ...props - }); + 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({ + accessor: 'location', + title: t`Location`, + sortable: true, + ordering: 'location', + ...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 { - return PathColumn({ - accessor: 'category', - title: t`Category`, - sortable: true, - ordering: 'category', - ...props - }); + 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({ + accessor: 'category', + title: t`Category`, + sortable: true, + ordering: 'category', + ...props + }); + } } export function BooleanColumn(props: TableColumn): TableColumn { diff --git a/src/frontend/src/tables/part/PartTable.tsx b/src/frontend/src/tables/part/PartTable.tsx index d221bb0514..c67c05b26b 100644 --- a/src/frontend/src/tables/part/PartTable.tsx +++ b/src/frontend/src/tables/part/PartTable.tsx @@ -24,6 +24,7 @@ import { useUserState } from '../../states/UserState'; import type { TableColumn } from '../Column'; import { CategoryColumn, + DefaultLocationColumn, DescriptionColumn, LinkColumn, PartColumn @@ -61,12 +62,9 @@ function partTableColumns(): TableColumn[] { CategoryColumn({ accessor: 'category_detail' }), - { - accessor: 'default_location', - sortable: true, - render: (record: any) => record.default_location_detail?.pathstring, - defaultVisible: false - }, + DefaultLocationColumn({ + accessor: 'default_location_detail' + }), { accessor: 'total_in_stock', sortable: true, diff --git a/src/frontend/src/tables/stock/StockItemTable.tsx b/src/frontend/src/tables/stock/StockItemTable.tsx index 17ab55f1e7..6113f7578b 100644 --- a/src/frontend/src/tables/stock/StockItemTable.tsx +++ b/src/frontend/src/tables/stock/StockItemTable.tsx @@ -25,8 +25,8 @@ import type { TableColumn } from '../Column'; import { DateColumn, DescriptionColumn, + LocationColumn, PartColumn, - PathColumn, StatusColumn } from '../ColumnRenderers'; import { @@ -223,10 +223,9 @@ function stockItemTableColumns({ accessor: 'batch', sortable: true }, - PathColumn({ - accessor: 'location_detail', - title: t`Location`, - hidden: !showLocation + LocationColumn({ + hidden: !showLocation, + accessor: 'location_detail' }), { accessor: 'purchase_order',