From 8e5a5e4b371b628bfcdd797a599c2e8d6b229692 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 22 Mar 2018 15:47:45 +0100 Subject: [PATCH] Bug 20468: Add multi-select to staff article request form Content-Type: text/plain; charset=utf-8 Adds a column with a checkbox. Adds buttons under the table for Select, Clear and Actions menu. An additional javascript function HandleMulti is placed between the form and the functions handling individual requests. Note: The Actions menu below does not contain Print slip. This does not work in its current form. This could be handled on a separate report. Test plan: [1] Enable Article Requests. Add a few requests. [2] Test the Select all / Clear all functionality on the form. [3] Verify that the menu options Process, Complete and Cancel work as expected both from the individual Actions menu as from the shared Actions menu for selected requests. Signed-off-by: Marcel de Rooy --- .../prog/en/modules/circ/article-requests.tt | 150 ++++++++++++--------- 1 file changed, 87 insertions(+), 63 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt index 744bb54..f983545 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt @@ -9,6 +9,38 @@ +[% BLOCK actions %] + + Actions + + + +[% END %] + [% INCLUDE 'header.inc' %] [% INCLUDE 'cat-search.inc' %] @@ -62,6 +94,7 @@ + @@ -78,13 +111,14 @@ - [% FOREACH ar IN article_requests_pending %] + [% END %] @@ -190,6 +198,7 @@
Title Requested article Collection
+ There are no pending article requests at this time.

@@ -150,35 +184,9 @@

[% ar.created_on | $KohaDates %] - +
+ @@ -206,13 +215,14 @@ - [% FOREACH ar IN article_requests_processing %] + [% END %]
Title Requested article Collection
+ There are no article requests in processing at this time.

@@ -278,36 +288,20 @@

[% ar.created_on | $KohaDates %] - +
- + +
+
+ Select all Clear all + [% PROCESS actions id_arg=0 pull_right='' aria_menu='table_controls' %] +
@@ -325,9 +319,41 @@ [% IF article_requests_processing.count %] $(".ar-processing-none").hide(); [% END %] + + $(".SelectAll").on("click", function(e) { + e.preventDefault(); + if( $('table#article-requests-pending-table').is(":visible") ) + var table='article-requests-pending-table'; + else table='article-requests-processing-table'; + $("table#"+table+" input[type='checkbox']").prop('checked', true); + }); + $(".ClearAll").on("click", function(e) { + e.preventDefault(); + if( $('table#article-requests-pending-table').is(":visible") ) + var table='article-requests-pending-table'; + else table='article-requests-processing-table'; + $("table#"+table+" input[type='checkbox']").prop('checked', false); + }); + $("a.ar-actions").on('click', function(e) { + // Hide menu option ? + if( $('table#article-requests-processing-table').is(":visible") ) + $('a.ar-process-request').hide(); + else $('a.ar-process-request').show(); + }); }); - function PrintSlip(link) { + function HandleMulti( fnHandler, id, a ) { + if( id !== 0 ) { fnHandler( id, a ); return; } + if( $('table#article-requests-pending-table').is(":visible") ) + var table='article-requests-pending-table'; + else table='article-requests-processing-table'; + $("table#"+table+" input[type='checkbox']:checked").each(function() { + fnHandler( $(this).attr('reqid'), $(this).closest('tr').find('td.ar-actions div a') ); + }); + } + + function PrintSlip(id, a) { + var link = 'article-request-slip.pl?id='+id; window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); } @@ -337,8 +363,7 @@ return; } - a.closest('td').prepend(''); - a.closest('div').hide(); + a.closest('td').prepend('').find('div.dropdown').hide(); $.ajax({ type: "POST", url: '/cgi-bin/koha/svc/article_request', @@ -358,9 +383,9 @@ function Process( id, a ) { var table_row = a.closest('tr').clone(); table_row.find('.ar-process-request').remove(); + table_row.find('input[type="checkbox"]').prop('checked', false); - a.closest('td').prepend(''); - a.closest('div').hide(); + a.closest('td').prepend('').find('div.dropdown').hide(); $.ajax({ type: "POST", url: '/cgi-bin/koha/svc/article_request', @@ -379,8 +404,7 @@ } function Complete( id, a ) { - a.closest('td').prepend(''); - a.closest('div').hide(); + a.closest('td').prepend('').find('div.dropdown').hide(); $.ajax({ type: "POST", url: '/cgi-bin/koha/svc/article_request', -- 2.1.4