diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4392a3e5..35949477 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## 6.1.0 (IN PROGRESS)
+* Add "Mark late" action to the piece form action menu. Refs UIREC-413.
+
## [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/PieceForm/PieceForm.js b/src/Piece/PieceForm/PieceForm.js
index 51b0c0f2..6fd565ad 100644
--- a/src/Piece/PieceForm/PieceForm.js
+++ b/src/Piece/PieceForm/PieceForm.js
@@ -213,6 +213,7 @@ const PieceForm = ({
[PIECE_ACTION_NAMES.unReceive]: isEditDisabled,
[PIECE_ACTION_NAMES.sendClaim]: isEditDisabled,
[PIECE_ACTION_NAMES.delayClaim]: isEditDisabled,
+ [PIECE_ACTION_NAMES.markLate]: isEditDisabled,
};
const start = (
diff --git a/src/Piece/PieceForm/PieceFormActionButtons/PieceFormActionButtons.js b/src/Piece/PieceForm/PieceFormActionButtons/PieceFormActionButtons.js
index 79eea069..7e5435fd 100644
--- a/src/Piece/PieceForm/PieceFormActionButtons/PieceFormActionButtons.js
+++ b/src/Piece/PieceForm/PieceFormActionButtons/PieceFormActionButtons.js
@@ -1,5 +1,6 @@
-import { useState } from 'react';
+import noop from 'lodash/noop';
import PropTypes from 'prop-types';
+import { useRef } from 'react';
import { FormattedMessage } from 'react-intl';
import {
@@ -28,21 +29,18 @@ export const PieceFormActionButtons = ({
onUnreceivePiece,
status = PIECE_STATUS.expected,
}) => {
- const [actionsKey, setActionsKey] = useState(new Date());
+ const onToggleRef = useRef(noop);
const actionMenu = getPieceActionMenu({
actionsDisabled,
isEditMode,
onClaimDelay,
onClaimSend,
- onCreateAnotherPiece: () => {
- setActionsKey(new Date());
-
- return onCreateAnotherPiece();
- },
+ onCreateAnotherPiece,
onDelete,
onReceive,
onStatusChange,
+ onToggle: onToggleRef.current,
onUnreceivePiece,
status,
});
@@ -77,7 +75,6 @@ export const PieceFormActionButtons = ({
-
- {actionMenu}
-
+ {({ onToggle }) => {
+ onToggleRef.current = onToggle;
+
+ return (
+
+ {actionMenu}
+
+ );
+ }}
);
diff --git a/src/Piece/PieceForm/PieceFormActionButtons/constants.js b/src/Piece/PieceForm/PieceFormActionButtons/constants.js
index 6f423d4e..d6e35765 100644
--- a/src/Piece/PieceForm/PieceFormActionButtons/constants.js
+++ b/src/Piece/PieceForm/PieceFormActionButtons/constants.js
@@ -1,3 +1,4 @@
+import without from 'lodash/without';
import { FormattedMessage } from 'react-intl';
import {
@@ -12,6 +13,7 @@ export const EXPECTED_PIECES_ACTIONS = [
PIECE_ACTION_NAMES.saveAndCreate,
PIECE_ACTION_NAMES.quickReceive,
PIECE_ACTION_NAMES.sendClaim,
+ PIECE_ACTION_NAMES.markLate,
PIECE_ACTION_NAMES.delayClaim,
PIECE_ACTION_NAMES.unReceivable,
PIECE_ACTION_NAMES.delete,
@@ -21,7 +23,7 @@ export const PIECE_ACTIONS_BY_STATUS = {
[PIECE_STATUS.expected]: EXPECTED_PIECES_ACTIONS,
[PIECE_STATUS.claimDelayed]: EXPECTED_PIECES_ACTIONS,
[PIECE_STATUS.claimSent]: EXPECTED_PIECES_ACTIONS,
- [PIECE_STATUS.late]: EXPECTED_PIECES_ACTIONS,
+ [PIECE_STATUS.late]: without(EXPECTED_PIECES_ACTIONS, PIECE_ACTION_NAMES.markLate),
[PIECE_STATUS.received]: [
PIECE_ACTION_NAMES.saveAndCreate,
PIECE_ACTION_NAMES.unReceive,
@@ -40,17 +42,21 @@ export const PIECE_ACTIONS = ({
onClaimDelay,
onClaimSend,
onCreateAnotherPiece,
- onStatusChange,
onDelete,
onReceive,
+ onStatusChange,
+ onToggle,
onUnreceivePiece,
}) => ({
[PIECE_ACTION_NAMES.delayClaim]: (