Skip to content

Commit

Permalink
Merge pull request #348 from folio-org/release/1.0.6
Browse files Browse the repository at this point in the history
Release 1.0.6
  • Loading branch information
Jack-Golding authored Jan 7, 2025
2 parents 27cc49e + b359b4f commit 05f588f
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 79 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ jobs:
comment_title: Jest Unit Test Statistics

- name: Publish Jest coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: jest-coverage-report
path: ${{ env.JEST_COVERAGE_REPORT_DIR }}
retention-days: 30

- name: Publish yarn.lock
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: failure()
with:
name: yarn.lock
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ jobs:
comment_title: Jest Unit Test Statistics

- name: Publish Jest coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: jest-coverage-report
path: ${{ env.JEST_COVERAGE_REPORT_DIR }}
retention-days: 30

- name: Publish yarn.lock
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: failure()
with:
name: yarn.lock
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# change history for ui-serials-management

## 1.0.6 2025-01-07
* UISER-172 Receiving pieces for combined pieces do not include correct display summary
* MODSER-54 Combination pieces do not get allocated a `date`

## 1.0.5 2024-08-23
* UISER-129 Add "Create item" checkbox to "Generate in receiving" dialog

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/serials-management",
"version": "1.0.5",
"version": "1.0.6",
"description": "FOLIO app for serials-management",
"main": "src/index.js",
"repository": "folio-org/ui-serials-management",
Expand Down
59 changes: 43 additions & 16 deletions src/components/GenerateReceivingModal/GenerateReceivingModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import {
PIECE_SET_ENDPOINT,
RECEIVING_PIECES_ENDPOINT,
} from '../../constants/endpoints';
import {
INTERNAL_COMBINATION_PIECE,
INTERNAL_OMISSION_PIECE,
INTERNAL_RECURRENCE_PIECE,
} from '../../constants/internalPieceClasses';

import css from './GenerateReceivingModal.css';

Expand Down Expand Up @@ -64,7 +69,12 @@ const GenerateReceivingModal = ({
'submitReceivingPiece',
],
(data) => {
return ky.post(`${RECEIVING_PIECES_ENDPOINT}${data?.createItem ? '?createItem=true' : ''}`, { json: data?.receiving }).json();
return ky
.post(
`${RECEIVING_PIECES_ENDPOINT}${data?.createItem ? '?createItem=true' : ''}`,
{ json: data?.receiving }
)
.json();
}
);

Expand Down Expand Up @@ -145,19 +155,20 @@ const GenerateReceivingModal = ({
};

const formatReceivingPiece = (piece, values) => {
if (!piece?.omissionOrigins) {
const pieceInfo = piece?.combinationOrigins
? {
date: addDays(piece?.recurrencePieces[0]?.date, values?.interval),
label: piece?.recurrencePieces[0]?.label,
}
: {
date: addDays(piece?.date, values?.interval),
label: piece?.label,
};
if (piece?.class !== INTERNAL_OMISSION_PIECE) {
const pieceInfo =
piece?.class === INTERNAL_COMBINATION_PIECE
? {
date: addDays(piece?.recurrencePieces[0]?.date, values?.interval),
label: piece?.label,
}
: {
date: addDays(piece?.date, values?.interval),
label: piece?.label,
};

return {
...values?.createItem && { createItem: values.createItem },
...(values?.createItem && { createItem: values.createItem }),
receiving: {
poLineId: serial?.orderLine?.remoteId,
titleId: serial?.orderLine?.titleId,
Expand Down Expand Up @@ -222,6 +233,20 @@ const GenerateReceivingModal = ({
};

const renderPredictedPiecesInformation = () => {
// Format piece information based on class
const renderPieceDateLabel = (piece) => {
switch (piece?.class) {
case INTERNAL_RECURRENCE_PIECE:
return `${piece?.date}, ${piece?.label}`;
case INTERNAL_OMISSION_PIECE:
return `${piece?.date}`;
case INTERNAL_COMBINATION_PIECE:
return `${piece?.recurrencePieces[0]?.date}, ${piece?.label}`;
default:
return null;
}
};

return (
<>
{!serial?.orderLine?.remoteId_object?.locations?.length && (
Expand Down Expand Up @@ -278,7 +303,7 @@ const GenerateReceivingModal = ({
<FormattedMessage id="ui-serials-management.pieceSets.firstPiece" />
}
>
{pieceSet?.pieces[0]?.date}, {pieceSet?.pieces[0]?.label}
{renderPieceDateLabel(pieceSet?.pieces[0])}
</KeyValue>
</Col>
<Col xs={3}>
Expand All @@ -287,8 +312,9 @@ const GenerateReceivingModal = ({
<FormattedMessage id="ui-serials-management.pieceSets.lastPiece" />
}
>
{pieceSet?.pieces[pieceSet?.pieces?.length - 1]?.date},{' '}
{pieceSet?.pieces[pieceSet?.pieces?.length - 1]?.label}
{renderPieceDateLabel(
pieceSet?.pieces?.[pieceSet?.pieces?.length - 1]
)}
</KeyValue>
</Col>
</Row>
Expand Down Expand Up @@ -354,7 +380,8 @@ const GenerateReceivingModal = ({
)}
</FormattedMessage>
</Col>
{serial?.orderLine?.remoteId_object?.physical?.createInventory === 'Instance, Holding, Item' && (
{serial?.orderLine?.remoteId_object?.physical?.createInventory ===
'Instance, Holding, Item' && (
<Col xs={3}>
<Label>
<FormattedMessage id="ui-serials-management.pieceSets.createItem" />
Expand Down
54 changes: 32 additions & 22 deletions src/components/PiecePublicationDate/PiecePublicationDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,44 @@ import PropTypes from 'prop-types';
import { FormattedMessage, FormattedDate } from 'react-intl';

import { InfoBox } from '@folio/stripes-erm-components';
import {
INTERNAL_COMBINATION_PIECE,
INTERNAL_OMISSION_PIECE,
INTERNAL_RECURRENCE_PIECE,
} from '../../constants/internalPieceClasses';

const propTypes = {
piece: PropTypes.object,
};

const PiecePublicationDate = ({ piece }) => {
if (piece?.recurrencePieces) {
return (
<>
<FormattedDate value={piece?.recurrencePieces[0].date} />
<br />
<FormattedMessage
id="ui-serials-management.pieceSets.combinedPieces"
values={{ length: piece?.recurrencePieces.length }}
/>
</>
);
} else {
return (
<>
<FormattedDate value={piece?.date} />
{piece?.omissionOrigins && (
<InfoBox type="success">
<FormattedMessage id="ui-serials-management.pieceSets.omitted" />
</InfoBox>
)}
</>
);
switch (piece?.class) {
case INTERNAL_RECURRENCE_PIECE:
return <FormattedDate value={piece?.date} />;
case INTERNAL_OMISSION_PIECE:
return (
<>
<FormattedDate value={piece?.date} />
{piece?.class === INTERNAL_OMISSION_PIECE && (
<InfoBox type="success">
<FormattedMessage id="ui-serials-management.pieceSets.omitted" />
</InfoBox>
)}
</>
);
case INTERNAL_COMBINATION_PIECE:
return (
<>
<FormattedDate value={piece?.recurrencePieces[0].date} />
<br />
<FormattedMessage
id="ui-serials-management.pieceSets.combinedPieces"
values={{ length: piece?.recurrencePieces.length }}
/>
</>
);
default:
return null;
}
};

Expand Down
51 changes: 25 additions & 26 deletions src/components/PiecePublicationDate/PiecePublicationDate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,26 @@ import { renderWithIntl } from '@folio/stripes-erm-testing';
import PiecePublicationDate from './PiecePublicationDate';
import { translationsProperties } from '../../../test/helpers';

function getCurrentFormattedDate() {
const date = new Date();
const formattedDate = `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
return formattedDate;
}

const expectedDate = getCurrentFormattedDate();

const recurrencePiece = {
piece: {
id: '582683dd-e971-44e6-bb4e-45b07fb06291',
date: '2024-04-01',
owner: {
id: '10e19919-dd8e-4a18-8846-14824100d853',
},
templateString: 'Volume: {{enumeration1.level1}} {{enumeration1.level2}}',
recurrenceRule: {
id: '7255a1d0-e7c3-4f9b-bd65-f3b28476ee88',
},
receivingPieces: '[]',
label: 'Volume: 25 1',
rowIndex: 0,
id: '582683dd-e971-44e6-bb4e-45b07fb06291',
date: '2024-04-01',
owner: {
id: '10e19919-dd8e-4a18-8846-14824100d853',
},
class: 'org.olf.internalPiece.InternalRecurrencePiece',
templateString: 'Volume: {{enumeration1.level1}} {{enumeration1.level2}}',
recurrenceRule: {
id: '7255a1d0-e7c3-4f9b-bd65-f3b28476ee88',
},
receivingPieces: '[]',
label: 'Volume: 25 1',
rowIndex: 0,
};

const omissionPiece = {
id: 'e549636a-af5f-4249-88dc-f2d33e759d8c',
class: 'org.olf.internalPiece.InternalOmissionPiece',
date: '2024-04-01',
omissionOrigins: '[]',
owner: {
id: '5e63a7aa-953d-4f31-9eee-5b2782ca7b5c',
Expand All @@ -37,35 +30,41 @@ const omissionPiece = {
label: 'test',
rowIndex: 0,
};
// FIXME This needs to be fixed, dates arenot currently working

describe('PiecePublicationDate', () => {
describe('PiecePublicationDate with recurrence pieces ', () => {
let renderComponent;
beforeEach(() => {
renderComponent = renderWithIntl(
<PiecePublicationDate id="piece-set-section-info" piece={recurrencePiece} />,
<PiecePublicationDate
id="piece-set-section-info"
piece={recurrencePiece}
/>,
translationsProperties
);
});

test('renders the expected date value', async () => {
const { getByText } = renderComponent;
expect(getByText(expectedDate)).toBeInTheDocument();
expect(getByText('4/1/2024')).toBeInTheDocument();
});
});

describe('PiecePublicationDate with omission origins', () => {
let renderComponent;
beforeEach(() => {
renderComponent = renderWithIntl(
<PiecePublicationDate id="piece-set-section-info" piece={omissionPiece} />,
<PiecePublicationDate
id="piece-set-section-info"
piece={omissionPiece}
/>,
translationsProperties
);
});

test('renders the expected date value', async () => {
const { getByText } = renderComponent;
expect(getByText(expectedDate)).toBeInTheDocument();
expect(getByText('4/1/2024')).toBeInTheDocument();
});

test('renders the Omitted', async () => {
Expand Down
7 changes: 5 additions & 2 deletions src/components/PieceSetSections/PiecesList/PiecesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';

import { Row, Col, MultiColumnList } from '@folio/stripes/components';

import { INTERNAL_OMISSION_PIECE } from '../../../constants/internalPieceClasses';

import PiecePublicationDate from '../../PiecePublicationDate';

const propTypes = {
Expand All @@ -16,7 +19,7 @@ const PiecesList = ({ pieceSet, id }) => {
/* istanbul ignore next */
const formatter = {
issueCount: (e) => {
return e?.omissionOrigins ? '-' : e.rowIndex + 1;
return e?.class === INTERNAL_OMISSION_PIECE ? '-' : e.rowIndex + 1;
},
publicationDate: (e) => renderPublicationDate(e),
displaySummary: (e) => {
Expand Down Expand Up @@ -47,7 +50,7 @@ const PiecesList = ({ pieceSet, id }) => {
columnWidths={{
publicationDate: { min: 100, max: 165 },
}}
contentData={pieceSet?.pieces.sort((a, b) => (a?.date < b?.date ? -1 : 1))}
contentData={pieceSet?.pieces}
formatter={formatter}
interactive={false}
visibleColumns={[
Expand Down
8 changes: 4 additions & 4 deletions src/components/PieceSetSections/PiecesList/PiecesList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ describe('PiecesList', () => {
content: '1',
}),
await MultiColumnListCell({ row: 0, columnIndex: 1 }).has({
content: '2/1/2024',
content: '10/1/2024',
}),
await MultiColumnListCell({ row: 0, columnIndex: 2 }).has({
content: '1 1',
content: '5 9',
}),
await MultiColumnListCell({ row: 1, columnIndex: 0 }).has({
content: '2',
}),
await MultiColumnListCell({ row: 1, columnIndex: 1 }).has({
content: '3/1/2024',
content: '7/1/2024',
}),
await MultiColumnListCell({ row: 1, columnIndex: 2 }).has({
content: '1 2',
content: '3 6',
}),
]);
});
Expand Down
6 changes: 4 additions & 2 deletions src/components/PiecesPreviewModal/PiecesPreviewModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import {
CREATE_PREDICTED_PIECES,
GENERATE_PIECES_PREVIEW,
} from '../../constants/endpoints';
import { INTERNAL_OMISSION_PIECE } from '../../constants/internalPieceClasses';

import PiecePublicationDate from '../PiecePublicationDate';

const propTypes = {
Expand Down Expand Up @@ -128,9 +130,9 @@ const PiecesPreviewModal = ({

/* istanbul ignore next */
const formatter = {
// If omissionOrigins exist then piece is omitted
// If pieces class is internal omission piece then piece is omitted
issueCount: (e) => {
return e?.omissionOrigins ? '-' : e.rowIndex + 1;
return e?.class === INTERNAL_OMISSION_PIECE ? '-' : e.rowIndex + 1;
},
publicationDate: (e) => renderPublicationDate(e),
displaySummary: (e) => {
Expand Down
Loading

0 comments on commit 05f588f

Please sign in to comment.