mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-06 07:18:48 +00:00
Hide "location" column in certain conditions (#8587)
This commit is contained in:
parent
ced695b099
commit
390828d166
@ -313,6 +313,7 @@ export default function BuildDetail() {
|
|||||||
<StockItemTable
|
<StockItemTable
|
||||||
allowAdd={false}
|
allowAdd={false}
|
||||||
tableName='build-consumed'
|
tableName='build-consumed'
|
||||||
|
showLocation={false}
|
||||||
params={{
|
params={{
|
||||||
consumed_by: id
|
consumed_by: id
|
||||||
}}
|
}}
|
||||||
|
@ -241,6 +241,7 @@ export default function CompanyDetail(props: Readonly<CompanyDetailProps>) {
|
|||||||
<StockItemTable
|
<StockItemTable
|
||||||
allowAdd={false}
|
allowAdd={false}
|
||||||
tableName='assigned-stock'
|
tableName='assigned-stock'
|
||||||
|
showLocation={false}
|
||||||
params={{ customer: company.pk }}
|
params={{ customer: company.pk }}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
@ -42,7 +42,13 @@ import { TableHoverCard } from '../TableHoverCard';
|
|||||||
/**
|
/**
|
||||||
* Construct a list of columns for the stock item table
|
* Construct a list of columns for the stock item table
|
||||||
*/
|
*/
|
||||||
function stockItemTableColumns(): TableColumn[] {
|
function stockItemTableColumns({
|
||||||
|
showLocation,
|
||||||
|
showPricing
|
||||||
|
}: {
|
||||||
|
showLocation: boolean;
|
||||||
|
showPricing: boolean;
|
||||||
|
}): TableColumn[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
accessor: 'part',
|
accessor: 'part',
|
||||||
@ -215,6 +221,7 @@ function stockItemTableColumns(): TableColumn[] {
|
|||||||
sortable: true
|
sortable: true
|
||||||
},
|
},
|
||||||
LocationColumn({
|
LocationColumn({
|
||||||
|
hidden: !showLocation,
|
||||||
accessor: 'location_detail'
|
accessor: 'location_detail'
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
@ -239,6 +246,7 @@ function stockItemTableColumns(): TableColumn[] {
|
|||||||
title: t`Unit Price`,
|
title: t`Unit Price`,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
switchable: true,
|
switchable: true,
|
||||||
|
hidden: !showPricing,
|
||||||
render: (record: any) =>
|
render: (record: any) =>
|
||||||
formatCurrency(record.purchase_price, {
|
formatCurrency(record.purchase_price, {
|
||||||
currency: record.purchase_price_currency
|
currency: record.purchase_price_currency
|
||||||
@ -248,6 +256,7 @@ function stockItemTableColumns(): TableColumn[] {
|
|||||||
accessor: 'stock_value',
|
accessor: 'stock_value',
|
||||||
title: t`Stock Value`,
|
title: t`Stock Value`,
|
||||||
sortable: false,
|
sortable: false,
|
||||||
|
hidden: !showPricing,
|
||||||
render: (record: any) => {
|
render: (record: any) => {
|
||||||
const min_price =
|
const min_price =
|
||||||
record.purchase_price || record.part_detail?.pricing_min;
|
record.purchase_price || record.part_detail?.pricing_min;
|
||||||
@ -466,10 +475,14 @@ function stockItemTableFilters({
|
|||||||
export function StockItemTable({
|
export function StockItemTable({
|
||||||
params = {},
|
params = {},
|
||||||
allowAdd = false,
|
allowAdd = false,
|
||||||
|
showLocation = true,
|
||||||
|
showPricing = true,
|
||||||
tableName = 'stockitems'
|
tableName = 'stockitems'
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
params?: any;
|
params?: any;
|
||||||
allowAdd?: boolean;
|
allowAdd?: boolean;
|
||||||
|
showLocation?: boolean;
|
||||||
|
showPricing?: boolean;
|
||||||
tableName: string;
|
tableName: string;
|
||||||
}>) {
|
}>) {
|
||||||
const table = useTable(tableName);
|
const table = useTable(tableName);
|
||||||
@ -482,7 +495,15 @@ export function StockItemTable({
|
|||||||
[settings]
|
[settings]
|
||||||
);
|
);
|
||||||
|
|
||||||
const tableColumns = useMemo(() => stockItemTableColumns(), []);
|
const tableColumns = useMemo(
|
||||||
|
() =>
|
||||||
|
stockItemTableColumns({
|
||||||
|
showLocation: showLocation ?? true,
|
||||||
|
showPricing: showPricing ?? true
|
||||||
|
}),
|
||||||
|
[showLocation, showPricing]
|
||||||
|
);
|
||||||
|
|
||||||
const tableFilters = useMemo(
|
const tableFilters = useMemo(
|
||||||
() =>
|
() =>
|
||||||
stockItemTableFilters({
|
stockItemTableFilters({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user