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
- 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 Dec 2, 2024
1 parent 3956f87 commit 4a1d87a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 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,11 @@ function viewItem(): array {
'modalButtons' => "",
];
}

private function getLibKeyUrl($doiUrl) {
require_once ROOT_DIR . "/Drivers/LibKeyDriver.php";
$libKeyDriver = new LibKeyDriver();
return $libKeyDriver->getLibKeyLink($doiUrl);
}
}

0 comments on commit 4a1d87a

Please sign in to comment.