From 0341e9d55bed86d184601cc0b94b89adb142d7c3 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 --- .../intranet-tmpl/prog/en/modules/tools/viewlog.tt | 10 +++++----- koha-tmpl/intranet-tmpl/prog/js/viewlog.js | 23 ++++++++++++++++++++++ 2 files changed, 28 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 85090b3ccb..549080d241 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -120,7 +120,7 @@ fieldset.rows label.viewlog { [% UNLESS src == "circ" %]
  • - +
    [% IF modules.size == 0 %] @@ -141,7 +141,7 @@ fieldset.rows label.viewlog { [% END %]
  • - +
    [% IF actions.length == 0 %] @@ -151,9 +151,9 @@ fieldset.rows label.viewlog { [% 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 %]
    @@ -172,7 +172,7 @@ fieldset.rows label.viewlog {
  • - + [% 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 1354c95e0a..2ec72ab13a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/viewlog.js +++ b/koha-tmpl/intranet-tmpl/prog/js/viewlog.js @@ -67,4 +67,27 @@ $(document).ready(function(){ "order": [[0, "desc"]], "pagingType" : "full" }, columns_settings); + + 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.11.0