Skip to content

Commit

Permalink
frontsite: DocumentDetails: Make DocumentItemBody and Header overridable
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshamarora1 committed Apr 8, 2024
1 parent 7250289 commit c820085
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 43 deletions.
1 change: 1 addition & 0 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export {
export { SeriesCardGroup } from '@modules/Series/SeriesCardGroup';
export { DocumentCardGroup } from '@modules/Document/DocumentCardGroup';
export { DocumentRequestForm } from '@pages/frontsite/DocumentRequests';
export { default as DocumentItemBody } from '@pages/frontsite/Documents/DocumentDetails/DocumentItems/DocumentItemBody';
export { default as LiteratureSearch } from '@pages/frontsite/Literature/LiteratureSearch/LiteratureSearch';
export { Headline } from '@pages/frontsite/Home/Headline';
export { BackOfficeRoutes, FrontSiteRoutes } from '@routes/urls';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,21 @@ class DocumentItem extends Component {

<Table stackable striped compact fixed className="document-item-table">
<Table.Header>
<Table.Row data-test="header">
<Table.HeaderCell>Barcode</Table.HeaderCell>
<Table.HeaderCell>Shelf</Table.HeaderCell>
<Table.HeaderCell>Call Number</Table.HeaderCell>
<Table.HeaderCell>Status</Table.HeaderCell>
<Table.HeaderCell>Medium</Table.HeaderCell>
<Table.HeaderCell>Loan restriction</Table.HeaderCell>
</Table.Row>
<Overridable id="DocumentDetails.DocumentItem.TableHeader">
<Table.Row data-test="header">
<Table.HeaderCell>Barcode</Table.HeaderCell>
<Table.HeaderCell>Shelf</Table.HeaderCell>
<Table.HeaderCell>Status</Table.HeaderCell>
<Table.HeaderCell>Medium</Table.HeaderCell>
<Table.HeaderCell>Loan restriction</Table.HeaderCell>
</Table.Row>
</Overridable>
</Table.Header>

<Table.Body>
<DocumentItemBody items={itemsToShow} />
<Overridable id="DocumentDetails.DocumentItemTableBody">
<DocumentItemBody items={itemsToShow} />
</Overridable>
</Table.Body>

{this.moreItemsToLoad && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { Component } from 'react';
import _get from 'lodash/get';
import { PropTypes } from 'prop-types';
import { Table } from 'semantic-ui-react';
import { Media } from '@components/Media';
import { getDisplayVal, invenioConfig } from '@config';

export default class DocumentItemBody extends Component {
Expand All @@ -27,19 +26,8 @@ export default class DocumentItemBody extends Component {
return getDisplayVal('ITEMS.statuses', item.status);
};

callNumber = (items) => {
const identifiers = _get(items, 'identifiers', []);
if (identifiers === null) {
return '-';
}
const callNumber = identifiers.find(
(identifier) => identifier.scheme.toLowerCase() === 'call number'
);
return callNumber ? callNumber.value : '-';
};

render() {
const { items } = this.props;
const { items, callNumber, shelfLink } = this.props;

return items.map((item) => (
<Table.Row key={item.pid}>
Expand All @@ -50,27 +38,14 @@ export default class DocumentItemBody extends Component {
{item.barcode}
</Table.Cell>

<Media greaterThanOrEqual="tablet">
<Table.Cell
data-label="Shelf"
className="document-item-table-itemCell"
>
{item.shelf}
</Table.Cell>
</Media>

<Media lessThan="tablet">
<Table.Cell
data-label="Shelf"
className="document-item-table-itemCell"
>
{item.shelf || 'none'}
</Table.Cell>
</Media>

<Table.Cell data-label="Call Number">
{this.callNumber(item)}
<Table.Cell data-label="Shelf" className="document-item-table-itemCell">
{(shelfLink !== null ? shelfLink(item) : _get(item, 'shelf')) ||
'none'}
</Table.Cell>

{callNumber && (
<Table.Cell data-label="Call Number">{callNumber(item)}</Table.Cell>
)}
<Table.Cell data-label="Status">{this.statusLabel(item)}</Table.Cell>
<Table.Cell data-label="Medium">
{getDisplayVal('ITEMS.mediums', item.medium)}
Expand All @@ -88,4 +63,11 @@ export default class DocumentItemBody extends Component {

DocumentItemBody.propTypes = {
items: PropTypes.array.isRequired,
shelfLink: PropTypes.func,
callNumber: PropTypes.func,
};

DocumentItemBody.defaultProps = {
shelfLink: null,
callNumber: null,
};
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class DocumentTabs extends Component {

return (
<Menu.Item
icon="edit"
icon
active={menuItemIsActive}
name={internalLocationName}
onClick={this.handleLocationClick}
Expand Down

0 comments on commit c820085

Please sign in to comment.