Bug 30200: Add custom tabs to View ILL requests page

To test:
0: yarn css:build:prod
1. Set system preference ILLRequestsTabs:
- name: New
  status:
    - NEW
- name: Requested or reverted
  status:
    - REQ
    - REQREV
- name: Queued
  status:
    - QUEUED
- name: Empty
  status:
    - NONEXISTENT

2. Add some ILL requests with the following SQL:
INSERT INTO `illrequests` (borrowernumber, branchcode, status, backend) VALUES (1, 'CPL', 'NEW', 'Standard');
INSERT INTO `illrequests` (borrowernumber, branchcode, status, backend) VALUES (1, 'CPL', 'NEW', 'Standard');
INSERT INTO `illrequests` (borrowernumber, branchcode, status, backend) VALUES (1, 'CPL', 'REQ', 'Standard');
INSERT INTO `illrequests` (borrowernumber, branchcode, status, backend) VALUES (1, 'CPL', 'REQREV', 'Standard');
INSERT INTO `illrequests` (borrowernumber, branchcode, status, backend) VALUES (1, 'CPL', 'QUEUED', 'Standard');
INSERT INTO `illrequests` (borrowernumber, branchcode, status, backend) VALUES (1, 'CPL', 'KILL', 'Standard');

3. Go to cgi-bin/koha/ill/ill-requests.pl
4. After the page loads, you should now see 4 different
   tabs:
   "All", "New", "Requested or reverted", "Queued", and
   "Empty"
5. Confirm all ILL requests are present under "All" tab
6. Confirm only ILL requests with the statuses you defined
   in system preference ILLRequestsTabs are under tabs
   "New", "Requested or reverted" and "Queued"
7. Confirm no ILL requests are under tab "Empty"
8. Clear system preference ILLRequestsTabs
9. Observe only one tab "All" under which correct ILL
   requests are presented
10. Try some other status values in ILLRequestsTabs and
   observe expected behavior

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Lari Taskula 2022-03-03 02:18:58 +00:00 committed by Katrin Fischer
parent 9fabd8cac3
commit 543c5fab0a
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
7 changed files with 67 additions and 10 deletions

2
.gitignore vendored
View File

@ -19,6 +19,8 @@ koha-tmpl/intranet-tmpl/prog/css/calendar.css
koha-tmpl/intranet-tmpl/prog/css/calendar-rtl.css
koha-tmpl/intranet-tmpl/prog/css/holds.css
koha-tmpl/intranet-tmpl/prog/css/holds-rtl.css
koha-tmpl/intranet-tmpl/prog/css/ill-requests.css
koha-tmpl/intranet-tmpl/prog/css/ill-requests-rtl.css
koha-tmpl/intranet-tmpl/prog/css/installer.css
koha-tmpl/intranet-tmpl/prog/css/installer-rtl.css
koha-tmpl/intranet-tmpl/prog/css/mainpage.css

View File

@ -503,10 +503,11 @@ if ($backends_available) {
}
$template->param(
backends => $backends,
types => [ "Book", "Article", "Journal" ],
op => $op,
branches => Koha::Libraries->search,
backends => $backends,
types => [ "Book", "Article", "Journal" ],
op => $op,
branches => Koha::Libraries->search,
illreq_tabs => C4::Context->yaml_preference('ILLRequestsTabs'),
);
output_html_with_http_headers( $cgi, $cookie, $template->output );

View File

@ -0,0 +1,16 @@
form#illfilter_form div.ms-parent button.ms-choice span.placeholder {
background-color: transparent;
cursor: default;
}
form#illfilter_form div.ms-parent button.ms-choice {
height: calc(1.5em + .75rem + 2px);
}
form#illfilter_form div.ms-parent div.ms-drop input[type="checkbox"] {
margin-left: -1.25rem
}
form#illfilter_form div.ms-parent div.ms-drop ul > li {
padding: .25rem 8px;
}

View File

@ -19,7 +19,7 @@
</li>
<li>
<label for="illfilter_status">Status:</label>
<select name="illfilter_status" id="illfilter_status"> </select>
<select name="illfilter_status" id="illfilter_status" multiple="multiple"> </select>
</li>
<li>
<label for="illfilter_dateplaced_start">Date placed between:</label>

View File

@ -3,7 +3,6 @@
var ill_borrower_details = _("View patron details");
var ill_manage = _("Manage request");
var ill_manage_select_backend_first = _("Select a backend first");
var ill_all_statuses = _("All statuses");
var ill_all_status_aliases = _("All status aliases");
var ill_no_status_alias = _("No status alias");
var ill_status_aliases = _("Status aliases");

View File

@ -16,6 +16,8 @@
[% END %]</title
>
[% INCLUDE 'doc-head-close.inc' %]
[% Asset.css("css/ill-requests.css") | $raw %]
[% Asset.css("lib/jquery/plugins/multiple-select/multiple-select.min.css") | $raw %]
</head>
<body id="illrequests" class="ill">
@ -835,6 +837,18 @@
[% END %]
</h1>
<div id="results" class="page-section">
[% WRAPPER tabs id= "ill-list-tabs" %]
[% WRAPPER tabs_nav %]
[% WRAPPER tab_item tabname= "ill-list-tab-all" bt_active= 1 %]
<span>All</span>
[% END %]
[% FOREACH illreq_tab IN illreq_tabs %]
[% WRAPPER tab_item tabname= "ill-list-tab-${loop.index}" %]
<span data-statuses="[% illreq_tab.status.join('|') | html %]">[% illreq_tab.name | html %]</span>
[% END %]
[% END %]
[% END # /WRAPPER tabs_nav %]
[% END %]
<h2>Details for all requests</h2>
[% INCLUDE 'ill-list-table.inc' %]
</div>
@ -1132,6 +1146,7 @@
[% IF op == 'generic_confirm' && Koha.Preference('ILLCheckAvailability') %]
[% Asset.js("js/ill-availability-partner.js") | $raw %]
[% END %]
[% Asset.js("lib/jquery/plugins/multiple-select/multiple-select.min.js") | $raw %]
[% END %]
<!-- prettier-ignore-start -->
[% TRY %]

View File

@ -17,6 +17,26 @@ $(document).ready(function () {
$("#addcomment").toggleClass("content_hidden");
});
$("div#ill-list-tabs a[id^='ill-list-tab'").on("click", function (e) {
e.preventDefault();
var select_status_el = $("form#illfilter_form select#illfilter_status");
var tab_statuses = $(this).children('span').attr("data-statuses");
if (tab_statuses) {
tab_statuses.split('|').forEach((select_status_option) => {
if ($("#illfilter_status option[value='"+select_status_option+"']").length === 0) {
select_status_el.append($('<option>', {
value: select_status_option,
text: select_status_option // how to access status.str when no ILL requests with that status exist?
}));
}
})
select_status_el.val(tab_statuses.split('|')).trigger("change");
} else {
select_status_el.val("").trigger("change");
}
filter();
});
// Filter partner list
// Record the list of all options
var ill_partner_options = $("#partners > option");
@ -116,7 +136,7 @@ $(document).ready(function () {
subquery_and.push(patronquery);
}
if (status) {
if (status && status.length > 0) {
subquery_and.push({ "me.status": { "=": status } });
}
if (status_alias) {
@ -544,9 +564,6 @@ $(document).ready(function () {
function addStatusOptions(statuses) {
$("#illfilter_status").children().remove();
$("#illfilter_status").append(
'<option value="">' + ill_all_statuses + "</option>"
);
statuses
.sort((a, b) => a.str.localeCompare(b.str))
.forEach(function (status) {
@ -558,6 +575,13 @@ $(document).ready(function () {
"</option>"
);
});
$("select#illfilter_status").multipleSelect( {
placeholder: _("Please select ..."),
selectAllText: _("Select all"),
allSelected: _("All selected"),
countSelected: _("# of % selected"),
noMatchesFound: _("No matches found"),
} );
}
function addStatusAliasOptions(status_aliases) {