Skip to content

Commit

Permalink
feat: handle records with multiple locations
Browse files Browse the repository at this point in the history
When there is more than one location, the
'Access Online' button opens a dropdown allowing
the user to select with link to use based
on item location.

Ensure that you have more than one item for the
record used for testing, and that they are not
recorded as being found at the same location.

Test plan:

- search Aspen for the item you have added
- click on the search result's title or 'More
Info' button
- Scroll to the 'Links' section, and open it.
- Notice the doi link
- Notice the LibKey link
- Notice th- Click the LibKey link
- if LibKey was able to
return a direct link to the text, this should take
you to a PDF of the document via LibKey, which
should open in a new tab.e 'Access Online' button
- On the search results page (/Union/Search),
open 'Show Edition(s)' on the record. Click the
'Access Online' link - select a location, click,
and notice that the redirect behaviour remains
the same.
  • Loading branch information
Chloe070196 committed Nov 25, 2024
1 parent 21cb956 commit 955e91a
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions code/web/services/Record/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -1996,10 +1996,18 @@ function viewItem(): array {
if ($item->itemId == $itemId) {
$relatedUrls = $item->getRelatedUrls();
foreach ($relatedUrls as $relatedUrl) {
return [
'success' => true,
'url' => $relatedUrl['url']
];
$libKeyLink = $this->getLibKeyUrl($relatedUrl['url']);
if (!empty($libKeyLink)) {
return [
'success' => true,
'url' => $libKeyLink
];
} else {
return [
'success' => true,
'url' => $relatedUrl['url']
];
}
}
}
}
Expand All @@ -2017,4 +2025,12 @@ function viewItem(): array {
'modalButtons' => "",
];
}

private function getLibKeyUrl($doiUrl) {
require_once ROOT_DIR . "/Drivers/LibKeyDriver.php";
$libKeyDriver = new LibKeyDriver();
$doi = str_replace(["http://", "https://"], "", $doiUrl);
return $libKeyDriver->getLibKeyLink($doi);
}
}

0 comments on commit 955e91a

Please sign in to comment.