Skip to content

Commit

Permalink
frontsite: DocumentItems: Add documentDetails to component props
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshamarora1 authored and kpsherva committed Jun 24, 2024
1 parent 8ff6712 commit 8ee5b8e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class DocumentItem extends Component {
};

render() {
const { internalLocationName, items, showTitle } = this.props;
const { internalLocationName, items, documentDetails, showTitle } =
this.props;
const { isShowingAll, itemAmountLimit } = this.state;

const previewArrayOfItems = items.slice(0, itemAmountLimit);
Expand Down Expand Up @@ -64,7 +65,10 @@ class DocumentItem extends Component {

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

Expand Down Expand Up @@ -101,6 +105,7 @@ class DocumentItem extends Component {
DocumentItem.propTypes = {
internalLocationName: PropTypes.object.isRequired,
items: PropTypes.array.isRequired,
documentDetails: PropTypes.object.isRequired,
showTitle: PropTypes.bool.isRequired,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class DocumentItemBody extends Component {
};

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

return items.map((item) => (
<Table.Row key={item.pid}>
Expand All @@ -39,8 +39,9 @@ export default class DocumentItemBody extends Component {
</Table.Cell>

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

<Table.Cell data-label="Status">{this.statusLabel(item)}</Table.Cell>
Expand All @@ -60,6 +61,7 @@ export default class DocumentItemBody extends Component {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import DocumentTabs from './DocumentTabs';
import { LOCATION_OBJECT_TOTAL_AMOUNT_KEY } from '@config/common';

class DocumentItems extends Component {
constructor(props) {
super(props);
}

itemStatus = (item) => ({
canCirculate: () =>
invenioConfig.ITEMS.canCirculateStatuses.includes(item.status),
Expand Down Expand Up @@ -79,7 +75,10 @@ class DocumentItems extends Component {
documentDetails,
} = this.props;
const internalLocationsComponent = (
<DocumentTabs locationsObject={this.filteredLocations} />
<DocumentTabs
locationsObject={this.filteredLocations}
documentDetails={documentDetails}
/>
);

const noItemsComponent = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export default class DocumentTabs extends Component {
return locationsObject;
}

get documentDetails() {
const { documentDetails } = this.props;

return documentDetails;
}

get locationEntries() {
return Object.entries(this.locations);
}
Expand Down Expand Up @@ -132,6 +138,7 @@ export default class DocumentTabs extends Component {
<DocumentItem
internalLocationName={internalLocationName}
items={items}
documentDetails={this.documentDetails}
showTitle={activeInternalLocation !== internalLocationName}
/>
);
Expand All @@ -146,6 +153,7 @@ export default class DocumentTabs extends Component {
key={internalLocationName}
internalLocationName={internalLocationName}
items={items}
documentDetails={this.documentDetails}
showTitle={activeInternalLocation !== internalLocationName}
/>
);
Expand Down Expand Up @@ -190,4 +198,5 @@ export default class DocumentTabs extends Component {

DocumentTabs.propTypes = {
locationsObject: PropTypes.object.isRequired,
documentDetails: PropTypes.object.isRequired,
};

0 comments on commit 8ee5b8e

Please sign in to comment.