From 203bfead646cc61071ee45326da09a44c7b905ba Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 28 Jul 2020 01:34:45 +0000 Subject: [PATCH] Bug 25314: Add system pref to control expanding/collapsing facets TO TEST: 1. Apply patch 2. Regenerate CSS (yarn build --view opac), updatedatabase and restart_all 3. DO a search and look at the facets. They should be collapsed. 4. Try mousing over a facet heading and click, that list should appear. 5. Try clicking the heading again to make th facet disappear. 6. Play around with different limiters and make sure eveything works. 7. Check aria labels look correct and you can tab through facets without a keyboard. 8. Find the system pref OPACFacetsCollapseByDefault in OPAC > Features 9. Try toggling different facets and make sure they all expland/collapse correctly --- ...ug_25314_add_OPACFacetsCollapseByDefault_syspref.perl | 6 ++++++ installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/opac.pref | 16 ++++++++++++++++ .../opac-tmpl/bootstrap/en/includes/opac-facets.inc | 1 - koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt | 14 ++++++++++++-- 5 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_25314_add_OPACFacetsCollapseByDefault_syspref.perl diff --git a/installer/data/mysql/atomicupdate/bug_25314_add_OPACFacetsCollapseByDefault_syspref.perl b/installer/data/mysql/atomicupdate/bug_25314_add_OPACFacetsCollapseByDefault_syspref.perl new file mode 100644 index 0000000000..d61dd20df2 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_25314_add_OPACFacetsCollapseByDefault_syspref.perl @@ -0,0 +1,6 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACFacetCollapseByDefault','0', 'Collapse/expand OPAC facets','','YesNO')" ); + + NewVersion( $DBversion, 25314, "Adds OPACFacetCollapseByDefault system preference"); +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index dbb13938ae..8d86001776 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -320,6 +320,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('maxItemsInSearchResults','20',NULL,'Specify the maximum number of items to display for each result on a page of results','free'), ('MaxOpenSuggestions','',NULL,'Limit the number of open suggestions a patron can have at once','Integer'), ('maxoutstanding','5','','maximum amount withstanding to be able make holds','Integer'), +('OPACFacetsCollapseByDefault','0','','Collapse/expand OPAC facets','YesNo'), ('OPACFineNoRenewalsBlockAutoRenew','0','','Block/Allow auto renewals if the patron owe more than OPACFineNoRenewals','YesNo'), ('maxRecordsForFacets','20',NULL,NULL,'Integer'), ('maxreserves','50','','Define maximum number of holds a patron can place','Integer'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 6f6e5499ef..e9cbccf74a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -402,6 +402,22 @@ OPAC: no: "Don't enable" - the option to show a QR Code on the OPAC bibliographic detail page. - + - "Define OPAC facets that should collapse by default" + - pref: OPACFacetsCollapseByDefault + multiple: + authors: Authors + collections: Collections + holding-libraries: Holding libraries + home-libraries: Home libraries + itemtypes: Itemtypes + languages: Languages + location: Locations + series: Series + places: Places + topics: Topics + titles: Titles + - "
Note: if none of the above options are selected all facets will expand by default" + - - pref: OPACFinesTab choices: yes: Allow diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc index 8fbda54c14..73bf7d5989 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc @@ -17,7 +17,6 @@ [% IF ( related ) %]
  • (related searches: [% FOREACH relate IN related %][% relate.related_search | html %][% END %])
  • [% END %] - [% FOREACH facets_loo IN facets_loop %] [% IF facets_loo.facets.size > 0 %]
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 1f47cff622..a7d1d03fa0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -1016,12 +1016,22 @@ $("input.newtag").on('keydown', function(e){ }); }); -$('.toggle-facet').click( function() { + +[% IF ( Koha.Preference('OPACFacetsCollapseByDefault') ) %] +[% SET OPACFacetsCollapsed = Koha.Preference('OPACFacetsCollapseByDefault') %] + var OPACFacetsToCollapse = "[% OPACFacetsCollapsed %]"; + var OPACFacetsToCollapeArray = OPACFacetsToCollapse.split(","); + OPACFacetsToCollapeArray.forEach(function(arr){ + $('#facet-'+arr).siblings('.collapsible-list').toggle(); + $('#facet-'+arr).toggleClass('facets-list-expanded'); + }) +[% END %] +$('.toggle-facet').click( function(){ $(this).siblings('.collapsible-list').toggle(); $(this).toggleClass('facet-list-expanded'); $(this).attr('aria-expanded' , function(index, attr) { return attr == 'true' ? false : true; }) -}) +}); [% END %] -- 2.11.0