Bugzilla – Attachment 128402 Details for
Bug 28377
Use the API to suspend/resume holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28377: Use the API to suspend/resume holds
Bug-28377-Use-the-API-to-suspendresume-holds.patch (text/plain), 7.70 KB, created by
Martin Renvoize (ashimema)
on 2021-12-10 15:57:17 UTC
(
hide
)
Description:
Bug 28377: Use the API to suspend/resume holds
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-12-10 15:57:17 UTC
Size:
7.70 KB
patch
obsolete
>From 0fa256358b5cfc8f4f14dd90c34ec86f1dd0fd96 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 13 May 2021 17:37:44 -0300 >Subject: [PATCH] Bug 28377: Use the API to suspend/resume holds > >This patch makes the patron page (detail and circulation) use the API to >suspend/resume holds on the holds tab. > >It previously used the old svc/ scripts we plan to replace. > >To test >1. Have a patron with some holds >2. Play with suspending/resuming holds. Include the indefinite > suspension. >=> SUCCESS: Everything works as usual >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Nothing changed, a soft breeze surprises you >5. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../prog/en/modules/circ/circulation.tt | 1 + > .../prog/en/modules/members/moremember.tt | 1 + > koha-tmpl/intranet-tmpl/prog/js/holds.js | 73 ++++++++++++------- > 3 files changed, 48 insertions(+), 27 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 1196a16425..a5ada8c27b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -954,6 +954,7 @@ > [% INCLUDE 'timepicker.inc' %] > [% INCLUDE 'select2.inc' %] > [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %] >+ [% INCLUDE 'js-date-format.inc' %] > <script> > /* Set some variable needed in circulation.js */ > var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]"; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 8f7263b1dd..f456dff8f9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -861,6 +861,7 @@ > [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") | $raw %] > [% INCLUDE 'timepicker.inc' %] > [% INCLUDE 'select2.inc' %] >+ [% INCLUDE 'js-date-format.inc' %] > <script> > /* Set some variable needed in circulation.js */ > var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]"; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js >index a022482bce..33849f8e41 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/holds.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js >@@ -94,6 +94,24 @@ function display_pickup_location (state) { > > /* global __ dataTablesDefaults borrowernumber SuspendHoldsIntranet */ > $(document).ready(function() { >+ >+ function suspend_hold(hold_id, end_date) { >+ return $.ajax({ >+ method: 'POST', >+ url: '/api/v1/holds/'+encodeURIComponent(hold_id)+'/suspension', >+ data: function () { >+ if ( end_date !== null ) return JSON.stringify({ "end_date": end_date }) >+ } >+ }); >+ } >+ >+ function resume_hold(hold_id) { >+ return $.ajax({ >+ method: 'DELETE', >+ url: '/api/v1/holds/'+encodeURIComponent(hold_id)+'/suspension' >+ }); >+ } >+ > var holdsTable; > > // Don't load holds table unless it is clicked on >@@ -225,10 +243,10 @@ $(document).ready(function() { > if ( oObj.found ) { > return ""; > } else if ( oObj.suspend == 1 ) { >- return "<a class='hold-resume btn btn-default btn-xs' id='resume" + oObj.reserve_id + "'>" >+ return "<a class='hold-resume btn btn-default btn-xs' data-hold-id='" + oObj.reserve_id + "'>" > +"<i class='fa fa-play'></i> " + __("Resume") + "</a>"; > } else { >- return "<a class='hold-suspend btn btn-default btn-xs' id='suspend" + oObj.reserve_id + "'>" >+ return "<a class='hold-suspend btn btn-default btn-xs' data-hold-id='" + oObj.reserve_id + "' data-hold-title='"+ oObj.title +"'>" > +"<i class='fa fa-pause'></i> " + __("Suspend") + "</a>"; > } > } >@@ -291,25 +309,24 @@ $(document).ready(function() { > > $('#holds-table').on( 'draw.dt', function () { > $(".hold-suspend").on( "click", function() { >- var id = $(this).attr("id").replace("suspend", ""); >- var hold = holds[id]; >- $("#suspend-modal-title").html( hold.title ); >- $("#suspend-modal-reserve_id").val( hold.reserve_id ); >+ var hold_id = $(this).data('hold-id'); >+ var hold_title = $(this).data('hold-title'); >+ $("#suspend-modal-title").html( hold_title ); >+ $("#suspend-modal-submit").data( 'hold-id', hold_id ); > $('#suspend-modal').modal('show'); > }); > >- $(".hold-resume").on( "click", function() { >- var id = $(this).attr("id").replace("resume", ""); >- var hold = holds[id]; >- $.post('/cgi-bin/koha/svc/hold/resume', { "reserve_id": hold.reserve_id }, function( data ){ >- if ( data.success ) { >- holdsTable.api().ajax.reload(); >- } else { >- if ( data.error == "HOLD_NOT_FOUND" ) { >- alert( __("Unable to resume, hold not found") ); >+ $(".hold-resume").on("click", function () { >+ var hold_id = $(this).data('hold-id'); >+ resume_hold( >+ hold_id >+ ).success(function () { >+ holdsTable.api().ajax.reload(); >+ }).error(function (jqXHR, textStatus, errorThrown) { >+ if (jqXHR.status === 404) { >+ alert(__("Unable to resume, hold not found")); > holdsTable.api().ajax.reload(); > } >- } > }); > }); > >@@ -384,19 +401,21 @@ $(document).ready(function() { > > $("#suspend-modal-submit").on( "click", function( e ) { > e.preventDefault(); >- $.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){ >- $('#suspend-modal').modal('hide'); >- if ( data.success ) { >- holdsTable.api().ajax.reload(); >- } else { >- if ( data.error == "INVALID_DATE" ) { >- alert( __("Unable to suspend hold, invalid date") ); >- } >- else if ( data.error == "HOLD_NOT_FOUND" ) { >- alert( __("Unable to suspend hold, hold not found") ); >+ var suspend_until_date = $("#suspend-modal-until").datepicker("getDate"); >+ if ( suspend_until_date !== null ) suspend_until_date = $date(suspend_until_date, {dateformat:"rfc3339"}); >+ suspend_hold( >+ $(this).data('hold-id'), >+ suspend_until_date >+ ).success(function () { >+ holdsTable.api().ajax.reload(); >+ }).error(function (jqXHR, textStatus, errorThrown) { >+ if (jqXHR.status === 404) { >+ alert(__("Unable to resume, hold not found")); > holdsTable.api().ajax.reload(); > } >- } >+ }).done(function() { >+ $("#suspend-modal-until").val(""); // clean the input >+ $('#suspend-modal').modal('hide'); > }); > }); > }); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28377
:
121129
|
121130
|
125052
|
125053
|
125057
|
125058
|
127270
|
127271
|
128380
|
128381
| 128402 |
128403
|
128404
|
128405
|
128458
|
128461