diff --git a/CHANGELOG.md b/CHANGELOG.md
index c18b9515..99b3d392 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
* Display and edit claiming active and interval fields in receiving title. Refs UIREC-288.
* Optimize pieces query to improve performance. Refs UIREC-298.
* Display claim actions for Piece. Refs UIREC-291.
+* Set claiming workflow statuses for single Piece. Refs UIREC-292.
## [4.0.0](https://github.com/folio-org/ui-receiving/tree/v4.0.0) (2023-10-12)
[Full Changelog](https://github.com/folio-org/ui-receiving/compare/v3.0.0...v4.0.0)
diff --git a/src/TitleDetails/AddPieceModal/AddPieceModal.js b/src/TitleDetails/AddPieceModal/AddPieceModal.js
index 6d46af21..a58d2f21 100644
--- a/src/TitleDetails/AddPieceModal/AddPieceModal.js
+++ b/src/TitleDetails/AddPieceModal/AddPieceModal.js
@@ -138,6 +138,11 @@ const AddPieceModal = ({
handleSubmit();
}, [change, handleSubmit]);
+ const onStatusChange = useCallback((status) => {
+ change('receivingStatus', status);
+ onSave();
+ }, [change, onSave]);
+
const start = (
);
diff --git a/src/TitleDetails/AddPieceModal/AddPieceModal.test.js b/src/TitleDetails/AddPieceModal/AddPieceModal.test.js
index af57f5e7..5c59eb0b 100644
--- a/src/TitleDetails/AddPieceModal/AddPieceModal.test.js
+++ b/src/TitleDetails/AddPieceModal/AddPieceModal.test.js
@@ -203,4 +203,38 @@ describe('AddPieceModal', () => {
expect(saveBtn).toBeInTheDocument();
});
});
+
+ it('should update piece status', async () => {
+ const onChange = jest.fn();
+
+ renderAddPieceModal({
+ ...defaultProps,
+ form: {
+ ...defaultProps.form,
+ change: onChange,
+ },
+ hasValidationErrors: false,
+ initialValues: {
+ 'id': 'cd3fd1e7-c195-4d8e-af75-525e1039d643',
+ 'format': 'Other',
+ 'poLineId': 'a92ae36c-e093-4daf-b234-b4c6dc33a258',
+ 'titleId': '03329fea-1b5d-43ab-b955-20bcd9ba530d',
+ 'holdingId': '60c67dc5-b646-425e-bf08-a8bf2d0681fb',
+ 'isCreateAnother': false,
+ 'isCreateItem': false,
+ receivingStatus: PIECE_STATUS.expected,
+ },
+ });
+
+ const dropdownButton = screen.getByTestId('dropdown-trigger-button');
+
+ await user.click(dropdownButton);
+ await screen.findByRole('button', { expanded: true });
+
+ const unReceiveButton = screen.getByTestId('unReceivable-piece-button');
+
+ await user.click(unReceiveButton);
+
+ expect(defaultProps.onSubmit).toHaveBeenCalled();
+ });
});
diff --git a/src/TitleDetails/AddPieceModal/ModalActionButtons/ModalActionButtons.css b/src/TitleDetails/AddPieceModal/ModalActionButtons/ModalActionButtons.css
index e82ba62a..a3513bfb 100644
--- a/src/TitleDetails/AddPieceModal/ModalActionButtons/ModalActionButtons.css
+++ b/src/TitleDetails/AddPieceModal/ModalActionButtons/ModalActionButtons.css
@@ -31,7 +31,7 @@
border-top-right-radius: 999px !important;
border-bottom-left-radius: 0;
border-top-left-radius: 0;
- margin-left: 1px;
+ margin-left: -1px;
margin-right: 0;
}
}
diff --git a/src/TitleDetails/AddPieceModal/ModalActionButtons/ModalActionButtons.js b/src/TitleDetails/AddPieceModal/ModalActionButtons/ModalActionButtons.js
index cb4d5675..e3b18545 100644
--- a/src/TitleDetails/AddPieceModal/ModalActionButtons/ModalActionButtons.js
+++ b/src/TitleDetails/AddPieceModal/ModalActionButtons/ModalActionButtons.js
@@ -22,6 +22,7 @@ export const ModalActionButtons = ({
onDelete,
onReceive,
onSave,
+ onStatusChange,
status,
}) => {
const actionMenu = getPieceActionMenu({
@@ -31,6 +32,7 @@ export const ModalActionButtons = ({
onCreateAnotherPiece,
onDelete,
onReceive,
+ onStatusChange,
status,
});
const saveButtonLabelId = 'ui-receiving.piece.actions.saveAndClose';
@@ -66,6 +68,7 @@ export const ModalActionButtons = ({
buttonStyle: 'primary',
buttonClass: css.dropdownButton,
marginBottom0: true,
+ 'data-testid': 'dropdown-trigger-button',
}}
>
@@ -84,6 +87,7 @@ ModalActionButtons.propTypes = {
onDelete: PropTypes.func,
onReceive: PropTypes.func,
onSave: PropTypes.func.isRequired,
+ onStatusChange: PropTypes.func,
status: PropTypes.string,
};
diff --git a/src/TitleDetails/AddPieceModal/ModalActionButtons/constants.js b/src/TitleDetails/AddPieceModal/ModalActionButtons/constants.js
index 4a9125ac..d03d0b9c 100644
--- a/src/TitleDetails/AddPieceModal/ModalActionButtons/constants.js
+++ b/src/TitleDetails/AddPieceModal/ModalActionButtons/constants.js
@@ -1,3 +1,4 @@
+import { noop } from 'lodash';
import { FormattedMessage } from 'react-intl';
import {
@@ -11,7 +12,7 @@ export const PIECE_STATUS = {
late: 'Late',
claimDelayed: 'Claim delayed',
claimSent: 'Claim sent',
- unreceivable: 'Unreceivable',
+ unReceivable: 'Unreceivable',
};
export const PIECE_ACTION_NAMES = {
@@ -20,6 +21,7 @@ export const PIECE_ACTION_NAMES = {
sendClaim: 'sendClaim',
delayClaim: 'delayClaim',
unReceivable: 'unReceivable',
+ unReceive: 'unReceive',
expect: 'expect',
delete: 'delete',
};
@@ -35,10 +37,10 @@ export const PIECE_ACTIONS_BY_STATUS = {
],
[PIECE_STATUS.received]: [
PIECE_ACTION_NAMES.saveAndCreate,
- PIECE_ACTION_NAMES.unReceivable,
+ PIECE_ACTION_NAMES.unReceive,
PIECE_ACTION_NAMES.delete,
],
- [PIECE_STATUS.unreceivable]: [
+ [PIECE_STATUS.unReceivable]: [
PIECE_ACTION_NAMES.saveAndCreate,
PIECE_ACTION_NAMES.expect,
PIECE_ACTION_NAMES.delete,
@@ -50,11 +52,16 @@ export const PIECE_ACTIONS = ({
disabled,
isEditMode,
onCreateAnotherPiece,
+ onStatusChange,
onDelete,
onReceive,
}) => ({
delayClaim: (
-