Merge 844e08814f into c56fe7f612
This commit is contained in:
commit
7f50479157
|
|
@ -13,6 +13,7 @@ import {
|
||||||
type InstanceRenderInterface,
|
type InstanceRenderInterface,
|
||||||
RenderInlineModel
|
RenderInlineModel
|
||||||
} from './Instance';
|
} from './Instance';
|
||||||
|
import { StatusRenderer, getStatusCodes } from './StatusRenderer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inline rendering of a single StockLocation instance
|
* Inline rendering of a single StockLocation instance
|
||||||
|
|
@ -102,6 +103,17 @@ export function RenderStockItem(
|
||||||
const showLocation: boolean = props.extra?.show_location !== false;
|
const showLocation: boolean = props.extra?.show_location !== false;
|
||||||
const location: any = props.instance?.location_detail;
|
const location: any = props.instance?.location_detail;
|
||||||
|
|
||||||
|
const statusKey = instance?.status_custom_key ?? instance?.status;
|
||||||
|
const flaggedStatusNames = ['ATTENTION', 'DAMAGED'];
|
||||||
|
const statusCodes = getStatusCodes(ModelType.stockitem);
|
||||||
|
const showStatus =
|
||||||
|
props.extra?.show_status === true &&
|
||||||
|
!!statusCodes &&
|
||||||
|
Object.values(statusCodes.values).some(
|
||||||
|
(entry) =>
|
||||||
|
entry.key == statusKey && flaggedStatusNames.includes(entry.name)
|
||||||
|
);
|
||||||
|
|
||||||
// Form the "secondary" text to display
|
// Form the "secondary" text to display
|
||||||
const secondary: ReactNode = (
|
const secondary: ReactNode = (
|
||||||
<Group gap='xs' style={{ paddingLeft: '5px' }}>
|
<Group gap='xs' style={{ paddingLeft: '5px' }}>
|
||||||
|
|
@ -111,6 +123,9 @@ export function RenderStockItem(
|
||||||
{instance.batch && (
|
{instance.batch && (
|
||||||
<InlineSecondaryBadge title={t`Batch`} text={instance.batch} />
|
<InlineSecondaryBadge title={t`Batch`} text={instance.batch} />
|
||||||
)}
|
)}
|
||||||
|
{showStatus && (
|
||||||
|
<StatusRenderer status={statusKey} type={ModelType.stockitem} />
|
||||||
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -587,6 +587,9 @@ function BuildAllocateLineRow({
|
||||||
field_type: 'related field',
|
field_type: 'related field',
|
||||||
api_url: apiUrl(ApiEndpoints.stock_item_list),
|
api_url: apiUrl(ApiEndpoints.stock_item_list),
|
||||||
model: ModelType.stockitem,
|
model: ModelType.stockitem,
|
||||||
|
modelRenderer: ({ instance }: { instance: any }) => (
|
||||||
|
<RenderStockItem instance={instance} extra={{ show_status: true }} />
|
||||||
|
),
|
||||||
autoFill: !output || !!output?.serial,
|
autoFill: !output || !!output?.serial,
|
||||||
autoFillFilters: {
|
autoFillFilters: {
|
||||||
serial: output?.serial
|
serial: output?.serial
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
||||||
import { ModelType } from '@lib/enums/ModelType';
|
import { ModelType } from '@lib/enums/ModelType';
|
||||||
import RemoveRowButton from '../components/buttons/RemoveRowButton';
|
import RemoveRowButton from '../components/buttons/RemoveRowButton';
|
||||||
import { StandaloneField } from '../components/forms/StandaloneField';
|
import { StandaloneField } from '../components/forms/StandaloneField';
|
||||||
|
import { RenderStockItem } from '../components/render/Stock';
|
||||||
|
|
||||||
import { ProgressBar } from '@lib/components/ProgressBar';
|
import { ProgressBar } from '@lib/components/ProgressBar';
|
||||||
import { apiUrl } from '@lib/functions/Api';
|
import { apiUrl } from '@lib/functions/Api';
|
||||||
|
|
@ -319,6 +320,9 @@ function SalesOrderAllocateLineRow({
|
||||||
field_type: 'related field',
|
field_type: 'related field',
|
||||||
api_url: apiUrl(ApiEndpoints.stock_item_list),
|
api_url: apiUrl(ApiEndpoints.stock_item_list),
|
||||||
model: ModelType.stockitem,
|
model: ModelType.stockitem,
|
||||||
|
modelRenderer: ({ instance }: { instance: any }) => (
|
||||||
|
<RenderStockItem instance={instance} extra={{ show_status: true }} />
|
||||||
|
),
|
||||||
autoFill: true,
|
autoFill: true,
|
||||||
filters: {
|
filters: {
|
||||||
available: true,
|
available: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue