From 38507b041ba3a448315d91294f032267679810bd Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 29 Sep 2020 11:12:31 +0000 Subject: [PATCH] Bug 26572: Add autocomplete to librarian field in log viewer This patch adds patron autocomplete to the librarian field in the log viewer search form. Also changed: Some HTML markup errors in the template have been corrected: Labels with invalid corresponding ids or with no valid id. To test, apply the patch and go to Tools -> Log Viewer. Type a name or cardnumber into the "Librarian" form field. This should trigger an autocomplete dropdown. Select a patron and confirm that the field is populated with the correct borrowernumber. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../prog/en/modules/tools/viewlog.tt | 10 ++++----- koha-tmpl/intranet-tmpl/prog/js/viewlog.js | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt index 22a17720c8..74f490aea9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -160,7 +160,7 @@ [% UNLESS src == "circ" %]
  • - +
    [% IF modules.size == 0 %] @@ -181,7 +181,7 @@ [% END %]
  • - +
    [% IF actions.length == 0 %] @@ -191,9 +191,9 @@ [% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'RENEW' 'CREATE' 'CANCEL' 'SUSPEND' 'RESUME' 'ADDCIRCMESSAGE' 'DELCIRCMESSAGE' 'STATUS_CHANGE' 'CHANGE PASS' 'Run' ] %] [% IF actions.grep(actx).size %] - + [% ELSE %] - + [% END %] [% END %]
    @@ -212,7 +212,7 @@
  • - + [% IF interfaces.size == 0 %] [% ELSE %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/viewlog.js b/koha-tmpl/intranet-tmpl/prog/js/viewlog.js index 58c126de59..ff835f5787 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/viewlog.js +++ b/koha-tmpl/intranet-tmpl/prog/js/viewlog.js @@ -144,4 +144,26 @@ $(document).ready(function(){ e.preventDefault(); $(".compare:checked").prop("checked", false).change(); }); + var obj = $("#user").autocomplete({ + source: "/cgi-bin/koha/circ/ysearch.pl", + minLength: 3, + select: function ( event, ui ) { + $("#user").val( ui.item.borrowernumber ); + return false; + } + }).data("ui-autocomplete"); + if (obj) { + obj._renderItem = function (ul, item) { + var cardnumber = ""; + if (item.cardnumber != "") { + // Display card number in parentheses if it exists + cardnumber = " (" + item.cardnumber + ") "; + } + return $("
  • ") + .data("ui-autocomplete-item", item) + .append("" + item.surname + ", " + item.firstname + cardnumber + " " + item.dateofbirth + " " + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "") + .appendTo(ul); + }; + } + }); -- 2.39.5