Bugzilla – Attachment 111472 Details for
Bug 23302
Less clicks on Z3950 search results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23302: Less clicks on Z3950 search results
Bug-23302-Less-clicks-on-Z3950-search-results.patch (text/plain), 18.95 KB, created by
Marcel de Rooy
on 2020-10-12 07:45:43 UTC
(
hide
)
Description:
Bug 23302: Less clicks on Z3950 search results
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2020-10-12 07:45:43 UTC
Size:
18.95 KB
patch
obsolete
>From 3ce9764f6ceb65e64f34fa55198f50611da2a983 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 12 Aug 2020 14:47:47 +0000 >Subject: [PATCH] Bug 23302: Less clicks on Z3950 search results >Content-Type: text/plain; charset=utf-8 > >Functional change: Instead of requiring two clicks for each option in >the Actions menu, we add a default action based on previous activity. > >NOTE: In order to prioritize MARC and Card preview actions, we will only >remember Import and Order when it is not preceded by a preview. In other >words: If you directly click Import, Import comes back. If you click Card >and Import, Card comes back. > >Technical changes: >[1] Combine Preview and Order button on Acquisition Z3950 search. >[2] Use Actions link as default action and add button with caret to open the dropdown. >[3] Keep last action in localStorage (sessionStorage makes not much sense for the popups), prioritizing previews. >[4] Where needed, add title attributes to dropdown links. Use class 'chosen' to differentiate preview popups from import/order actions. >[5] Replace previewMARC by previewData in Authority Z3950 search. Remove duplicate code. >[6] Use link href from template instead of constructing link in javascript. >[7] Removing unused linktools markup from acqui template. > >Test plan: >[1] Start on acqui Z3950. Choose Card once from the menu and then Order. >[2] Start auth Z3950. Verify that Default is MARC now. Close popup. > (Since Card is no option here.) >[3] Start cataloguing Z3950. Verify that you have Card as default. > Click Import rightaway. >[4] Back to auth Z3950. Verify that Import is default. Click Import. >[5] Back to acqui Z3950. Verify that MARC is default (no Import here). > Click Order. Go back and verify that Order is now default. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > .../prog/en/modules/acqui/z3950_search.tt | 16 ++--- > .../en/modules/cataloguing/z3950_auth_search.tt | 14 ++-- > .../prog/en/modules/cataloguing/z3950_search.tt | 7 +- > koha-tmpl/intranet-tmpl/prog/js/z3950_search.js | 77 +++++++++++----------- > 4 files changed, 56 insertions(+), 58 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt >index e8dc607e1a..fe2e0b3d93 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt >@@ -8,9 +8,6 @@ > [% USE Koha %] > > <style> >-.linktools { background-color:#FFF;border-top:1px solid #DDD; border-left: 1px solid #DDD; border-right: 1px solid #666; border-bottom:1px solid #666;display: none; white-space: nowrap;} >-.linktools a { font-size : 85%; text-decoration:none; padding:.3em;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;} >-.linktools a:hover { background-color:#EEE;color:#CC3300;border-right:1px solid #CCC;} > tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : transparent !important; } #dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } } > </style> > </head> >@@ -113,14 +110,13 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : > [% IF ( Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' ) %] > <th>Additional fields</th> > [% END %] >- <th>Preview</th> >- <th> </th> >+ <th>Actions</th> > </tr></thead> > <tbody>[% FOREACH breeding_loo IN breeding_loop %] > [% IF ( breeding_loo.breedingid ) %] > > <tr> >- <td>[% breeding_loo.server | html %] <div class="linktools"><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid | uri %]" class="previewData">Preview MARC</a> <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&importid=[% breeding_loo.breedingid | html %]" class="previewData">Preview card</a> <a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&breedingid=[% breeding_loo.breedingid | html %]&booksellerid=[% booksellerid | uri %]&basketno=[% basketno | uri %]">[% tp('verb', 'Order') | html %]</a> <a href="#" id="closemenu" title="Close this menu"> X </a></div></td> >+ <td>[% breeding_loo.server | html %]</td> > <td>[% breeding_loo.title | html %]</td> > <td>[% breeding_loo.author | html %]</td> > <td>[% breeding_loo.date | html %]</td> >@@ -141,16 +137,14 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : > [% END %] > <td class="actions"> > <div class="btn-group dropup"> >- <a class="btn btn-default btn-xs dropdown-toggle" id="z3950preview[% breeding_loo.breedingid | uri %]" role="button" data-toggle="dropdown" href="#"> >- Preview <b class="caret"></b> >- </a> >+ <a class="btn btn-default btn-xs z3950actions" href="#">MARC</a><button data-toggle="dropdown" class="btn-xs dropdown-toggle"><span class="caret"></span></button> > <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="z3950preview[% breeding_loo.breedingid | html %]"> > <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid | uri %]" title="MARC" class="previewData"><i class="fa fa-eye"></i> MARC</a></li> > <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&importid=[% breeding_loo.breedingid | uri %]" title="Card" class="previewData"><i class="fa fa-eye"></i> Card</a></li> >+ <li><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&breedingid=[% breeding_loo.breedingid | uri %]&booksellerid=[% booksellerid | uri %]&basketno=[% basketno | uri %]" class="chosen" title="Order"><i class="fa fa-plus"></i> [% tp('verb', 'Order') | html %]</a></li> > </ul> > </div> > </td> >- <td class="actions"><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&breedingid=[% breeding_loo.breedingid | uri %]&booksellerid=[% booksellerid | uri %]&basketno=[% basketno | uri %]" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> [% tp('verb', 'Order') | html %]</a></td> > </tr> > [% END %] > [% END %]</tbody> >@@ -232,6 +226,7 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'z3950_search.inc' %] > [% Asset.js("js/z3950_search.js") | $raw %] >+ [% INCLUDE 'z3950_search.inc' %] > <script> > $(document).ready(function(){ > var resultst = $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, { >@@ -242,6 +237,7 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : > "aaSorting": [[ 1, "asc" ]], > "bPaginate": false > })); >+ InitLastAction(); > }); > </script> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt >index 51aa454619..9ac17a0ea3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt >@@ -89,12 +89,10 @@ > <td>[% breeding_loo.heading_code | html %]</td> > <td class="actions"> > <div class="btn-group dropup"> >- <a class="btn btn-default btn-xs dropdown-toggle" id="cataloguesearchactions[% breeding_loo.breedingid | html %]" role="button" data-toggle="dropdown" href="#"> >- Actions <b class="caret"></b> >- </a> >+ <a class="btn btn-default btn-xs z3950actions" href="#">MARC</a><button class="btn-xs dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button> > <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="cataloguesearchactions[% breeding_loo.breedingid | html %]"> >- <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid | uri %]" class="previewMARC"><i class="fa fa-eye"></i> MARC preview</a></li> >- <li><a href="#" class="import_record" data-breedingid="[% breeding_loo.breedingid | html %]" data-heading_code="[% breeding_loo.heading_code | html %]" data-authid="[% breeding_loo.authid | html %]"><i class="fa fa-download"></i> Import</a></li> >+ <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid | uri %]" title="MARC" class="previewData"><i class="fa fa-eye"></i> MARC preview</a></li> >+ <li><a href="/cgi-bin/koha/authorities/authorities.pl?breedingid=[% breeding_loo.breedingid | html %]&authtypecode=[% breeding_loo.heading_code | html %]" class="chosen" title="Import"><i class="fa fa-download"></i> Import</a></li> > </ul> > </div> > </td> >@@ -103,12 +101,12 @@ > [% END %]</tbody> > </table> > >- <div id="marcPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true"> >+ <div id="dataPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true"> > <div class="modal-dialog"> > <div class="modal-content"> > <div class="modal-header"> > <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >- <h3 id="marcPreviewLabel">MARC preview</h3> >+ <h3 id="dataPreviewLabel">MARC preview</h3> > </div> > <div class="modal-body"> > <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div> >@@ -171,6 +169,7 @@ > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'z3950_search.inc' %] > [% Asset.js("js/z3950_search.js") | $raw %] >+ [% INCLUDE 'z3950_search.inc' %] > <script> > $(document).ready(function(){ > $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, { >@@ -181,6 +180,7 @@ > "aaSorting": [[ 1, "asc" ]], > "bPaginate": false > })); >+ InitLastAction(); > }); > </script> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt >index 8649164d41..c55a94301b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt >@@ -156,13 +156,11 @@ > [% END %] > <td class="actions"> > <div class="btn-group dropup"> >- <a class="btn btn-default btn-xs dropdown-toggle" id="cataloguesearchactions[% breeding_loo.breedingid | html %]" role="button" data-toggle="dropdown" href="#"> >- Actions <b class="caret"></b> >- </a> >+ <a class="btn btn-default btn-xs z3950actions" href="#">MARC</a><button class="btn-xs dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button> > <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="cataloguesearchactions[% breeding_loo.breedingid | html %]"> > <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid | uri %]" title="MARC" class="previewData"><i class="fa fa-eye"></i> MARC preview</a></li> > <li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&importid=[% breeding_loo.breedingid | uri %]" title="Card" class="previewData"><i class="fa fa-eye"></i> Card preview</a></li> >- <li><a href="#" class="import_record" data-breedingid="[% breeding_loo.breedingid | html %]" data-biblionumber="[% breeding_loo.biblionumber | html %]" data-frameworkcode="[% frameworkcode | uri %]"><i class="fa fa-download"></i> Import</a></li> >+ <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% breeding_loo.biblionumber | html %]&z3950=1&frameworkcode=[% frameworkcode | uri %]&breedingid=[% breeding_loo.breedingid | html %]" class="chosen" title="Import"><i class="fa fa-download"></i> Import</a></li> > </ul> > </div> > </td> >@@ -250,6 +248,7 @@ > "aaSorting": [[ 1, "asc" ]], > "bPaginate": false > }, columns_settings ); >+ InitLastAction(); > }); > > function columnsInit(){ >diff --git a/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js b/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js >index 39a7af0c0d..10b4149fa0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js >@@ -1,16 +1,7 @@ > /* global __ total_pages */ > //z3950_search.js for Authorities, Bib records and Acquisitions module >-function Import(Breeding, recordid, AuthType, FrameworkCode) { > >- if ( AuthType == false ) { >- opener.document.location="../cataloguing/addbiblio.pl?biblionumber="+recordid+"&z3950=1&frameworkcode="+FrameworkCode+"&breedingid="+Breeding; >- } else { >- opener.document.location="../authorities/authorities.pl?breedingid="+Breeding+"&authtypecode="+AuthType+"&authid="+recordid; >- } >- window.close(); >- return false; >- >-} >+var last_action, previewed = 0; > > function validate_goto_page() { > var page = $('#goto_page').val(); >@@ -70,16 +61,19 @@ $( document ).ready( function() { > /* Note: The templates where this is included must have a search results > table with the id "resultst" and "action" table cells with the class "actions" */ > $("#resultst").on("click", "td", function(event){ >+ event.preventDefault(); > var tgt = $(event.target); >- var row = $(this).parent(); >+ var row = $(this).closest('tr'); > /* Remove highlight from all rows and add to the clicked row */ > $("tr").removeClass("highlighted-row"); > row.addClass("highlighted-row"); > /* Remove any menus created on the fly for other rows */ > $(".btn-wrapper").remove(); > >- if( tgt.is("a") || tgt.hasClass("actions") ){ >- /* Don't show inline links for cells containing links of their own. */ >+ if( tgt.hasClass("z3950actions") ) { // direct button click >+ var link = $( "a[title='" + tgt.text() + "']", row ); >+ if( link.length == 1) link.click(); >+ row.find('ul.dropdown-menu').hide(); > } else { > event.stopPropagation(); > /* Remove the "open" class from all dropup menus in case one is open */ >@@ -100,6 +94,10 @@ $( document ).ready( function() { > The menu must first be wrapped in a block-level div to clear > the table cell's text contents and then a relative-positioned > div to allow the menu to be positioned correctly */ >+ if( tgt.prop('nodeName') != 'TD' ) { >+ // handling click on caret to improve menu position >+ tgt = tgt.closest('td'); >+ } > tgt.append( > $('<div/>', {'class': 'btn-wrapper'}).append( > $('<div/>', {'class': 'btn-group'}).append( >@@ -110,43 +108,48 @@ $( document ).ready( function() { > } > }); > >- $( "#resultst" ).on("click", ".previewMARC", function(e) { >- e.preventDefault(); >- var ltitle = $( this ).text(); >- var page = $( this ).attr( "href" ); >- $( "#marcPreviewLabel" ).text( ltitle ); >- $( "#marcPreview .modal-body" ).load( page + " pre" ); >- $( '#marcPreview' ).modal( {show:true} ); >- }); >- $( "#marcPreview" ).on( "hidden", function() { >- $( "#marcPreviewLabel" ).html( "" ); >- $( "#marcPreview .modal-body" ).html( "<div id='loading'><img src='" + interface + "/" + theme + "/img/spinner-small.gif' alt='' /> " + __("Loading") + "</div>" ); >- }); > $( "#resultst" ).on("click", ".previewData", function(e) { > e.preventDefault(); >+ previewed = 1; >+ ChangeLastAction( $(this).attr('title'), 1 ); > var ltitle = $( this ).text(); > var page = $( this ).attr( "href" ); > $( "#dataPreviewLabel" ).text( ltitle ); > $( "#dataPreview .modal-body" ).load( page + " div" ); > $( '#dataPreview' ).modal( {show:true} ); > }); >+ > $( "#dataPreview" ).on( "hidden", function() { > $( "#dataPreviewLabel" ).html( "" ); > $( "#dataPreview .modal-body" ).html( "<div id='loading'><img src='" + interface + "/" + theme + "/img/spinner-small.gif' alt='' /> " + __("Loading") + "</div>" ); > }); >- $( "#resultst" ).on("click", ".import_record", function(e) { >+ >+ $( "#resultst" ).on("click", ".chosen", function(e) { > e.preventDefault(); >- var data_breedingid = $( this ).data( "breedingid" ); >- var data_headingcode = $( this ).data( "heading_code" ); >- var data_authid = $( this ).data( "authid" ); >- var data_biblionumber = $( this ).data( "biblionumber" ); >- var data_frameworkcode = $( this ).data( "frameworkcode" ); >- if ( data_headingcode == undefined ) { >- Import( data_breedingid, data_biblionumber, false , data_frameworkcode ); >- } else { >- Import( data_breedingid, data_authid, data_headingcode ); >+ var title = $(this).attr('title'); >+ ChangeLastAction( title, 0 ); >+ if( title == 'Order' ) window.location = $(this).attr('href'); >+ else { >+ opener.document.location = $(this).attr('href'); >+ window.close(); > } >- return false; > }); >- > }); >+ >+function InitLastAction() { >+ if( $("#resultst").length == 0 ) return; >+ try { last_action = localStorage.getItem('z3950search_last_action'); } catch (err) {} >+ if( last_action ) { >+ var linkcount = $(".z3950actions:eq(0)").siblings(".dropdown-menu").find("a[title='"+last_action+"']").length; >+ if( linkcount == 0 ) return; >+ if( last_action != 'MARC' ) $( ".z3950actions" ).text( last_action ); >+ } >+} >+ >+function ChangeLastAction(title, change_text) { >+ if( last_action && last_action == title ) return; >+ last_action = title; >+ if( change_text ) $( ".z3950actions" ).text( last_action ); >+ if( previewed == 0 || change_text == 1 ) >+ try { localStorage.setItem('z3950search_last_action', last_action); } catch(err) {} >+} >-- >2.11.0
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 23302
:
91468
|
91470
|
108285
|
111472
|
113910
|
115030
|
115031
|
115661
|
115663