From 23e8ea407b912072cc6280ff9f7b5d9384a01d92 Mon Sep 17 00:00:00 2001 From: Owen Leonard <oleonard@myacpl.org> Date: Wed, 6 Mar 2019 17:12:17 +0000 Subject: [PATCH] Bug 12533: Improve authority search result display This patch implements a few changes in the way authority records are displayed in search results. - In most cases heading type is now displayed as a separate column in the table of search results. - The heading itself is now linked rather than a separate "details" link. In the authority search results for MARC editor plugins the heading link triggers a modal with the authority details instead of linking to a separate page. To test, apply the patch and go to Authorities. - Perform an authority search which will return results. - In the search results headings should be linked to the corresponding detail page. - There should be a separate column for heading type. - Go to Cataloging and create a new record using a framework which has a field linked to an authority type (e.g. 100a -> PERSO_NAME ). - Perform a search which will return results. - In the search results, clicking a heading link should trigger a modal window with the authority details. - Test multiple entries in the results and confirm that each time the correct data is loaded into the modal window. - Test the same process for a field which is linked to the unimarc_field_210c.pl plugin. - Go to Tools -> Batch record modification and submit multiple authority record numbers. - In the results list the heading should be linked correctly to the corresponding detail page. Heading type is not present in this view. - Perform the same test with batch record deletion. --- .../en/includes/authorities-search-results.inc | 7 +++- .../modules/authorities/searchresultlist-auth.tt | 44 ++++++++++++++++++++-- .../en/modules/authorities/searchresultlist.tt | 7 ++-- .../value_builder/unimarc_field_210c.tt | 41 +++++++++++++++++++- .../prog/en/modules/tools/batch_delete_records.tt | 2 +- .../en/modules/tools/batch_record_modification.tt | 2 +- 6 files changed, 91 insertions(+), 12 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc index 3832d3c..fe6cbc8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc @@ -53,8 +53,8 @@ [% END %] [% END %] [% END %] + [% BLOCK authresult %] - [% IF ( summary.label ) %][% summary.label | html %]:[% END %] [% IF summary.summary %] <div class="authority-summary"> [% summary.summary | html %] @@ -63,7 +63,9 @@ [% UNLESS ( summary.summaryonly ) %] <div class="authorizedheading"> [% FOREACH authorize IN summary.authorized %] - <span class="authorizedheading">[% authorize.heading | html %]</span> + <span class="authorizedheading"> + <a data-authid="[% authid | html %]" href="/cgi-bin/koha/authorities/detail.pl?authid=[% authid | uri %]">[% authorize.heading | html %]</a> + </span> [% UNLESS loop.last %] | [% END %] [% END %] </div> @@ -126,6 +128,7 @@ [% END %] [% END %] [% END %] + [% BLOCK language %] [% SWITCH lang %] [% CASE ['en', 'eng'] %]English diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt index b50ebbc..39b676e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt @@ -42,13 +42,15 @@ <table> <tr> <th>Summary</th> + <th>Heading type</th> <th>Used</th> <th>Get it!</th> <th>Other action</th> </tr> [% FOREACH resul IN result %] <tr> - <td>[% PROCESS authresult summary=resul.summary %]</td> + <td>[% PROCESS authresult summary=resul.summary authid=resul.authid %]</td> + <td>[% resul.summary.label | html %]</td> <td>[% resul.used | html %] times</td> <td> [% IF resul.summary && resul.summary.authorized && resul.summary.authorized.size > 1 %] @@ -86,14 +88,50 @@ </div>[% END %] </div> +<!-- Authority details modal --> +<div class="modal" id="authorityDetail" tabindex="-1" role="dialog" aria-labelledby="authorityDetailLabel"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title" id="authorityDetailLabel"></h4> + </div> + <div class="modal-body"> + <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> + </div> + </div> + </div> +</div> + [% MACRO jsinclude BLOCK %] - <script type="text/javascript"> + <script> var index = "[% index | html %]"; var authtypecode = "[% authtypecode | html %]"; </script> [% Asset.js("js/auth-finder-search.js") | $raw %] - <script type="text/javascript"> + <script> + $(document).ready(function(){ + $(".authorizedheading a").on("click", function(e){ + e.preventDefault(); + var authid = $(this).data("authid"); + + $.get("/cgi-bin/koha/authorities/detail.pl", { authid : authid }, function( data ){ + var auth_detail = $(data).find("#authoritiestabs"); + auth_detail.find("ul").remove(); + $("#authorityDetail .modal-title").html(_("Authority") + " " + authid ); + $("#authorityDetail .modal-body").html( auth_detail ); + }); + $("#authorityDetail").modal("show"); + }); + $("#authorityDetail").on("hidden.bs.modal", function(){ + $("#authorityDetail .modal-body, #authorityDetail .modal-title").html(""); + $("#authorityDetail .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /></div>"); + }); + }); function jumpfull(page){ window.open(page,'','width=100,height=100,resizable=yes,toolbar=false,scrollbars=yes,top'); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt index 9da4f27..808c33c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt @@ -30,7 +30,8 @@ <div id="authorities_searchresultlist_results"> <table> <tr> - <th colspan="2">Summary</th> + <th>Summary</th> + <th>Heading type</th> [% UNLESS ( isEDITORS ) %] <th>Used in</th> [% END %] @@ -40,8 +41,8 @@ </tr> [% FOREACH resul IN result %] <tr data-authid="[% resul.authid | html %]"> - <td>[% PROCESS authresult summary=resul.summary %]</td> - <td><a href="detail.pl?authid=[% resul.authid | uri %]">Details</a></td> + <td>[% PROCESS authresult summary=resul.summary authid=resul.authid %]</td> + <td>[% resul.summary.label | html %]</td> [% UNLESS ( resul.isEDITORS ) %] <td> [% IF resul.used > 0 %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt index 0ce0861..7fb4807 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c.tt @@ -58,12 +58,14 @@ <table> <tr> <th>Summary</th> + <th>Heading type</th> <th>Used</th> <th>Get it!</th> </tr> [% FOREACH resul IN result %] <tr> - <td>[% PROCESS authresult summary=resul.summary %]</td> + <td>[% PROCESS authresult summary=resul.summary authid=resul.authid %]</td> + <td>[% resul.summary.label | html %]</td> <td>[% resul.used | html %] times</td> <td> [% IF ( resul.to_report ) %] @@ -82,13 +84,48 @@ </div> [% END %] +<!-- Authority details modal --> +<div class="modal" id="authorityDetail" tabindex="-1" role="dialog" aria-labelledby="authorityDetailLabel"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title" id="authorityDetailLabel"></h4> + </div> + <div class="modal-body"> + <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> + </div> + </div> + </div> +</div> + [% MACRO jsinclude BLOCK %] - <script type="text/javascript"> + <script> $(document).ready(function(){ $(".choosebt").on("click",function(){ var toreport = $(this).siblings(".toreport").text(); report(toreport); }); + $(".authorizedheading a").on("click", function(e){ + e.preventDefault(); + var authid = $(this).data("authid"); + + $.get("/cgi-bin/koha/authorities/detail.pl", { authid : authid }, function( data ){ + var auth_detail = $(data).find("#authoritiestabs"); + auth_detail.find("ul").remove(); + $("#authorityDetail .modal-title").html(_("Authority") + " " + authid ); + $("#authorityDetail .modal-body").html( auth_detail ); + }); + + $("#authorityDetail").modal("show"); + }); + $("#authorityDetail").on("hidden.bs.modal", function(){ + $("#authorityDetail .modal-body, #authorityDetail .modal-title").html(""); + $("#authorityDetail .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /></div>"); + }); }); function report(summary){ var doc = opener.document; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt index 5004055..c50a6f4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt @@ -182,7 +182,7 @@ <tr> <td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td> <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td> - <td>[% PROCESS authresult summary=authority.summary %]</td> + <td>[% PROCESS authresult summary=authority.summary authid=authority.authid %]</td> <td><a href="/cgi-bin/koha/catalogue/search.pl?type=intranet&op=do_search&idx=an,phr&q=[% authority.authid | uri %]">[% authority.count_usage | html %] record(s)</a></td> </tr> [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt index bd58fd2..6faab17 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt @@ -221,7 +221,7 @@ <tr> <td><input type="checkbox" name="record_id" value="[% authority.authid | html %]" data-usage="[% authority.count_usage | html %]" /></td> <td><a href="/cgi-bin/koha/authorities/detail.pl?authid=[% authority.authid | uri %]">[% authority.authid | html %]</a></td> - <td>[% PROCESS authresult summary=authority.summary %]</td> + <td>[% PROCESS authresult summary=authority.summary authid=authority.authid %]</td> <td class="actions"><a href="/cgi-bin/koha/svc/records/preview?record_type=authority&record_id=[% authority.authid | uri %]&mmtid=[% mmtid | uri %]" data-record_type="authority" data-record_id="[% authority.authid | html %]" data-mmtid="[% mmtid | html %]" class="previewMARC btn btn-default btn-xs"><i class='fa fa-eye'></i> Show MARC</a> </tr> [% END %] -- 2.1.4