Skip to content

Commit

Permalink
global: add identifiers tab in documents frontsite and display isbn i…
Browse files Browse the repository at this point in the history
…n backoffice (#791)

* add identifiers tab in document frontsite and fix problems with identifiers in backoffice

* Add isbn to identifiers vocabulary
  • Loading branch information
KonstantinaStoikou authored Apr 3, 2020
1 parent d2b1ab3 commit f264e91
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
"key": "ASIN",
"text": "Amazon Standard Id. Number (ASIN)"
},
{
"type": "alternative_identifier_scheme",
"key": "ISBN",
"text": "International Standard Book Number (ISBN)"
},
{
"type": "alternative_identifier_scheme",
"key": "HDL",
Expand All @@ -24,4 +19,4 @@
"key": "SAFARI",
"text": "Safari Books Online (SAFARI)"
}
]
]
7 changes: 6 additions & 1 deletion invenio_app_ils/vocabularies/data/identifier_schemes.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@
"type": "identifier_scheme",
"key": "URN",
"text": "Uniform Resource Name (URN)"
},
{
"type": "identifier_scheme",
"key": "ISBN",
"text": "International Standard Book Number (ISBN)"
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import React, { Component } from 'react';
export class DocumentIdentifiers extends Component {
render() {
const { document } = this.props;
const identifiers = groupedSchemeValueList(document.metadata.identifiers);
const alternative_identifiers = groupedSchemeValueList(
document.metadata.alternative_identifiers
);
return document.metadata.identifiers ? (
<MetadataTable
rows={groupedSchemeValueList(document.metadata.identifiers)}
/>
<MetadataTable rows={identifiers.concat(alternative_identifiers)} />
) : (
<InfoMessage
header={'No stored identifiers.'}
Expand Down
17 changes: 17 additions & 0 deletions ui/src/pages/frontsite/components/Document/DocumentInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { Component } from 'react';
import { Divider, Table } from 'semantic-ui-react';
import PropTypes from 'prop-types';
import { DocumentAuthors } from '@components/Document';
import isEmpty from 'lodash/isEmpty';
import { IdentifierRows } from '../Identifiers';

export class DocumentInfo extends Component {
constructor(props) {
Expand All @@ -23,6 +25,19 @@ export class DocumentInfo extends Component {
return null;
}

renderSpecificIdentifiers(scheme) {
const identifiers = this.metadata.identifiers
? this.metadata.identifiers.filter(
identifier => identifier.scheme === scheme
)
: null;

if (!isEmpty(identifiers)) {
return <IdentifierRows identifiers={identifiers} />;
}
return null;
}

render() {
return (
<>
Expand Down Expand Up @@ -50,6 +65,8 @@ export class DocumentInfo extends Component {
{this.metadata.keywords.value} ({this.metadata.keywords.source})
</Table.Cell>
</Table.Row>
{this.renderSpecificIdentifiers('ISBN')}
{this.renderSpecificIdentifiers('DOI')}
</Table.Body>
</Table>
</>
Expand Down
18 changes: 18 additions & 0 deletions ui/src/pages/frontsite/components/Document/DocumentMetadataTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { DocumentConference } from './DocumentConference';
import { DocumentLinks } from './DocumentLinks';
import { Notes } from '../Notes';
import _get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
import { Identifiers } from '../Identifiers';

export class DocumentMetadataTabs extends Component {
constructor(props) {
Expand All @@ -28,6 +30,22 @@ export class DocumentMetadataTabs extends Component {
</Tab.Pane>
),
},
{
menuItem: 'Identifiers',
render: () => (
<Tab.Pane attached={false}>
<Identifiers
identifiers={
isEmpty(this.document.identifiers)
? this.document.alternative_identifiers
: this.document.identifiers.concat(
this.document.alternative_identifiers
)
}
/>
</Tab.Pane>
),
},
{
menuItem: 'Content',
render: () => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class DocumentRelations extends Component {
{this.renderSerials()}
{this.renderLanguages()}
{this.renderEditions()}
)}
</>
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const IdentifierRows = ({ includeSchemes, identifiers }) => {
// Only include whitelisted schemes if includeSchemes is set
if (!includeSchemes || includeSchemes.includes(id.scheme)) {
const value = { value: id.value, material: id.material };
if (id.scheme in identifiers) {
if (id.scheme in idsByScheme) {
idsByScheme[id.scheme].push(value);
} else {
idsByScheme[id.scheme] = [value];
Expand Down

0 comments on commit f264e91

Please sign in to comment.