Bug 16450 - Remove the use of "onclick" from guarantor search template
authorOwen Leonard <oleonard@myacpl.org>
Wed, 4 May 2016 13:34:46 +0000 (09:34 -0400)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Tue, 31 May 2016 11:53:32 +0000 (11:53 +0000)
This patch updates the guarantor search template so that event
definition is done in the script rather than in an onclick attribute.

This patch also increases the size of the popup window to help prevent
the need for horizontal scrolling and adds Bootstrap style to the
"select" button.

To test, apply the patch and clear your browser cache if necessary.

- Go to Patrons and add a patron with a "child" category type.
- In the "Guarantor information" section, click the "Set to patron"
  button.
- In the pop-up window, search for a patron.
- Click the "Select" button next to a patron.
- The window should close, and the patron you selected should now appear
  as the guarantor. The guarantor's address information should be added
  to the "Main address" section.

Tested on top of Bug 13041 and Bug 16386, works as expected, however see
Bug 16458
Signed-off-by: Marc VĂ©ron <veron@veron.ch>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt
koha-tmpl/intranet-tmpl/prog/js/members.js

index 99bb52f..1dd4151 100644 (file)
@@ -107,6 +107,14 @@ $(document).ready(function(){
         var surname = $(this).data("surname");
         add_user( borrowernumber, firstname + " " + surname );
     });
+
+    $("body").on("click",".select_user",function(e){
+        e.preventDefault();
+        var borrowernumber = $(this).data("borrowernumber");
+        var guarantor_data = $("#guarantor_data"+borrowernumber).val();
+        select_user( borrowernumber, JSON.parse(guarantor_data) );
+    });
+
 });
 
 function filter() {
index 33cb95f..fee361b 100644 (file)
@@ -17,7 +17,7 @@
                 "dt_address":
                     "[% INCLUDE escape_address data=data %]",
                 "dt_action":
-                    "<a style='cursor:pointer' onclick='select_user(\"[% data.borrowernumber %]\", [% To.json(data) | html %] );'>Select</a>"
+                    "<a href=\"#\" class=\"btn btn-mini select_user\" data-borrowernumber=\"[% data.borrowernumber %]\">Select</a><input type=\"hidden\" id=\"guarantor_data[% data.borrowernumber %]\" name=\"guarantor_data\" value=\"[% To.json(data) | html %]\" />"
             }[% UNLESS loop.last %],[% END %]
         [% END %]
     ]
index a6b6b59..969f39f 100644 (file)
@@ -143,7 +143,7 @@ function Dopop(link) {
 }
 
 function Dopopguarantor(link) {
-    var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top');
+    var newin=window.open(link,'popup','width=800,height=500,resizable=no,toolbar=false,scrollbars=yes,top');
 }
 
 function clear_entry(node) {