Skip to content
Snippets Groups Projects
Commit 1cc8915e authored by Demian Katz's avatar Demian Katz
Browse files

Merge branch 'release-3.1'

parents 156e01ba b2a051a3
No related merge requests found
......@@ -360,7 +360,27 @@ class SearchActionsTest extends \VuFindTest\Unit\MinkTestCase
}
/**
* Test that exclusion works properly deep in lightbox results.
* Support method to click a hierarchical facet.
*
* @param \Behat\Mink\Element\Element $page Mink page object
*
* @return void
*/
protected function clickHierarchyFacet($page)
{
$this->findCss($page, '#j1_1.jstree-closed .jstree-icon');
$session = $this->getMinkSession();
$session->executeScript("$('#j1_1.jstree-closed .jstree-icon').click();");
$this->findCss($page, '#j1_1.jstree-open .jstree-icon');
$this->findCss($page, '#j1_2 a')->click();
$this->snooze();
$filter = $this->findCss($page, '.filters .list-group-item.active');
$this->assertEquals('hierarchy: 1/level1a/level2a/', $filter->getText());
$this->findCss($page, '#j1_2 .fa-check');
}
/**
* Test that hierarchy facets work properly.
*
* @return void
*/
......@@ -378,15 +398,46 @@ class SearchActionsTest extends \VuFindTest\Unit\MinkTestCase
]
]
);
$page = $this->performSearch('');
$this->findCss($page, '#j1_1.jstree-closed .jstree-icon');
$session = $this->getMinkSession();
$session->executeScript("$('#j1_1.jstree-closed .jstree-icon').click();");
$this->findCss($page, '#j1_1.jstree-open .jstree-icon');
$this->findCss($page, '#j1_2 a')->click();
$filter = $this->findCss($page, '.filters .list-group-item.active');
$this->assertEquals('hierarchy: 1/level1a/level2a/', $filter->getText());
$this->findCss($page, '#j1_2 .fa-check');
$page = $this->performSearch('building:"hierarchy.mrc"');
$this->clickHierarchyFacet($page);
}
/**
* Test that we can persist uncollapsed state of collapsed facets
*
* @return void
*/
public function testCollapseStatePersistence()
{
$this->changeConfigs(
[
'facets' => [
'Results' => [
'hierarchical_facet_str_mv' => 'hierarchy'
],
'Results_Settings' => [
'collapsedFacets' => '*'
],
'SpecialFacets' => [
'hierarchical[]' => 'hierarchical_facet_str_mv'
]
]
]
);
$page = $this->performSearch('building:"hierarchy.mrc"');
// Uncollapse format so we can check if it is still open after reload:
$this->findCss($page, '#side-panel-format .collapsed')->click();
// Uncollapse hierarchical facet so we can click it:
$this->findCss($page, '#side-panel-hierarchical_facet_str_mv .collapsed')->click();
$this->clickHierarchyFacet($page);
// We have now reloaded the page. Let's toggle format off and on to confirm
// that it was opened, and let's also toggle building on to confirm that
// it was not alread opened.
$this->findCss($page, '#side-panel-format .title')->click(); // off
$this->snooze(); // wait for animation
$this->findCss($page, '#side-panel-format .collapsed')->click(); // on
$this->findCss($page, '#side-panel-building .collapsed')->click(); // on
}
/**
......
......@@ -250,7 +250,6 @@ function setupAutocomplete() {
/**
* Handle arrow keys to jump to next record
* @returns {undefined}
*/
function keyboardShortcuts() {
var $searchform = $('.searchForm_lookfor');
......@@ -290,6 +289,33 @@ function keyboardShortcuts() {
}
}
/**
* Setup facets
*/
function setupFacets() {
// Advanced facets
$('.facetOR').click(function facetBlocking() {
$(this).closest('.collapse').html('<div class="list-group-item">' + VuFind.translate('loading') + '...</div>');
window.location.assign($(this).attr('href'));
});
// Side facet status saving
$('.facet.list-group .collapse').each(function openStoredFacets(index, item) {
var source = $('#result0 .hiddenSource').val();
var storedItem = sessionStorage.getItem('sidefacet-' + source + item.id);
if (storedItem) {
item.className = storedItem;
if ($(item).hasClass('in')) {
$(item).collapse('show');
} else {
$(item).collapse('hide');
}
}
});
$('.facet.list-group .collapse').on('shown.bs.collapse', facetSessionStorage);
$('.facet.list-group .collapse').on('hidden.bs.collapse', facetSessionStorage);
}
$(document).ready(function commonDocReady() {
// Start up all of our submodules
VuFind.init();
......@@ -340,28 +366,8 @@ $(document).ready(function commonDocReady() {
$.getJSON(VuFind.path + '/AJAX/JSON', {method: 'keepAlive'});
}
// Advanced facets
$('.facetOR').click(function facetBlocking() {
$(this).closest('.collapse').html('<div class="list-group-item">' + VuFind.translate('loading') + '...</div>');
window.location.assign($(this).attr('href'));
});
// Side facet status saving
$('.facet.list-group .collapse').each(function openStoredFacets(index, item) {
var source = $('#result0 .hiddenSource').val();
var storedItem = sessionStorage.getItem('sidefacet-' + source + item.id);
if (storedItem) {
item.className = storedItem;
if (item.className.indexOf('in') < 0) {
$(item).siblings('.title').addClass('collapsed');
} else {
$(item).siblings('.title').removeClass('collapsed');
}
}
});
$('.facet.list-group .collapse').on('shown.bs.collapse', facetSessionStorage);
$('.facet.list-group .collapse').on('hidden.bs.collapse', facetSessionStorage);
setupFacets();
// retain filter sessionStorage
$('.searchFormKeepFilters').click(function retainFiltersInSessionStorage() {
sessionStorage.setItem('vufind_retain_filters', this.checked ? 'true' : 'false');
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment