Commit a542b87b authored by ac's avatar ac Committed by borisson_

Issue #2925719 by ac, borisson_: Remove label from breadcrumb

parent b6f72b9b
......@@ -24,6 +24,9 @@ facets.facet_source.*:
active:
type: boolean
label: 'Append active facets to breadcrumb'
before:
type: boolean
label: 'Show facet label before active facet'
group:
type: boolean
label: 'Group active items under same crumb'
......
......@@ -340,7 +340,12 @@ function facets_system_breadcrumb_alter(Breadcrumb &$breadcrumb, RouteMatchInter
// Set the new query and create the link.
$facet_url->setOption('query', $query);
$crumb_text = $active_facets[$facet_alias]->label() . ': ' . implode(', ', $facet_crumb_items);
if (!empty($facet_source->getBreadcrumbSettings()['before'])) {
$crumb_text = $active_facets[$facet_alias]->label() . ': ' . implode(', ', $facet_crumb_items);
}
else {
$crumb_text = implode(', ', $facet_crumb_items);
};
$link = Link::fromTextAndUrl($crumb_text, $facet_url);
$breadcrumb->addLink($link);
}
......
......@@ -146,6 +146,16 @@ class FacetSourceEditForm extends EntityForm {
'#title' => $this->t('Append active facets to breadcrumb'),
'#default_value' => isset($breadcrumb_settings['active']) ? $breadcrumb_settings['active'] : FALSE,
];
$form['breadcrumb']['before'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show facet label before active facet'),
'#default_value' => isset($breadcrumb_settings['before']) ? $breadcrumb_settings['before'] : TRUE,
'#states' => [
'visible' => [
':input[name="breadcrumb[active]"]' => ['checked' => TRUE],
],
],
];
$form['breadcrumb']['group'] = [
'#type' => 'checkbox',
'#title' => $this->t('Group active items under same crumb (not implemented yet - now always grouping)'),
......
......@@ -80,6 +80,34 @@ class BreadcrumbIntegrationTest extends FacetsTestBase {
$this->markTestSkipped('Not yet implemented.');
}
/**
* Tests enabling + disabling the breadcrumb label prefix.
*/
public function testBreadcrumbLabel() {
$id = 'type';
$this->createFacet('Type', $id);
$this->resetAll();
$this->drupalGet('admin/config/search/facets/' . $id . '/edit');
$this->drupalPostForm(NULL, ['facet_settings[weight]' => '1'], 'Save');
$this->editFacetConfig(['breadcrumb[before]' => FALSE]);
$initial_query = ['search_api_fulltext' => 'foo'];
$this->drupalGet('search-api-test-fulltext', ['query' => $initial_query]);
$this->clickLink('item');
$breadcrumb = $this->getSession()->getPage()->find('css', '.breadcrumb');
$this->assertFalse(strpos($breadcrumb->getText(), 'Type'));
$breadcrumb->findLink('item');
$this->editFacetConfig(['breadcrumb[before]' => TRUE]);
$initial_query = ['search_api_fulltext' => 'foo'];
$this->drupalGet('search-api-test-fulltext', ['query' => $initial_query]);
$this->clickLink('item');
$breadcrumb = $this->getSession()->getPage()->find('css', '.breadcrumb');
$this->assertTrue(strpos($breadcrumb->getText(), 'Type'));
}
/**
* Edit the facet configuration with the given values.
*
......
Markdown is supported
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