Skip to content

Commit 8d4e5d6

Browse files
CalamityCEthanFreestone
authored andcommitted
ERM-3239 Query all titles rather than just /electronic in local KB title search (#1316)
* ERM-3239 Query all titles rather than just /electronic in local KB title search * switch to TITLES_ENDPOINT in TitlesRoute * add and use printTitle icon * pass boolean showLink to RelatedTitleInfo to indicate when showing the electronic link * avoid displaying edit button on print title view * add materialType column in titles MCL * ERM-3239 Query all titles rather than just /electronic in local KB title search * fix tests
1 parent a6f830a commit 8d4e5d6

File tree

12 files changed

+123
-62
lines changed

12 files changed

+123
-62
lines changed

icons/printTitle.png

452 Bytes
Loading

icons/printTitle.svg

Lines changed: 1 addition & 0 deletions
Loading

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,11 @@
338338
"name": "platform",
339339
"alt": " ",
340340
"title": "platform"
341+
},
342+
{
343+
"name": "printTitle",
344+
"alt": " ",
345+
"title": "Print title"
341346
}
342347
]
343348
}
Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { FormattedMessage } from 'react-intl';
4+
import { useHistory } from 'react-router-dom';
5+
import { AppIcon } from '@folio/stripes/core';
46
import {
57
Col,
68
Headline,
9+
InfoPopover,
710
KeyValue,
811
NoValue,
912
Row,
13+
TextLink
1014
} from '@folio/stripes/components';
1115

1216
import { resourceTypes } from '../../constants';
@@ -37,39 +41,67 @@ const propTypes = {
3741
value: PropTypes.string,
3842
}),
3943
}).isRequired,
44+
showLink: PropTypes.bool,
4045
};
4146

4247
const RelatedTitleInfo = ({
43-
relatedTitle
44-
}) => (
45-
<div data-test-related-titles>
46-
<div className={css.separator} />
47-
<Headline data-test-title-instance-name size="large" tag="h3">
48-
<FormattedMessage id="ui-agreements.eresources.relatedTitle" values={{ name: relatedTitle.name }} />
49-
</Headline>
50-
<Row>
51-
<Col xs={3}>
52-
<KeyValue label={<FormattedMessage id="ui-agreements.eresources.materialType" />}>
53-
<div data-test-title-instance-sub-type>{relatedTitle.subType?.label ?? <NoValue />}</div>
54-
</KeyValue>
55-
</Col>
56-
{relatedTitle.type.value === resourceTypes.MONOGRAPH || relatedTitle.type.value === resourceTypes.BOOK ?
57-
<>
58-
<EResourceIdentifier titleInstance={relatedTitle} type="isbn" />
59-
<EResourceIdentifier titleInstance={relatedTitle} type="doi" />
60-
</>
61-
:
62-
<>
63-
<EResourceIdentifier titleInstance={relatedTitle} type="ezb" />
64-
<EResourceIdentifier titleInstance={relatedTitle} type="zdb" />
65-
<EResourceIdentifier titleInstance={relatedTitle} type="eissn" />
66-
<EResourceIdentifier titleInstance={relatedTitle} type="pissn" />
67-
<EResourceIdentifier titleInstance={relatedTitle} type="issn" />
68-
</>
48+
relatedTitle,
49+
showLink = false
50+
}) => {
51+
const { location: { search: searchString } } = useHistory();
52+
53+
const renderElectronicLink = () => {
54+
const relatedTitleLink = `${relatedTitle.id}${searchString}`;
55+
return (
56+
<Row>
57+
<Col xs={12}>
58+
<AppIcon
59+
app="agreements"
60+
iconAlignment="baseline"
61+
iconKey="title"
62+
size="small"
63+
>
64+
<TextLink to={relatedTitleLink}><FormattedMessage id="ui-agreements.eresources.electronicTitle" values={{ name: relatedTitle.name }} /></TextLink>
65+
<InfoPopover
66+
content={<FormattedMessage id="ui-agreements.eresources.relatedTitle.infoPopover" />}
67+
/>
68+
</AppIcon>
69+
</Col>
70+
</Row>
71+
);
72+
};
73+
74+
return (
75+
<div data-test-related-titles>
76+
<div className={css.separator} />
77+
<Headline data-test-title-instance-name size="large" tag="h3">
78+
<FormattedMessage id="ui-agreements.eresources.relatedTitle" values={{ name: relatedTitle.name }} />
79+
</Headline>
80+
<Row>
81+
<Col xs={3}>
82+
<KeyValue label={<FormattedMessage id="ui-agreements.eresources.materialType" />}>
83+
<div data-test-title-instance-sub-type>{relatedTitle.subType?.label ?? <NoValue />}</div>
84+
</KeyValue>
85+
</Col>
86+
{relatedTitle.type.value === resourceTypes.MONOGRAPH || relatedTitle.type.value === resourceTypes.BOOK ?
87+
<>
88+
<EResourceIdentifier titleInstance={relatedTitle} type="isbn" />
89+
<EResourceIdentifier titleInstance={relatedTitle} type="doi" />
90+
</>
91+
:
92+
<>
93+
<EResourceIdentifier titleInstance={relatedTitle} type="ezb" />
94+
<EResourceIdentifier titleInstance={relatedTitle} type="zdb" />
95+
<EResourceIdentifier titleInstance={relatedTitle} type="eissn" />
96+
<EResourceIdentifier titleInstance={relatedTitle} type="pissn" />
97+
<EResourceIdentifier titleInstance={relatedTitle} type="issn" />
98+
</>
6999
}
70-
</Row>
71-
</div>
72-
);
100+
</Row>
101+
{showLink && renderElectronicLink()}
102+
</div>
103+
);
104+
};
73105

74106
RelatedTitleInfo.propTypes = propTypes;
75107
export default RelatedTitleInfo;

src/components/RelatedTitleInfo/RelatedTitleInfo.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ import translationsProperties from '../../../test/helpers';
66
import RelatedTitleInfo from './RelatedTitleInfo';
77
import { relatedMonographTitle, relatedSerialTitle } from './testResources';
88

9+
jest.mock('react-router-dom', () => ({
10+
...jest.requireActual('react-router-dom'),
11+
useHistory: () => ({
12+
location: {
13+
search: ''
14+
}
15+
}),
16+
}));
17+
918
let renderComponent;
1019
describe('RelatedTitleInfo', () => {
1120
describe('with monograph resource', () => {

src/components/TitleCard/TitleCardInfo.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import RelatedTitleInfo from '../RelatedTitleInfo';
88

99
const propTypes = {
1010
title: PropTypes.shape({
11+
subType: PropTypes.shape({
12+
value: PropTypes.string,
13+
}),
1114
type: PropTypes.oneOfType([
1215
PropTypes.shape({ label: PropTypes.string }),
1316
PropTypes.string,
@@ -27,13 +30,13 @@ const TitleCardInfo = ({ title }) => {
2730
const type = (titleInstance?.type?.label ?? titleInstance?.type ?? '').toLowerCase();
2831
return (
2932
<>
30-
{ type === resourceTypes.MONOGRAPH || type === resourceTypes.BOOK ?
33+
{type === resourceTypes.MONOGRAPH || type === resourceTypes.BOOK ?
3134
<MonographResourceInfo titleInstance={titleInstance} />
3235
:
3336
<SerialResourceInfo titleInstance={titleInstance} />
3437
}
35-
{ titleInstance?.relatedTitles?.map((relatedTitle, i) => (
36-
<RelatedTitleInfo key={i} relatedTitle={relatedTitle} />
38+
{titleInstance?.relatedTitles?.map((relatedTitle, i) => (
39+
<RelatedTitleInfo key={i} relatedTitle={relatedTitle} showLink={title.subType?.value === 'print' && relatedTitle.subType?.value === 'electronic'} />
3740
))
3841
}
3942
</>

src/components/views/EResource/EResource.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ const EResource = ({
5858
if (eresource.class === resourceClasses.TITLEINSTANCE) {
5959
EResourceViewComponent = Title;
6060
icon = 'title';
61+
if (eresource.subType?.value === 'print') {
62+
icon = 'printTitle';
63+
}
6164
} else if (eresource.class === resourceClasses.PCI) {
6265
EResourceViewComponent = PCI;
6366
icon = 'pci';
@@ -78,14 +81,16 @@ const EResource = ({
7881
entity={eresource}
7982
/>
8083
}
81-
<Button
82-
buttonStyle="primary"
83-
id="clickable-edit-eresource"
84-
marginBottom0
85-
onClick={handlers.onEdit}
86-
>
87-
<FormattedMessage id="stripes-components.button.edit" />
88-
</Button>
84+
{eresource.subType?.value !== 'print' &&
85+
<Button
86+
buttonStyle="primary"
87+
id="clickable-edit-eresource"
88+
marginBottom0
89+
onClick={handlers.onEdit}
90+
>
91+
<FormattedMessage id="stripes-components.button.edit" />
92+
</Button>
93+
}
8994
</PaneMenu>
9095
</IfPermission>
9196
) : null

src/components/views/Title/Title.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,16 @@ export default class Title extends React.Component {
113113
</Col>
114114
</Row>
115115
<AccordionSet initialStatus={this.getInitialAccordionsState()}>
116-
<Agreements
117-
{...this.getSectionProps('eresourceAgreements')}
118-
isEmptyMessage={<FormattedMessage id="ui-agreements.emptyAccordion.noAgreementsEresource" />}
119-
visibleColumns={['name', 'type', 'startDate', 'endDate', 'eresource', 'acqMethod', 'coverage', 'isCustomCoverage']}
120-
/>
121-
<AcquisitionOptions {...this.getSectionProps('acquisitionOptions')} />
116+
{data.eresource.subType.value !== 'print' &&
117+
<>
118+
<Agreements
119+
{...this.getSectionProps('eresourceAgreements')}
120+
isEmptyMessage={<FormattedMessage id="ui-agreements.emptyAccordion.noAgreementsEresource" />}
121+
visibleColumns={['name', 'type', 'startDate', 'endDate', 'eresource', 'acqMethod', 'coverage', 'isCustomCoverage']}
122+
/>
123+
<AcquisitionOptions {...this.getSectionProps('acquisitionOptions')} />
124+
</>
125+
}
122126
<NotesSmartAccordion
123127
{...this.getSectionProps('notes')}
124128
domainName="agreements"
@@ -129,7 +133,7 @@ export default class Title extends React.Component {
129133
pathToNoteDetails={urls.notes()}
130134
/>
131135
{
132-
handlers.isSuppressFromDiscoveryEnabled('title') &&
136+
handlers.isSuppressFromDiscoveryEnabled('title') && data.eresource.subType?.value !== 'print' &&
133137
<DiscoverySettings
134138
handlers={handlers}
135139
id="discoverySettings"

src/components/views/Titles/Titles.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424

2525
import {
2626
getResourceIdentifier,
27-
getSiblingIdentifier,
2827
EResourceType,
2928
useHandleSubmitSearch,
3029
usePrevNextPagination,
@@ -279,35 +278,36 @@ const Titles = ({
279278
columnMapping={{
280279
name: <FormattedMessage id="ui-agreements.eresources.name" />,
281280
publicationType: <FormattedMessage id="ui-agreements.eresources.publicationType" />,
281+
materialType: <FormattedMessage id="ui-agreements.eresources.materialType" />,
282282
isbn: <FormattedMessage id="ui-agreements.identifier.isbn" />,
283-
eissn: <FormattedMessage id="ui-agreements.identifier.eissn" />,
284-
pissn: <FormattedMessage id="ui-agreements.identifier.pissn" />,
283+
issn: <FormattedMessage id="ui-agreements.identifier.issn" />,
285284
}}
286285
columnWidths={{
287286
name: 300,
288-
publicationType: 100,
287+
publicationType: 150,
288+
materialType: 150,
289289
isbn: 150,
290-
eissn: 150,
291-
pissn: 150,
290+
issn: 150,
292291
}}
293292
contentData={data.titles}
294293
formatter={{
295294
name: e => {
295+
const iconKey = e.subType?.value === 'print' ? 'printTitle' : 'title';
296296
return (
297297
<AppIcon
298298
app="agreements"
299299
iconAlignment="baseline"
300-
iconKey="title"
300+
iconKey={iconKey}
301301
size="small"
302302
>
303303
{e?.longName ?? e.name}
304304
</AppIcon>
305305
);
306306
},
307307
publicationType: e => <EResourceType resource={e} />,
308+
materialType: e => e?.subType?.label,
308309
isbn: e => getResourceIdentifier(e, 'isbn'),
309-
eissn: e => getResourceIdentifier(e, 'eissn') ?? getResourceIdentifier(e, 'issn'),
310-
pissn: e => getResourceIdentifier(e, 'pissn') ?? getSiblingIdentifier(e, 'issn'),
310+
issn: e => (getResourceIdentifier(e, 'issn') ?? getResourceIdentifier(e, 'eissn')) ?? getResourceIdentifier(e, 'pissn'),
311311
}}
312312
id="list-titles"
313313
isEmptyMessage={
@@ -332,7 +332,7 @@ const Titles = ({
332332
sortDirection={sortOrder.startsWith('-') ? 'descending' : 'ascending'}
333333
sortOrder={sortOrder.replace(/^-/, '').replace(/,.*/, '')}
334334
totalCount={count}
335-
visibleColumns={['name', 'publicationType', 'isbn', 'eissn', 'pissn']}
335+
visibleColumns={['name', 'publicationType', 'materialType', 'isbn', 'issn']}
336336
/>
337337
</Pane>
338338
{children}

src/components/views/Titles/Titles.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ describe('Titles', () => {
119119
columns: [
120120
'Name',
121121
'Publication type',
122+
'Material type',
122123
'ISBN',
123-
'ISSN (Online)',
124-
'ISSN (Print)'
124+
'ISSN',
125125
],
126126
}).exists();
127127
});

0 commit comments

Comments
 (0)