Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display status of item locations by status priority. #3758

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2e917b0
Display status of item locations by status priority.
GrothTobias Jun 6, 2024
9c07778
Removed unneeded code
GrothTobias Jun 6, 2024
4d74ee2
Refactored display of item locations in the results
GrothTobias Jun 21, 2024
8cf1ee9
Reverted return values of AvailabilityStatus::availabilityAsString. A…
GrothTobias Jul 8, 2024
cc13f9d
Code styling
GrothTobias Jul 8, 2024
f257af4
Code styling
GrothTobias Jul 8, 2024
5fc5bac
Fixed results-scripts.phtml for theme bootstrap3
GrothTobias Jul 8, 2024
92b5022
Fixed availability display
GrothTobias Aug 12, 2024
0a56e68
Merge branch 'dev' into item-status-location-by-priority
demiankatz Sep 5, 2024
04ee7cf
Added 'status-uncertain' icons to js-icons.phtml
GrothTobias Sep 6, 2024
239c360
Fix broken tests.
demiankatz Sep 6, 2024
cfaa055
Return location list's icons and classes in ajax response.
GrothTobias Sep 9, 2024
2c46f8e
Removed unused 'availabilityClasses' declaration from check_item_stat…
GrothTobias Sep 9, 2024
34cc7be
Server side rendering of location list and callnumbers.
GrothTobias Sep 13, 2024
3f6a1fb
Fixed code style
GrothTobias Sep 13, 2024
c3d3ef6
Fixed code styling
GrothTobias Sep 13, 2024
cc00199
code style fix
GrothTobias Sep 13, 2024
264487b
Revert unwanted changes
GrothTobias Sep 23, 2024
47d57da
Refactored pickValue() to return an array. Use associative array for …
GrothTobias Oct 4, 2024
4d5522b
Added changes to bootstrap3 theme. Fixed code styling.
GrothTobias Oct 4, 2024
72ad7e4
Fixed code styling.
GrothTobias Oct 4, 2024
d1711b7
Fixed code styling.
GrothTobias Oct 4, 2024
2da98bb
Added missing escapeHtml calls in templates. Code style update.
GrothTobias Oct 10, 2024
869aee3
Vagrantfile fix
GrothTobias Oct 10, 2024
9d88e3f
Syntax fix
GrothTobias Oct 10, 2024
54f02e0
Sync bs3 and bs5 themes
GrothTobias Oct 10, 2024
6f0c324
Merge remote-tracking branch 'refs/remotes/upstream/dev' into item-st…
GrothTobias Oct 11, 2024
e430935
Merge branch 'dev-11.0' into item-status-location-by-priority
demiankatz Oct 11, 2024
d857623
Fixed callnumbers in location lists
GrothTobias Oct 30, 2024
c033401
Fixed callnumbers in location lists
GrothTobias Oct 30, 2024
c5fbe18
Updated PHPDoc and comment
GrothTobias Nov 4, 2024
6115476
Renamed callnumber variable. Escape html attributes.
GrothTobias Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions module/VuFind/src/VuFind/AjaxHandler/GetItemStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,22 +330,12 @@ protected function getItemStatusGroup($record, $callnumberSetting)
// Summarize call number, location and availability info across all items:
$locations = [];
foreach ($record as $info) {
$availabilityStatus = $info['availability'];
// Find an available copy
if ($availabilityStatus->isAvailable()) {
if ('true' !== ($locations[$info['location']]['available'] ?? null)) {
$locations[$info['location']]['available'] = $availabilityStatus->getStatusDescription();
}
}
// Check for a use_unknown_message flag
if ($availabilityStatus->is(AvailabilityStatusInterface::STATUS_UNKNOWN)) {
$locations[$info['location']]['status_unknown'] = true;
}
// Store call number/location info:
$locations[$info['location']]['callnumbers'][] = $this->formatCallNo(
$info['callnumber_prefix'] ?? '',
$info['callnumber']
);
$locations[$info['location']]['items'][] = $info;
}

