Skip to content

Commit

Permalink
overridden: DocumentItemBody: Update renderShelfLink to use title for…
Browse files Browse the repository at this point in the history
…m documentDetails
  • Loading branch information
sakshamarora1 committed Jun 24, 2024
1 parent 002d437 commit 49977eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
} from "@inveniosoftware/react-invenio-app-ils";
import _get from "lodash/get";
import { parametrize } from "react-overridable";
import { shelfLinkComponent } from "../../../utils";
import { renderCallNumber, shelfLinkComponent } from "../../../utils";

function renderShelflink(item) {
function renderShelflink(item, documentDetails) {
const itemStatus = _get(item, "circulation.state");

// If item is on loan, don't hyperlink the shelf
Expand All @@ -17,8 +17,14 @@ function renderShelflink(item) {
_get(item, "status")
);

const shelfNumber = _get(item, "shelf");
const title = _get(documentDetails, "metadata.title");
const callNumber = renderCallNumber(item);

const itemShelf =
cannotCirculate && itemOnShelf ? _get(item, "shelf") : shelfLinkComponent(item);
cannotCirculate && itemOnShelf
? shelfNumber
: shelfLinkComponent(shelfNumber, title, callNumber);
return itemShelf;
}

Expand Down
15 changes: 9 additions & 6 deletions ui/src/overridden/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { invenioConfig } from "@inveniosoftware/react-invenio-app-ils";
import { Icon } from "semantic-ui-react";
import _get from "lodash/get";
Expand Down Expand Up @@ -38,11 +37,15 @@ export const shelfLink = (shelfNumber, { popupContent = null, iframe = false })
return shelfLink;
};

export const shelfLinkComponent = (item, iconName = "map pin") => {
const shelfNumber = _get(item, "shelf");
const callNumber = renderCallNumber(item);
const popupContent = { "Title": item.title, "Call number": callNumber };
const linkToShelf = shelfLink(shelfNumber, { popupContent: popupContent });
export const shelfLinkComponent = (
shelfNumber,
title,
callNumber,
iconName = "map pin"
) => {
const linkToShelf = shelfLink(shelfNumber, {
popupContent: { "Title": title, "Call number": callNumber },
});
return (
<>

Check failure on line 50 in ui/src/overridden/utils.js

View workflow job for this annotation

GitHub Actions / Node_Tests

'React' must be in scope when using JSX
{shelfNumber && (
Expand Down

0 comments on commit 49977eb

Please sign in to comment.