Skip to content

Commit

Permalink
UIIN-3102: The item cannot be moved to another holdings associated wi…
Browse files Browse the repository at this point in the history
…th another instance (#2663)

* UIIN-3102: The item cannot be moved to another holdings associated with another instance

* Update CHANGELOG.md
  • Loading branch information
OleksandrHladchenko1 authored Nov 8, 2024
1 parent 3e36a66 commit a31e89a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Run `history.replace` once during component mount and update to avoid URL rewriting. Refs UIIN-3099.
* ECS | "FOLIO/MARC-shared" source is displayed in manually shared instance record. Fixes UIIN-3115.
* Allow user to move item to another holdings associated with another instance. Fixes UIIN-3102.

## [12.0.0](https://github.com/folio-org/ui-inventory/tree/v12.0.0) (2024-10-31)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v11.0.5...v12.0.0)
Expand Down
12 changes: 10 additions & 2 deletions src/Instance/MoveHoldingContext/MoveHoldingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from 'react';
import { DragDropContext } from 'react-beautiful-dnd';
import { useIntl } from 'react-intl';
import isEmpty from 'lodash/isEmpty';

import {
Loading,
Expand Down Expand Up @@ -172,6 +173,13 @@ const MoveHoldingContext = ({
}, [setIsModalOpen]);

const checkHasMultiplePOLsOrHoldings = async (holdingIds = []) => {
if (isEmpty(holdingIds)) {
return {
hasLinkedPOLs: false,
poLineHoldingIds: [],
};
}

try {
const { poLines = [] } = await ky.get(LINES_API, {
searchParams: {
Expand All @@ -181,7 +189,7 @@ const MoveHoldingContext = ({
}).json();

return {
hasLinkedPOLs: poLines.length > 1 || poLines[0]?.locations?.length > 1,
hasLinkedPOLs: poLines.length > 1 || poLines[0]?.locations?.length > 1,
poLineHoldingIds: getPOLineHoldingIds(poLines, holdingIds),
};
} catch (error) {
Expand Down Expand Up @@ -219,7 +227,7 @@ const MoveHoldingContext = ({

const holdingIdsToMove = uniq([...poLineHoldingIds, ...holdingIdsFromSelection]);

setMovingItems(holdingIdsToMove);
setMovingItems(isHolding || hasLinkedPOLs ? holdingIdsToMove : items);
setHasLinkedPOLsOrHoldings(hasLinkedPOLs);
setSelectedHoldingIds(holdingIdsToMove);
setIsModalOpen(true);
Expand Down

0 comments on commit a31e89a

Please sign in to comment.