Skip to content

Commit

Permalink
feat: display edition info for individual records in Where is it popup
Browse files Browse the repository at this point in the history
The 'Where is it?' link also appear for individual records, a list of
which can be displayed for a specific title by selecting the 'Show
Edition(s)' button. This applies the changes in 'feat: display copies
per edition per location in Where is it popup' to 'Where is it?' popups
opened through links on individual records, allowing for edition
information to be shown.

Test plan: same as for 'feat: display copies per edition per location in
Where is it popup', but focusing on 'Where is it' links on individual
records.
  • Loading branch information
Chloe070196 committed Sep 6, 2024
1 parent 8f4022d commit 63cc9e5
Showing 1 changed file with 56 additions and 26 deletions.
82 changes: 56 additions & 26 deletions code/web/services/GroupedWork/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ function uploadCoverByURL() : array {
}

/** @noinspection PhpUnused */
function getCopyDetails() : array {
function getCopyDetails(): array {
global $interface;

require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php';
Expand All @@ -1556,48 +1556,78 @@ function getCopyDetails() : array {
$interface->assign('itemSummaryId', $id);
$interface->assign('relatedManifestation', $relatedManifestation);

$summaryList = [];
if ($recordId != $id) {
$record = $recordDriver->getRelatedRecord($recordId);
$summary = null;
if ($record != null) {
foreach ($relatedManifestation->getVariations() as $variation) {
foreach ($variation->getRecords() as $recordWithVariation) {
if ($recordWithVariation->id == $recordId) {
$summary = $recordWithVariation->getItemSummary();
// show the editions and group the copies at given locations by edition
if (!empty($separateItemsByEditionInWhereIsIt) && $separateItemsByEditionInWhereIsIt == 1) {
$summaryList = [];
if ($recordId != $id) {
$record = $recordDriver->getRelatedRecord($recordId);
$summary = null;
if ($record != null) {
foreach ($relatedManifestation->getVariations() as $variation) {
foreach ($variation->getRecords() as $recordWithVariation) {
if ($recordWithVariation->id == $recordId) {
$item = [];
$item['summary'] = $recordWithVariation->getItemSummary();
$item['editionCoverUrl'] = $recordWithVariation->getBookcoverUrl('small');
$item['edition'] = $recordWithVariation->edition;
array_push($summaryList, $item);
break;
}
}
if (!empty($summary)) {
break;
}
}
if (!empty($summary)) {
break;
} else {
// if there is no recordId, then do not attempt to look for edition information, and only display summary information
foreach ($relatedManifestation->getVariations() as $variation) {
if ($recordId == $id . '_' . $variation->label) {
$summary = $variation->getItemSummary();
break;
}
}
}
$interface->assign('summary', $summary);
} else {
foreach ($relatedManifestation->getVariations() as $variation) {
if ($recordId == $id . '_' . $variation->label) {
$summary = $variation->getItemSummary();
break;
}
}
$interface->assign('summary', $summary);
}
} else {
if(!empty($separateItemsByEditionInWhereIsIt) && $separateItemsByEditionInWhereIsIt == 1) {
foreach ($recordDriver->getRelatedRecords() as $relatedRecord) {
$item = [];
$item['summary'] = $relatedRecord->getItemSummary();
$item['editionCoverUrl'] = $relatedRecord->getBookcoverUrl('small');
$item['edition'] = $relatedRecord->edition;
array_push($summaryList, $item);
}
$interface->assign('summaryList', $summaryList);
}
$interface->assign('summaryList', $summaryList);
} else {
// only group copies by location, irrespective of edition (default)
if ($recordId != $id) {
$record = $recordDriver->getRelatedRecord($recordId);
$summary = null;
if ($record != null) {
foreach ($relatedManifestation->getVariations() as $variation) {
foreach ($variation->getRecords() as $recordWithVariation) {
if ($recordWithVariation->id == $recordId) {
$summary = $recordWithVariation->getItemSummary();
break;
}
}
if (!empty($summary)) {
break;
}
}
} else {
foreach ($relatedManifestation->getVariations() as $variation) {
if ($recordId == $id . '_' . $variation->label) {
$summary = $variation->getItemSummary();
break;
}
}
}
} else {
$summary = $relatedManifestation->getItemSummary();
$interface->assign('summary', $summary);
}
$interface->assign('summary', $summary);
}

$modalBody = $interface->fetch('GroupedWork/copyDetails.tpl');
return [
'title' => translate([
Expand Down

0 comments on commit 63cc9e5

Please sign in to comment.