diff --git a/CHANGELOG.md b/CHANGELOG.md
index 35949477..0a62f06e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
## 6.1.0 (IN PROGRESS)
* Add "Mark late" action to the piece form action menu. Refs UIREC-413.
+* 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 b1af826a..7f356673 100644
--- a/src/Piece/constants.js
+++ b/src/Piece/constants.js
@@ -207,3 +207,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..412e111a 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..2f1fa690 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({
+ actionsDisabled,
+ actionsHidden,
applyFilters,
filters,
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"
>
-
+ {(!actionsHidden?.[EXPECTED_PIECES_ACTION_NAMES.addPiece]) && (
+
+ )}
- {hasReceive && (
+ {(!actionsHidden?.[EXPECTED_PIECES_ACTION_NAMES.receive]) && (