Bugzilla – Attachment 76579 Details for
Bug 21024
JS error on search result breaks JS functionalities
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21024: (bug 20864 follow-up) Only set bibs_selected cookie when BrowseResultSelection is activated
Bug-21024-bug-20864-follow-up-Only-set-bibsselecte.patch (text/plain), 5.65 KB, created by
Jonathan Druart
on 2018-06-29 18:04:24 UTC
(
hide
)
Description:
Bug 21024: (bug 20864 follow-up) Only set bibs_selected cookie when BrowseResultSelection is activated
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-06-29 18:04:24 UTC
Size:
5.65 KB
patch
obsolete
>From 44ba7c27c8a5ca22fd82589ce5dd6c1c4505a151 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 29 Jun 2018 14:53:38 -0300 >Subject: [PATCH] Bug 21024: (bug 20864 follow-up) Only set bibs_selected > cookie when BrowseResultSelection is activated > >This is an attempt to fix correctly the problem bug 20864 tried to >solve. > >The cookie bibs_selected must only be defined if BrowseResultSelection >is set. >Bug 20864 removed the inclusion of commons.js, but some code from >results.tt > >We should include it and take care of the pref in each function. > >Test plan: >Retest 19290 and 20864 >--- > .../intranet-tmpl/prog/en/includes/js_includes.inc | 13 ++++++-- > .../prog/en/modules/catalogue/results.tt | 17 +++++----- > koha-tmpl/intranet-tmpl/prog/js/commons.js | 37 ++++++++++++++-------- > 3 files changed, 43 insertions(+), 24 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >index 946859a018..d16c905e18 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >@@ -12,6 +12,15 @@ > </script> > [% END %] > >+[%# Define prefs we will need all around %] >+<script> >+ [% IF Koha.Preference('BrowseResultSelection') %] >+ var global_pref_BrowseResultSelection = 1; >+ [% ELSE %] >+ var global_pref_BrowseResultSelection = 0; >+ [% END %] >+</script> >+ > [% Asset.js("lib/jquery/jquery-2.2.3.min.js") %] > [% Asset.js("lib/jquery/jquery-migrate-1.3.0.min.js") %] > [% Asset.js("lib/jquery/jquery-ui-1.11.4.min.js") %] >@@ -22,9 +31,7 @@ > [% Asset.js("lib/jquery/plugins/jquery.validate.min.js") %] > <!-- koha core js --> > [% Asset.js("js/staff-global.js") %] >-[% IF Koha.Preference('BrowseResultSelection') %] >- [% Asset.js("js/commons.js") %] >-[% END %] >+[% Asset.js("js/commons.js") %] > > [% INCLUDE 'validator-strings.inc' %] > [% IF ( IntranetUserJS ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index bb294cd92e..c93aba1f71 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -773,16 +773,17 @@ > delSingleRecord(biblionumber); > }); > >- [% UNLESS Koha.Preference('BrowseResultSelection') %] >+ [% IF Koha.Preference('BrowseResultSelection') %] >+ $(".selection").change(function(){ >+ if ( $(this).is(':checked') == true ) { >+ addBibToContext( $(this).val() ); >+ } else { >+ delBibToContext( $(this).val() ); >+ } >+ }); >+ [% ELSE %] > resetSearchContext(); > [% END %] >- $(".selection").change(function(){ >- if ( $(this).is(':checked') == true ) { >- addBibToContext( $(this).val() ); >- } else { >- delBibToContext( $(this).val() ); >- } >- }); > $("#bookbag_form").ready(function(){ > $("#bookbag_form").unCheckCheckboxes(); > var bibnums = getContextBiblioNumbers(); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/commons.js b/koha-tmpl/intranet-tmpl/prog/js/commons.js >index 4981c07946..8021c8327b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/commons.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/commons.js >@@ -27,6 +27,7 @@ function paramOfUrl( url, param ) { > } > > function addBibToContext( bibnum ) { >+ if ( ! global_pref_BrowseResultSelection ) return; > bibnum = parseInt(bibnum, 10); > var bibnums = getContextBiblioNumbers(); > bibnums.push(bibnum); >@@ -35,12 +36,15 @@ function addBibToContext( bibnum ) { > } > > function delBibToContext( bibnum ) { >+ if ( ! global_pref_BrowseResultSelection ) return; > var bibnums = getContextBiblioNumbers(); > removeByValue( bibnums, bibnum ); > setContextBiblioNumbers( $.uniqueArray( bibnums ) ); > } > > function setContextBiblioNumbers( bibnums ) { >+ if ( ! global_pref_BrowseResultSelection ) return; >+ > $.cookie('bibs_selected', JSON.stringify( bibnums )); > } > >@@ -54,20 +58,27 @@ function getContextBiblioNumbers() { > } > > function resetSearchContext() { >- setContextBiblioNumbers( new Array() ); >+ if ( global_pref_BrowseResultSelection ) { >+ setContextBiblioNumbers( new Array() ); >+ } else { >+ $.cookie('bibs_selected', '', { 'path': '/', 'expires': -1 }); >+ } > } > > $(document).ready(function(){ >- // forms with action leading to search >- $("form[action*='search.pl']").submit(function(){ >- resetSearchContext(); >- }); >- // any link to launch a search except navigation links >- $("[href*='search.pl?']").not(".nav").not('.searchwithcontext').click(function(){ >- resetSearchContext(); >- }); >- // any link to a detail page from the results page. >- $("#bookbag_form a[href*='detail.pl?']").click(function(){ >- resetSearchContext(); >- }); >+ >+ if ( ! global_pref_BrowseResultSelection ) { >+ // forms with action leading to search >+ $("form[action*='search.pl']").submit(function(){ >+ resetSearchContext(); >+ }); >+ // any link to launch a search except navigation links >+ $("[href*='search.pl?']").not(".nav").not('.searchwithcontext').click(function(){ >+ resetSearchContext(); >+ }); >+ // any link to a detail page from the results page. >+ $("#bookbag_form a[href*='detail.pl?']").click(function(){ >+ resetSearchContext(); >+ }); >+ } > }); >-- >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 21024
:
76579
|
76583
|
76600
|
76714