Bug 20468: (follow-up) Cancel multiple items for same reason
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 6 Jun 2018 11:38:36 +0000 (13:38 +0200)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 10 Aug 2018 10:00:56 +0000 (10:00 +0000)
The repeated prompts for cancelling multiple selected items are
confusing.
The wording is slightly adjusted. The reason is asked only once per
group of selected items.

Test plan:
Create three requests.
Select two requests and cancel (from top menu) for reason A.
Cancel third request (from item menu) for reason B.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt

index fddd9fe..c43cc75 100644 (file)
 [% MACRO jsinclude BLOCK %]
     <script>
         var active_table = "#article-requests-pending";
+        var last_cancel_reason;
         $(document).ready(function() {
             $('#article-request-tabs').tabs({
                 activate: function( activate_event, activate_ui ) {
         }
 
         function HandleMulti( fnHandler, id, a ) {
+            last_cancel_reason = undefined;
             if( id !== 0 ) { fnHandler( id, a ); return; }
             $( active_table + " input[type='checkbox']:checked").each(function() {
                 fnHandler( $(this).attr('reqid'), $(this).closest('tr').find('td.ar-actions div a') );
         }
 
         function Cancel( id, a ) {
-            notes = prompt(_("Reason for cancellation:"));
-            if ( notes == null ) {
+            // last_cancel_reason: undefined means 'prompt for new reason'
+            // a null value indicates that prompt was cancelled
+            if( last_cancel_reason === undefined ) last_cancel_reason = prompt(_("Please specify the reason for cancelling selected item(s):"));
+            if ( last_cancel_reason === null ) {
                 return;
             }
 
                 data: {
                     action: 'cancel',
                     id: id,
-                    notes: notes
+                    notes: last_cancel_reason
                 },
                 success: function( data ) {
                     a.closest('tr').remove();