// Build list split out by location:
Expand All @@ -362,16 +352,21 @@ protected function getItemStatusGroup($record, $callnumberSetting)
$callnumberSetting,
'Multiple Call Numbers'
);

// Get combined availability for location
$locationStatus = $this->availabilityStatusManager->combine($details['items']);
$locationAvailability = $locationStatus['availability'];

$locationInfo = [
'availability' => $details['available'] ?? false,
'availability' =>
GrothTobias marked this conversation as resolved.
Show resolved Hide resolved
$locationAvailability->availabilityAsString(),
'location' => htmlentities(
$this->translateWithPrefix('location_', $location),
ENT_COMPAT,
'UTF-8'
),
'callnumbers' =>
htmlentities($locationCallnumbers, ENT_COMPAT, 'UTF-8'),
'status_unknown' => $details['status_unknown'] ?? false,
'callnumber_handler' => $callnumberHandler,
];
$locationList[] = $locationInfo;
Expand Down
4 changes: 2 additions & 2 deletions module/VuFind/src/VuFind/ILS/Logic/AvailabilityStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ public function availabilityAsString(): string
{
switch ($this->availability) {
case AvailabilityStatusInterface::STATUS_UNAVAILABLE:
return 'false';
return 'unavailable';
case AvailabilityStatusInterface::STATUS_AVAILABLE:
return 'true';
return 'available';
case AvailabilityStatusInterface::STATUS_UNKNOWN:
return 'unknown';
default:
Expand Down
25 changes: 5 additions & 20 deletions themes/bootstrap3/js/check_item_statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,12 @@
el.querySelectorAll('.callnumber,.hideIfDetailed,.location').forEach((e) => e.classList.add('hidden'));
var locationListHTML = "";
for (var x = 0; x < result.locationList.length; x++) {
var status = result.locationList[x].status;
GrothTobias marked this conversation as resolved.
Show resolved Hide resolved
locationListHTML += '<div class="groupLocation">';
if (result.locationList[x].availability) {
locationListHTML += '<span class="text-success">'
+ VuFind.icon("status-available")
+ result.locationList[x].location
+ '</span> ';
} else if (typeof(result.locationList[x].status_unknown) !== 'undefined'
&& result.locationList[x].status_unknown
) {
if (result.locationList[x].location) {
locationListHTML += '<span class="text-warning">'
+ VuFind.icon("status-unknown")
+ result.locationList[x].location
+ '</span> ';
}
} else {
locationListHTML += '<span class="text-danger">'
+ VuFind.icon("status-unavailable")
+ result.locationList[x].location
+ '</span> ';
}
locationListHTML += '<span class="' + availabilityClasses[status] + '">'

Check failure on line 63 in themes/bootstrap3/js/check_item_statuses.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

'availabilityClasses' is not defined
GrothTobias marked this conversation as resolved.
Show resolved Hide resolved
+ VuFind.icon('status-' + status)
+ result.locationList[x].location
+ '</span> ';
locationListHTML += '</div>';
locationListHTML += '<div class="groupCallnumber">';
locationListHTML += (result.locationList[x].callnumbers)
Expand Down
18 changes: 18 additions & 0 deletions themes/bootstrap3/templates/search/results-scripts.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,21 @@ if (($this->listViewOption ?? 'full') !== 'full') {
if ($this->jsResults ?? false) {
$this->headScript()->appendFile('search.js');
}

$statuses = [
\VuFind\ILS\Logic\AvailabilityStatus::STATUS_AVAILABLE,
\VuFind\ILS\Logic\AvailabilityStatus::STATUS_UNAVAILABLE,
\VuFind\ILS\Logic\AvailabilityStatus::STATUS_UNKNOWN,
\VuFind\ILS\Logic\AvailabilityStatus::STATUS_UNCERTAIN,
];

$availabilityStatuses = [];
foreach ($statuses as $status) {
$status = new \VuFind\ILS\Logic\AvailabilityStatus($status);
$availabilityStatusClasses[$status->availabilityAsString()] =
$this->availabilityStatus()->getClass($status);
}

$this->headScript()->appendScript(<<<JS
var availabilityStatusClasses = $availabilityStatuses;
JS);
1 change: 1 addition & 0 deletions themes/bootstrap3/theme.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
'status-pending' => 'FontAwesome:clock-o',
'status-ready' => 'FontAwesome:bell',
'status-unavailable' => 'FontAwesome:times',
'status-uncertain' => 'FontAwesome:circle',
'status-unknown' => 'FontAwesome:circle',
'tag-add' => 'Alias:ui-add',
'tag-remove' => 'Alias:ui-remove',
Expand Down
25 changes: 5 additions & 20 deletions themes/bootstrap5/js/check_item_statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,12 @@
el.querySelectorAll('.callnumber,.hideIfDetailed,.location').forEach((e) => e.classList.add('hidden'));
var locationListHTML = "";
for (var x = 0; x < result.locationList.length; x++) {
var status = result.locationList[x].status;
locationListHTML += '<div class="groupLocation">';
if (result.locationList[x].availability) {
locationListHTML += '<span class="text-success">'
+ VuFind.icon("status-available")
+ result.locationList[x].location
+ '</span> ';
} else if (typeof(result.locationList[x].status_unknown) !== 'undefined'
&& result.locationList[x].status_unknown
) {
if (result.locationList[x].location) {
locationListHTML += '<span class="text-warning">'
+ VuFind.icon("status-unknown")
+ result.locationList[x].location
+ '</span> ';
}
} else {
locationListHTML += '<span class="text-danger">'
+ VuFind.icon("status-unavailable")
+ result.locationList[x].location
+ '</span> ';
}
locationListHTML += '<span class="' + availabilityClasses[status] + '">'

Check failure on line 63 in themes/bootstrap5/js/check_item_statuses.js

View workflow job for this annotation

GitHub Actions / Tests with PHP 8.2

'availabilityClasses' is not defined
+ VuFind.icon('status-' + status)
+ result.locationList[x].location
+ '</span> ';
locationListHTML += '</div>';
locationListHTML += '<div class="groupCallnumber">';
locationListHTML += (result.locationList[x].callnumbers)
Expand Down
19 changes: 19 additions & 0 deletions themes/bootstrap5/templates/search/results-scripts.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,22 @@ if (($this->listViewOption ?? 'full') !== 'full') {
if ($this->jsResults ?? false) {
$this->headScript()->appendFile('search.js');
}

$statuses = [
\VuFind\ILS\Logic\AvailabilityStatus::STATUS_AVAILABLE,
\VuFind\ILS\Logic\AvailabilityStatus::STATUS_UNAVAILABLE,
\VuFind\ILS\Logic\AvailabilityStatus::STATUS_UNKNOWN,
\VuFind\ILS\Logic\AvailabilityStatus::STATUS_UNCERTAIN,
];

$availabilityStatuses = [];
foreach ($statuses as $status) {
$status = new \VuFind\ILS\Logic\AvailabilityStatus($status);
$availabilityClasses[$status->availabilityAsString()] =
$this->availabilityStatus()->getClass($status);
}

$availabilityClassesJson = json_encode($availabilityClasses);
$this->headScript()->appendScript(<<<JS
var availabilityClasses = $availabilityClassesJson;
JS);
1 change: 1 addition & 0 deletions themes/bootstrap5/theme.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
'status-pending' => 'FontAwesome:clock-o',
'status-ready' => 'FontAwesome:bell',
'status-unavailable' => 'FontAwesome:times',
'status-uncertain' => 'FontAwesome:circle',
'status-unknown' => 'FontAwesome:circle',
'tag-add' => 'Alias:ui-add',
'tag-remove' => 'Alias:ui-remove',
Expand Down
Loading