From 9e297367f1beef093ac8c55803ea1ff96375da40 Mon Sep 17 00:00:00 2001 From: Yury Saukou Date: Wed, 18 Dec 2024 17:23:23 +0400 Subject: [PATCH 1/2] UIREC-362 Hide 'Add piece' action when related order has 'Pending' status and 'Synchronized' workflow --- CHANGELOG.md | 2 + src/Piece/constants.js | 5 ++ src/TitleDetails/TitleDetails.js | 74 +++++++++++-------- .../TitleDetailsExpectedActions.js | 37 +++++----- 4 files changed, 72 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4392a3e5..ade13433 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 6.1.0 (IN PROGRESS) +* Hide "Add piece" action when related order has "Pending" status and "Synchronized" workflow. Refs UIREC-362. + ## [6.0.5](https://github.com/folio-org/ui-receiving/tree/v6.0.5) (2024-12-13) [Full Changelog](https://github.com/folio-org/ui-receiving/compare/v6.0.4...v6.0.5) diff --git a/src/Piece/constants.js b/src/Piece/constants.js index a61375bc..61767da3 100644 --- a/src/Piece/constants.js +++ b/src/Piece/constants.js @@ -206,3 +206,8 @@ export const PIECE_ACTION_NAMES = { expect: 'expect', delete: 'delete', }; + +export const EXPECTED_PIECES_ACTION_NAMES = { + addPiece: 'addPiece', + receive: 'receive', +}; diff --git a/src/TitleDetails/TitleDetails.js b/src/TitleDetails/TitleDetails.js index b0b7ba01..b2a0556e 100644 --- a/src/TitleDetails/TitleDetails.js +++ b/src/TitleDetails/TitleDetails.js @@ -69,6 +69,7 @@ import { } from '../constants'; import { useReceivingSearchContext } from '../contexts'; import { + EXPECTED_PIECES_ACTION_NAMES, EXPECTED_PIECES_SEARCH_VALUE, EXPECTED_PIECE_COLUMN_MAPPING, MENU_FILTERS, @@ -123,10 +124,11 @@ const TitleDetails = ({ const titleId = title.id; const isAcknowledged = title.isAcknowledged; const isOrderClosed = order.workflowStatus === ORDER_STATUSES.closed; + const isOrderPending = order.workflowStatus === ORDER_STATUSES.pending; const showRoutingList = orderFormat === ORDER_FORMATS.PEMix || orderFormat === ORDER_FORMATS.physicalResource; const numberOfPhysicalUnits = useMemo(() => { return poLine?.locations?.reduce((acc, { quantityPhysical = 0 }) => acc + quantityPhysical, 0); - }, [poLine?.locations]); + }, [poLine.locations]); const vendor = vendorsMap[order?.vendor]; const accessProvider = vendorsMap[poLine?.eresource?.accessProvider]; const materialSupplier = vendorsMap[poLine?.physical?.materialSupplier]; @@ -141,7 +143,7 @@ const TitleDetails = ({ ); const isRestrictedByAcqUnit = isRestrictionsLoading || restrictions?.protectUpdate; - const isPiecesLock = !checkinItems && order.workflowStatus === ORDER_STATUSES.pending; + const isPiecesLock = !checkinItems && isOrderPending; const isBinderyActive = get(poLine, 'details.isBinderyActive', false); const acknowledgeNoteModalLabel = intl.formatMessage({ id: 'ui-receiving.piece.receivingNoteModal.title' }); @@ -293,34 +295,48 @@ const TitleDetails = ({ } = useFilters(noop); const { filters: boundItemsFilters } = useFilters(noop, { [MENU_FILTERS.bound]: ['true'] }); - const expectedPiecesActions = useMemo( - () => ( - + const expectedPiecesProtectedActions = useMemo(() => ({ + [EXPECTED_PIECES_ACTION_NAMES.addPiece]: ( + restrictions?.protectCreate + || (isOrderPending && poLine.checkinItems === false) ), - [ - applyExpectedPiecesFilters, - expectedPiecesFilters, - onPieceCreate, - hasReceive, - restrictions, - onReceivePieces, - titleId, - isPiecesLock, - toggleExpectedPiecesColumn, - expectedPiecesVisibleColumns, - ], - ); + [EXPECTED_PIECES_ACTION_NAMES.receive]: ( + !hasReceive + || isPiecesLock + || restrictions?.protectUpdate + ), + }), [ + hasReceive, + isOrderPending, + isPiecesLock, + poLine.checkinItems, + restrictions.protectCreate, + restrictions.protectUpdate, + ]); + + const expectedPiecesActions = useMemo(() => ( + + ), [ + applyExpectedPiecesFilters, + expectedPiecesProtectedActions, + expectedPiecesFilters, + onPieceCreate, + hasReceive, + onReceivePieces, + titleId, + toggleExpectedPiecesColumn, + expectedPiecesVisibleColumns, + ]); const hasUnreceive = Boolean(piecesExistence?.[PIECE_STATUS.received]); const receivedPiecesActions = useMemo( diff --git a/src/TitleDetails/TitleDetailsActions/TitleDetailsExpectedActions.js b/src/TitleDetails/TitleDetailsActions/TitleDetailsExpectedActions.js index 82804307..3ab10bb4 100644 --- a/src/TitleDetails/TitleDetailsActions/TitleDetailsExpectedActions.js +++ b/src/TitleDetails/TitleDetailsActions/TitleDetailsExpectedActions.js @@ -16,18 +16,19 @@ import { import { EXPECTED_PIECE_COLUMN_MAPPING, + EXPECTED_PIECES_ACTION_NAMES, MENU_FILTERS, SUPPLEMENT_MENU_FILTER_OPTIONS, } from '../../Piece'; export function TitleDetailsExpectedActions({ applyFilters, + disabledActions, filters, + hiddenActions, onPieceCreate, openReceiveList, hasReceive, - disabled, - canAddPiece, toggleColumn, visibleColumns, }) { @@ -47,25 +48,27 @@ export function TitleDetailsExpectedActions({ label={intl.formatMessage({ id: 'stripes-components.paneMenuActionsToggleLabel' })} id="expected-pieces-menu-actions" > - + {(!hiddenActions?.[EXPECTED_PIECES_ACTION_NAMES.addPiece]) && ( + + )} - {hasReceive && ( + {(!hiddenActions?.[EXPECTED_PIECES_ACTION_NAMES.receive]) && ( )} - {(!hiddenActions?.[EXPECTED_PIECES_ACTION_NAMES.receive]) && ( + {(!actionsHidden?.[EXPECTED_PIECES_ACTION_NAMES.receive]) && (