Bugzilla – Attachment 122376 Details for
Bug 20472
Add digital scan as optional format to Article Requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20472: Edit URL field on staff form
Bug-20472-Edit-URL-field-on-staff-form.patch (text/plain), 10.51 KB, created by
Martin Renvoize (ashimema)
on 2021-06-24 10:08:06 UTC
(
hide
)
Description:
Bug 20472: Edit URL field on staff form
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-06-24 10:08:06 UTC
Size:
10.51 KB
patch
obsolete
>From c88baab8c7ae08a0937b5e001f716dcdc5bd24a6 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 5 Apr 2018 14:22:42 +0200 >Subject: [PATCH] Bug 20472: Edit URL field on staff form > >This patch makes the following changes: > >Add menu option Edit URLs. >Edit modal form to edit URLs. >Save URLs via ajax call to svc/article_request (Add action update_urls). >Add URL column to pending and processing table. >Allow Edit URLs for pending table too (just as Complete). >Do not allow 'Complete request' if a scan request has no URL(s). > >Test plan: >[1] Add a few scan and photocopy requests. >[2] Fill url-A and url-B in two separate scan requests. >[3] Verify that these two urls are really saved (refresh form). >[4] Check that you cannot complete a scan request without URL and that you > cannot add a URL to a photocopy request. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../prog/en/modules/circ/article-requests.tt | 77 ++++++++++++++++++- > svc/article_request | 7 +- > 2 files changed, 81 insertions(+), 3 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 8cf05a2d5f..e97eb8708b 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 >@@ -24,6 +24,13 @@ > Process request > </a> > >+ [% IF id_arg && format=='SCAN' %] >+ <a class="ar-edit-urls" href="#" onclick="HandleMulti( EditURLs, [% id_arg %], $(this) ); return false;"> >+ <i class="fa fa-edit"></i> >+ Edit URLs >+ </a> >+ [% END %] >+ > <a class="ar-complete-request" href="#" onclick="HandleMulti( Complete, [% id_arg | html %], $(this) ); return false;"> > <i class="fa fa-check-circle"></i> > Complete request >@@ -51,6 +58,23 @@ > [% ELSIF myitem.notforloan < 0 %]<span>On order</span> > [% END %] > [% END %] >+[% BLOCK urls_modal %] >+ <div id="myModal" class="modal fade modal-lg" role="dialog"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h4 class="modal-title">Edit URL(s)</h4> >+ </div> >+ <div class="modal-body"> >+ <textarea id="urls" style="width:100%;"></textarea> >+ </div> >+ <div class="modal-footer"> >+ <button type="button" class="btn btn-default" data-dismiss="modal">Save</button> >+ </div> >+ </div> >+ </div> >+ </div> >+[% END %] > > <body id="circ_article-requests" class="circ"> > [% INCLUDE 'header.inc' %] >@@ -76,6 +100,7 @@ > <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2"> > > <h1>Article requests</h1> >+ [% PROCESS urls_modal %] > > <form id="ar-branchcode-form" method="post"> > <select name="branchcode" id="branchcode"> >@@ -128,6 +153,7 @@ > <th class="ar-enumchron">Enumeration</th> > <th class="ar-barcode">Barcode</th> > <th class="ar-format">Format</th> >+ <th class="ar-urls">URLs</th> > <th class="ar-patron">Patron</th> > <th class="ar-date">Date</th> > <th class="ar-actions noExport">Actions</th> >@@ -193,6 +219,7 @@ > <td class="ar-enumchron">[% ar.item.enumchron | html %]</td> > <td class="ar-barcode">[% ar.item.barcode | html %]</td> > <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td> >+ <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id%]" style="display:none;">[% ar.urls %]</span>[% END %]</td> > <td class="ar-patron"> > <p> > <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]"> >@@ -204,7 +231,7 @@ > </td> > <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td> > <td class="ar-actions"> >- [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %] >+ [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %] > </td> > </tr> > [% END %] >@@ -231,6 +258,7 @@ > <th class="ar-enumchron">Enumeration</th> > <th class="ar-barcode">Barcode</th> > <th class="ar-format">Format</th> >+ <th class="ar-urls">URLs</th> > <th class="ar-patron">Patron</th> > <th class="ar-date">Date</th> > <th class="ar-actions noExport">Actions</th> >@@ -294,6 +322,7 @@ > <td class="ar-enumchron">[% ar.item.enumchron | html %]</td> > <td class="ar-barcode">[% ar.item.barcode | html %]</td> > <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td> >+ <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id%]" style="display:none;">[% ar.urls %]</span>[% END %]</td> > <td class="ar-patron"> > <p> > <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]"> >@@ -305,7 +334,7 @@ > </td> > <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td> > <td class="ar-actions"> >- [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %] >+ [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %] > </td> > </tr> > [% END %] >@@ -356,6 +385,19 @@ > else $('a.ar-process-request').show(); > }); > >+ $('#myModal').on("shown.bs.modal", function () { >+ $('#myModal textarea').focus(); >+ }); >+ $('#myModal').on("hidden.bs.modal", function () { >+ // Set focus back to dropdown >+ var id = $('#myModal textarea').attr('ar_id'); >+ var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a'); >+ if( link.length > 0 ) link[0].focus(); >+ }); >+ $( '#myModal button' ).on("click", function () { >+ SaveURLs( $('#myModal textarea').val() ); >+ }); >+ > pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, { > "aoColumnDefs": [ > { "aTargets": [0, -1], "bSortable": false, "bSearchable": false }, >@@ -451,6 +493,12 @@ > } > > function Complete( id, a ) { >+ // if it is a scan, check if urls field is filled >+ var urlspan = $('span#url_'+id); >+ if( urlspan.length>0 && urlspan.text() === '' ) { >+ alert( _("Please fill URL before completing request.") ); >+ return; >+ } > a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide(); > $.ajax({ > type: "POST", >@@ -472,6 +520,31 @@ > $("#ar_pending_count").html( pending_datatable.rows().count() ); > $("#ar_processing_count").html( processing_datatable.rows().count() ); > } >+ >+ function EditURLs(id) { >+ var urls = $('span#url_'+ id).text(); >+ $('#myModal textarea').val(urls); >+ $('#myModal textarea').attr('ar_id', id); >+ $('#myModal').modal('show'); >+ } >+ >+ function SaveURLs(newurl) { >+ var id = $('#myModal textarea').attr('ar_id'); >+ $('span#url_'+ id).text(newurl); >+ if(newurl) >+ $('span#url_yesno_'+id).text(_("Yes")); >+ else >+ $('span#url_yesno_'+id).text(_("No")); >+ >+ $.ajax({ >+ type: "POST", >+ url: '/cgi-bin/koha/svc/article_request', >+ data: { action: 'update_urls', id: id, urls: newurl }, >+ dataType: 'json', >+ error: function() { alert('Error: Saving URL failed!'); }, >+ success: function(data) { if(!data.success) alert('Saving URL failed!'); }, >+ }); >+ } > </script> > [% END %] > >diff --git a/svc/article_request b/svc/article_request >index e5c1759b2b..9d55d9a0ab 100755 >--- a/svc/article_request >+++ b/svc/article_request >@@ -20,7 +20,7 @@ > > use Modern::Perl; > >-use CGI; >+use CGI qw ( -utf8 ); > use JSON qw(to_json); > > use C4::Auth qw(check_cookie_auth); >@@ -58,6 +58,11 @@ if ($ar) { > $ar->branchcode( $branchcode ) if $branchcode; > $ar = $ar->store(); > } >+ elsif( $action eq 'update_urls' ) { >+ my $urls = $cgi->param('urls') // q{}; >+ $ar->urls( $urls ); >+ $ar = $ar->store(); >+ } > } > > print to_json( { success => $ar ? 1 : 0 } ); >-- >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 20472
:
107506
|
107507
|
107508
|
107509
|
107510
|
107511
|
107512
|
111473
|
111474
|
111475
|
111476
|
111477
|
111478
|
111479
|
122366
|
122367
|
122368
|
122369
|
122370
|
122371
|
122372
|
122373
|
122374
|
122375
|
122376
|
122377
|
122378
|
122379
|
122382
|
122383
|
122699
|
122700
|
122701
|
122702
|
122703
|
122704
|
122705
|
122706
|
122775
|
122781