Bug 13121: Move search results "action" links ("Place hold," "Add tag," etc) into include file

This patch moves markup for controls repeated across several OPAC
templates into a single include: Place hold, Request article, Add tag,
Save to lists, and Add to cart.

To test, apply the patch and view the following OPAC pages:

 - Search results
 - Shelf contents view
 - User tags list

On each of these pages all the controls should work correctly:

 - Place hold
 - Request art
 - Add tag
 - Save to lists
 - Add to cart

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Owen Leonard 2020-01-07 13:03:18 +00:00 committed by Martin Renvoize
parent f1f1c2e9b1
commit 07d2a419f3
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
6 changed files with 98 additions and 92 deletions

View File

@ -0,0 +1,61 @@
<div class="actions-menu noprint">
[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
[% UNLESS ( items.norequests ) %]
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
[% IF ( shelf AND op == 'view' ) # Lists view has more granular checking of hold availability %]
[% IF ( items.allow_onshelf_holds ) %]
<span class="actions"><a class="btn btn-link hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% items.biblionumber | html %]"><i class="fa fa-fw fa-bookmark"></i> Place hold</a></span>
[% ELSE %]
[% IF ( items.itemsissued ) %]
<span class="actions"><a class="btn btn-link hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% items.biblionumber | html %]"><i class="fa fa-fw fa-bookmark"></i> Place hold</a></span>
[% END %]
[% END %]
[% ELSE %]
<span class="actions"><a class="btn btn-link hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% items.biblionumber | html %]"><i class="fa fa-fw fa-bookmark"></i> Place hold</a></span>
[% END %]
[% END # / IF opacuserlogin %]
[% END # / UNLESS items.norequests %]
[% END # / RequestOnOpac %]
[% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %]
[% IF items.artreqpossible %]
<span class="actions"><a href="/cgi-bin/koha/opac-request-article.pl?biblionumber=[% items.biblionumber | uri %]" class="btn btn-link"><i class="fa fa-file-text"></i> Request article</a></span>
[% END %]
[% END %]
[% IF ( TagsInputEnabled ) %]
[% IF ( loggedinusername ) %]
<span class="actions"><a id="tag_add[% items.biblionumber | html %]" href="#" class="tag_add btn btn-link"><i class="fa fa-tag"></i> Add tag</a></span>
<div id="tagform[% items.biblionumber | html %]" class="tag_results_input" style="display:none;">
<label for="newtag[% items.biblionumber | html %]">New tag(s), separated by a comma:</label>
<input type="text" name="newtag[% items.biblionumber | html %]" id="newtag[% items.biblionumber | html %]" class="newtag" maxlength="100" />
<input name="tagbutton" class="btn btn-small tagbutton" title="[% items.biblionumber | html %]" type="submit" value="Add" />
<a class="cancel_tag_add" id="cancel[% items.biblionumber | html %]" href="#">(done)</a>
</div>
<span id="newtag[% items.biblionumber | html %]_status" class="tagstatus" style="display:none;">
Tag status here.
</span>
[% ELSE %]
<span class="actions"><span id="login4tags"><a class="btn btn-link loginModal-trigger" href="/cgi-bin/koha/opac-user.pl"><i class="fa fa-tag"></i> Log in to add tags</a></span></span>
[% END # IF loggedinusername %]
[% END # if TagsInputEnabled %]
[% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && loggedinusername && ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]
[% IF ( shelf AND op == 'view' ) %]
<span class="actions"><a href="/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber=[% items.biblionumber | uri %]" onclick="Dopop('opac-addbybiblionumber.pl?biblionumber=[% items.biblionumber | uri %]'); return false;" class="btn btn-link"><i class="fa fa-list"></i> Save to another list</a></span>
[% IF can_remove_biblios %]
<span class="actions"><a class="btn btn-link removefromlist" href="/cgi-bin/koha/opac-shelves.pl?op=remove_biblios&amp;shelfnumber=[% shelf.shelfnumber | html %]&amp;biblionumber=[% items.biblionumber | html %]"><i class="fa fa-remove"></i> Remove from this list</a></span>
[% END %]
[% ELSE %]
<span class="actions"><a class="addtoshelf btn btn-link" href="/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber=[% items.biblionumber | html %]" onclick="Dopop('opac-addbybiblionumber.pl?biblionumber=[% items.biblionumber | html %]'); return false;"><i class="fa fa-list"></i> Save to lists</a></span>
[% END # /IF ( shelf AND op == 'view' ) %]
[% END # /IF Koha.Preference( 'opacuserlogin' ) %]
[% IF Koha.Preference( 'opacbookbag' ) == 1 %]
[% IF ( items.incart ) %]
<span class="actions"><a data-biblionumber="[% items.biblionumber | html %]" class="btn btn-link cart cart[% items.biblionumber | html %]" href="#"><i class="fa fa-shopping-cart"></i> In your cart</a> <a data-biblionumber="[% items.biblionumber | html %]" class="btn btn-link remove cartRemove cartR[% items.biblionumber | html %]" href="#">(remove)</a></span>
[% ELSE %]
<span class="actions"><a data-biblionumber="[% items.biblionumber | html %]" class="btn btn-link addtocart cart cart[% items.biblionumber | html %]" href="#"><i class="fa fa-shopping-cart"></i> Add to cart</a> <a style="display:none;" data-biblionumber="[% items.biblionumber | html %]" class="btn btn-link remove cartRemove cartR[% items.biblionumber | html %]" href="#">(remove)</a></span>
[% END %]
[% END # / IF opacbookbag %]
</div>

View File

@ -536,50 +536,8 @@
</div> <!-- / .results_summary -->
[% END # / IF OpacStarRatings %]
<div class="actions-menu noprint">
[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
[% UNLESS ( SEARCH_RESULT.norequests ) %]
[% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %]
<span class="actions"><a href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]" class="btn btn-link"><i class="fa fa-bookmark"></i> Place hold</a></span><!-- add back when available 0 holds in queue-->
[% END # / IF opacuserlogin && holdable %]
[% END # UNLESS SEARCH_RESULT.norequests %]
[% END # IF RequestOnOpac %]
[% INCLUDE 'title-actions-menu.inc' items=SEARCH_RESULT %]
[% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %]
[% IF SEARCH_RESULT.artreqpossible %]
<span class="actions"><a href="/cgi-bin/koha/opac-request-article.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]" class="btn btn-link"><i class="fa fa-file-text"></i> Request article</a></span>
[% END %]
[% END %]
[% IF ( TagsInputEnabled ) %]
[% IF ( loggedinusername ) %]
<span class="actions"><a id="tag_add[% SEARCH_RESULT.biblionumber | html %]" href="#" class="tag_add btn btn-link"><i class="fa fa-tag"></i> Add tag</a></span>
<div id="tagform[% SEARCH_RESULT.biblionumber | html %]" class="tag_results_input" style="display:none;">
<label for="newtag[% SEARCH_RESULT.biblionumber | html %]">New tag(s), separated by a comma:</label>
<input type="text" name="newtag[% SEARCH_RESULT.biblionumber | html %]" id="newtag[% SEARCH_RESULT.biblionumber | html %]" class="newtag" maxlength="100" />
<input name="tagbutton" class="btn btn-small tagbutton" title="[% SEARCH_RESULT.biblionumber | html %]" type="submit" value="Add" />
<a class="cancel_tag_add" id="cancel[% SEARCH_RESULT.biblionumber | html %]" href="#">(done)</a>
</div>
<span id="newtag[% SEARCH_RESULT.biblionumber | html %]_status" class="tagstatus" style="display:none;">
Tag status here.
</span>
[% ELSE %]
<span class="actions"><span id="login4tags"><a class="btn btn-link loginModal-trigger" href="/cgi-bin/koha/opac-user.pl"><i class="fa fa-tag"></i> Log in to add tags</a></span></span>
[% END # IF loggedinusername %]
[% END # if TagsInputEnabled %]
[% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && loggedinusername && ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]
<span class="actions"><a href="/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]" onclick="Dopop('opac-addbybiblionumber.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]'); return false;" class="btn btn-link"><i class="fa fa-list"></i> Save to lists</a></span>
[% END %]
[% IF Koha.Preference( 'opacbookbag' ) == 1 %]
[% IF ( SEARCH_RESULT.incart ) %]
<span class="actions"><a data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="btn btn-link cart cart[% SEARCH_RESULT.biblionumber | html %]" href="#"><i class="fa fa-shopping-cart"></i> In your cart</a> <a data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="btn btn-link remove cartRemove cartR[% SEARCH_RESULT.biblionumber | html %]" href="#">(remove)</a></span>
[% ELSE %]
<span class="actions"><a data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="btn btn-link addtocart cart cart[% SEARCH_RESULT.biblionumber | html %]" href="#"><i class="fa fa-shopping-cart"></i> Add to cart</a> <a style="display:none;" data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="btn btn-link remove cartRemove cartR[% SEARCH_RESULT.biblionumber | html %]" href="#">(remove)</a></span>
[% END %]
[% END # / IF opacbookbag %]
</div>
</div>
[% INCLUDE "openlibrary-readapi.inc" bib = SEARCH_RESULT %]

View File

@ -463,55 +463,7 @@
</div>
[% END %]
<span class="results_summary">
[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
[% UNLESS ( itemsloo.norequests ) %]
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
[% IF ( itemsloo.allow_onshelf_holds ) %]
<span class="actions"><a class="btn btn-link hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% itemsloo.biblionumber | html %]"><i class="fa fa-fw fa-bookmark"></i> Place hold</a><!-- add back when available 0 holds in queue--></span>
[% ELSE %]
[% IF ( itemsloo.itemsissued ) %]
<span class="actions"><a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% itemsloo.biblionumber | html %]"><i class="fa fa-fw fa-bookmark"></i> Place hold</a><!-- add back when available 0 holds in queue--></span>
[% END %]
[% END %]
[% END # / IF opacuserlogin %]
[% END # / UNLESS itemsloo.norequests %]
[% END # / RequestOnOpac %]
[% IF ( TagsInputEnabled ) %]
[% IF ( loggedinusername ) %]
<span class="actions"><a class="btn btn-link tag_add hidden" id="tag_add[% itemsloo.biblionumber | html %]" href="#"><i class="fa fa-fw fa-tag"></i> Add tag</a></span>
<div id="tagform[% itemsloo.biblionumber | html %]" class="tag_results_input" style="display:none;">
<label for="newtag[% itemsloo.biblionumber | html %]">New tag(s), separated by a comma:</label>
<input type="text" name="newtag[% itemsloo.biblionumber | html %]" id="newtag[% itemsloo.biblionumber | html %]" maxlength="100" />
<input name="tagbutton" class="tagbutton btn btn-small" title="[% itemsloo.biblionumber | html %]" type="submit" value="Add" />
<a class="cancel_tag_add" id="cancel[% itemsloo.biblionumber | html %]" href="#">(done)</a>
</div>
<div id="newtag[% itemsloo.biblionumber | html %]_status" class="tagstatus" style="display:none;">
Tag status here.
</div>
[% ELSIF ( loop.first ) %]
<span class="tagstatus" id="login4tags">Log in to add tags.</span>
[% END # / IF loggedinusername %]
[% END # / IF TagsInputEnabled %]
[% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && loggedinusername && ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]
<span class="actions"><a class="btn btn-link addtoshelf" href="/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber=[% itemsloo.biblionumber | uri %]" onclick="Dopop('opac-addbybiblionumber.pl?biblionumber=[% itemsloo.biblionumber | uri %]'); return false;"><i class="fa fa-fw fa-list"></i> Save to another list</a></span>
[% END %]
[% IF can_remove_biblios %]
<span class="actions"><a class="btn btn-link btn-disabled remove removefromlist" href="/cgi-bin/koha/opac-shelves.pl?op=remove_biblios&amp;shelfnumber=[% shelf.shelfnumber | html %]&amp;biblionumber=[% itemsloo.biblionumber | html %]"><i class="fa fa-fw fa-remove"></i> Remove from this list</a></span>
[% END %]
[% IF Koha.Preference( 'opacbookbag' ) == 1 %]
[% IF ( itemsloo.incart ) %]
<span class="actions"><a data-biblionumber="[% itemsloo.biblionumber | html %]" class="btn btn-link addtocart cart[% itemsloo.biblionumber | html %] hidden" href="#"><i class="fa fa-fw fa-shopping-cart"></i> In your cart</a> <a data-biblionumber="[% itemsloo.biblionumber | html %]" class="btn btn-link cartRemove cartR[% itemsloo.biblionumber | html %] hidden" href="#">(remove)</a></span>
[% ELSE %]
<span class="actions"><a data-biblionumber="[% itemsloo.biblionumber | html %]" class="btn btn-link addtocart cart[% itemsloo.biblionumber | html %] hidden" href="#"><i class="fa fa-fw fa-shopping-cart"></i> Add to cart</a> <a style="display:none;" data-biblionumber="[% itemsloo.biblionumber | html %]" class="btn btn-link cartRemove cartR[% itemsloo.biblionumber | html %] hidden" href="#">(remove)</a></span>
[% END %]
[% END # / IF opacbookbag %]
</span> <!-- / .results_summary .actions -->
[% INCLUDE 'title-actions-menu.inc' items=itemsloo %]
<!-- COinS / Openurl -->
<span class="Z3988" title="[% itemsloo.coins | html %]"></span>

View File

@ -155,6 +155,8 @@
by [% MY_TAG.author | html %]
[% END %]
[% END # /IF MY_TAG.XSLTBloc %]
[% INCLUDE 'title-actions-menu.inc' items=MY_TAG %]
</td>
<td>
<span title="[% MY_TAG.date_created | html %]">

View File

@ -267,12 +267,23 @@ if ( $op eq 'view' ) {
my $patron = Koha::Patrons->find( $loggedinuser );
my $categorycode; # needed for may_article_request
if( C4::Context->preference('ArticleRequests') ) {
$categorycode = $patron ? $patron->categorycode : undef;
}
# Lists display falls back to search results configuration
my $xslfile = C4::Context->preference('OPACXSLTListsDisplay');
my $lang = $xslfile ? C4::Languages::getlanguage() : undef;
my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
my $art_req_itypes;
if( C4::Context->preference('ArticleRequests') ) {
$art_req_itypes = Koha::IssuingRules->guess_article_requestable_itemtypes({ $patron ? ( categorycode => $patron->categorycode ) : () });
}
my @items;
while ( my $content = $contents->next ) {
my $biblionumber = $content->biblionumber;
@ -304,6 +315,8 @@ if ( $op eq 'view' ) {
$this_item->{'normalized_ean'} = GetNormalizedEAN( $record, $marcflavour );
$this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber( $record, $marcflavour );
$this_item->{'normalized_isbn'} = GetNormalizedISBN( undef, $record, $marcflavour );
# BZ17530: 'Intelligent' guess if result can be article requested
$this_item->{artreqpossible} = ( $art_req_itypes->{ $this_item->{itemtype} // q{} } || $art_req_itypes->{ '*' } ) ? 1 : q{};
unless ( defined $this_item->{size} ) {

View File

@ -236,6 +236,20 @@ if ($loggedinuser) {
$should_hide = ( $should_hide =~ /\S/ ) ? 1 : 0;
$my_tags = get_tag_rows({borrowernumber=>$loggedinuser});
my $my_approved_tags = get_approval_rows({ approved => 1 });
my $art_req_itypes;
if( C4::Context->preference('ArticleRequests') ) {
$art_req_itypes = Koha::IssuingRules->guess_article_requestable_itemtypes({ $patron ? ( categorycode => $patron->categorycode ) : () });
}
# get biblionumbers stored in the cart
my @cart_list;
if($query->cookie("bib_list")){
my $cart_list = $query->cookie("bib_list");
@cart_list = split(/\//, $cart_list);
}
foreach my $tag (@$my_tags) {
$tag->{visible} = 0;
my $biblio = Koha::Biblios->find( $tag->{biblionumber} );
@ -262,6 +276,8 @@ if ($loggedinuser) {
$tag->{part_number} = $biblio->part_number;
$tag->{part_name} = $biblio->part_name;
$tag->{author} = $biblio->author;
# BZ17530: 'Intelligent' guess if result can be article requested
$tag->{artreqpossible} = ( $art_req_itypes->{ $tag->{itemtype} // q{} } || $art_req_itypes->{ '*' } ) ? 1 : q{};
my $xslfile = C4::Context->preference('OPACXSLTResultsDisplay');
my $lang = $xslfile ? C4::Languages::getlanguage() : undef;
@ -279,6 +295,10 @@ if ($loggedinuser) {
$tag->{time_created_display} = $1;
$tag->{approved} = ( grep { $_->{term} eq $tag->{term} and $_->{approved} } @$my_approved_tags );
$tag->{visible} = 1;
# while we're checking each line, see if item is in the cart
if ( grep {$_ eq $biblio->biblionumber} @cart_list) {
$tag->{incart} = 1;
}
}
}