Skip to content
Snippets Groups Projects
Unverified Commit 8581df91 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #1810148 by Matroskeen, tanc, ravi.shankar, AaronBauman, VladimirAus,...

Issue #1810148 by Matroskeen, tanc, ravi.shankar, AaronBauman, VladimirAus, jmickela, edurenye, hugronaphor, erikwebb, dawehner, Lendude, tim.plunkett, drupalninja, mohit_aghera, youfei.sun, Nick Hope, seanmrafferty, pyrello, interdruper, attisan, EclipseGc, Blanca.Esqueda: Grouped exposed taxonomy term filters do not work
parent c7efd92e
No related branches found
No related tags found
38 merge requests!7471uncessary 5 files are moved from media-library folder to misc folder,!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!54479.5.x SF update,!5014Issue #3071143: Table Render Array Example Is Incorrect,!4868Issue #1428520: Improve menu parent link selection,!4289Issue #1344552 by marcingy, Niklas Fiekas, Ravi.J, aleevas, Eduardo Morales...,!4114Issue #2707291: Disable body-level scrolling when a dialog is open as a modal,!3630Issue #2815301 by Chi, DanielVeza, kostyashupenko, smustgrave: Allow to create...,!3291Issue #3336463: Rewrite rules for gzipped CSS and JavaScript aggregates never match,!3143Issue #3313342: [PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 LayoutBuilderUiCacheContext.php on line 28,!3102Issue #3164428 by DonAtt, longwave, sahil.goyal, Anchal_gupta, alexpott: Use...,!2853#3274419 Makes BaseFieldOverride inherit the internal property from the base field.,!2719Issue #3110137: Remove Classy from core.,!2437Issue #3238257 by hooroomoo, Wim Leers: Fragment link pointing to <textarea>...,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2074Issue #2707689: NodeForm::actions() checks for delete access on new entities,!2062Issue #3246454: Add weekly granularity to views date sort,!1974Issue #3036862 demonstration,!1591Issue #3199697: Add JSON:API Translation experimental module,!1484Exposed filters get values from URL when Ajax is on,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1254Issue #3238915: Refactor (if feasible) uses of the jQuery ready function to use VanillaJS,!1162Issue #3100350: Unable to save '/' root path alias,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!957Added throwing of InvalidPluginDefinitionException from getDefinition().,!925Issue #2339235: Remove taxonomy hard dependency on node module,!877Issue #2708101: Default value for link text is not saved,!873Issue #2875228: Site install not using batch API service,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links,!844Resolve #3036010 "Updaters",!712Issue #2909128: Autocomplete intermittent on Chrome Android,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!485Sets the autocomplete attribute for username/password input field on login form.,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
......@@ -344,6 +344,12 @@ public function validateExposed(&$form, FormStateInterface $form_state) {
}
$identifier = $this->options['expose']['identifier'];
$input = $form_state->getValue($identifier);
if ($this->options['is_grouped'] && isset($this->options['group_info']['group_items'][$input])) {
$this->validated_exposed_input = $this->options['group_info']['group_items'][$input]['value'];
return;
}
// We only validate if they've chosen the text field style.
if ($this->options['type'] != 'textfield') {
......
langcode: en
status: true
dependencies:
config:
- node.type.article
- taxonomy.vocabulary.tags
module:
- node
- taxonomy
- user
id: test_taxonomy_exposed_grouped_filter
label: 'Test Taxonomy Exposed Grouped Filter'
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
display:
default:
display_plugin: default
id: default
display_title: Default
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: mini
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ‹‹
next: ››
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
fields:
title:
id: title
table: node_field_data
field: title
entity_type: node
entity_field: title
label: ''
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
html: false
hide_empty: false
empty_zero: false
settings:
link_to_entity: true
plugin_id: field
relationship: none
group_type: group
admin_label: ''
exclude: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_alter_empty: true
click_sort_column: value
type: string
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
filters:
status:
value: '1'
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
operator_limit_selection: false
operator_list: { }
group: 1
type:
id: type
table: node_field_data
field: type
value:
article: article
entity_type: node
entity_field: type
plugin_id: bundle
expose:
operator_limit_selection: false
operator_list: { }
field_views_testing_tags_target_id:
id: field_views_testing_tags_target_id
table: node__field_views_testing_tags
field: field_views_testing_tags_target_id
relationship: none
group_type: group
admin_label: ''
operator: or
value: { }
group: 1
exposed: true
expose:
operator_id: field_views_testing_tags_target_id_op
label: 'views_testing_tags (field_views_testing_tags)'
description: null
use_operator: false
operator: field_views_testing_tags_target_id_op
operator_limit_selection: false
operator_list: { }
identifier: field_views_testing_tags_target_id
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
reduce: false
is_grouped: true
group_info:
label: 'views_testing_tags (field_views_testing_tags)'
description: ''
identifier: field_views_testing_tags_target_id
optional: true
widget: radios
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items:
1:
title: 'Group 1'
operator: or
value:
1: '1'
2: '2'
2:
title: 'Group 2'
operator: or
value:
3: '3'
4: '4'
3:
title: 'Group 3'
operator: or
value:
1: '1'
5: '5'
reduce_duplicates: false
type: select
limit: true
vid: tags
hierarchy: false
error_message: true
plugin_id: taxonomy_index_tid
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
entity_type: node
entity_field: created
plugin_id: date
relationship: none
group_type: group
admin_label: ''
exposed: false
expose:
label: ''
field_identifier: ''
granularity: second
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- user
- 'user.node_grants:view'
- user.permissions
tags: { }
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 1
display_options:
display_extenders: { }
path: test-taxonomy-exposed-grouped-filter
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args
- user
- 'user.node_grants:view'
- user.permissions
tags: { }
......@@ -24,7 +24,11 @@ class TaxonomyIndexTidUiTest extends UITestBase {
*
* @var array
*/
public static $testViews = ['test_filter_taxonomy_index_tid', 'test_taxonomy_term_name'];
public static $testViews = [
'test_filter_taxonomy_index_tid',
'test_taxonomy_term_name',
'test_taxonomy_exposed_grouped_filter',
];
/**
* {@inheritdoc}
......@@ -230,6 +234,50 @@ public function testExposedFilter() {
$this->assertSession()->elementNotExists('xpath', "//div[@class='view-content']");
}
/**
* Tests exposed grouped taxonomy filters.
*/
public function testExposedGroupedFilter() {
// Create a content type with a taxonomy field.
$this->drupalCreateContentType(['type' => 'article']);
$field_name = 'field_views_testing_tags';
$this->createEntityReferenceField('node', 'article', $field_name, NULL, 'taxonomy_term');
$nodes = [];
for ($i = 0; $i < 3; $i++) {
$node = [];
$node['type'] = 'article';
$node['field_views_testing_tags'][0]['target_id'] = $this->terms[$i][0]->id();
$nodes[] = $this->drupalCreateNode($node);
}
$this->drupalGet('/admin/structure/views/nojs/handler/test_taxonomy_exposed_grouped_filter/page_1/filter/field_views_testing_tags_target_id');
$edit = [
'options[group_info][group_items][1][value][]' => [$this->terms[0][0]->id(), $this->terms[1][0]->id()],
'options[group_info][group_items][2][value][]' => [$this->terms[1][0]->id(), $this->terms[2][0]->id()],
'options[group_info][group_items][3][value][]' => [$this->terms[2][0]->id(), $this->terms[0][0]->id()],
];
$this->submitForm($edit, 'Apply');
$this->submitForm([], 'Save');
// Visit the view's page url and validate the results.
$this->drupalGet('/test-taxonomy-exposed-grouped-filter');
$this->submitForm(['field_views_testing_tags_target_id' => 1], 'Apply');
$this->assertSession()->pageTextContains($nodes[0]->getTitle());
$this->assertSession()->pageTextContains($nodes[1]->getTitle());
$this->assertSession()->pageTextNotContains($nodes[2]->getTitle());
$this->submitForm(['field_views_testing_tags_target_id' => 2], 'Apply');
$this->assertSession()->pageTextContains($nodes[1]->getTitle());
$this->assertSession()->pageTextContains($nodes[2]->getTitle());
$this->assertSession()->pageTextNotContains($nodes[0]->getTitle());
$this->submitForm(['field_views_testing_tags_target_id' => 3], 'Apply');
$this->assertSession()->pageTextContains($nodes[0]->getTitle());
$this->assertSession()->pageTextContains($nodes[2]->getTitle());
$this->assertSession()->pageTextNotContains($nodes[1]->getTitle());
}
/**
* Tests that an exposed taxonomy filter doesn't show unpublished terms.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment