Skip to content
Snippets Groups Projects
Unverified Commit 577f9357 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

(cherry picked from commit 8581df91)
parent fd949e55
No related branches found
No related tags found
54 merge requests!10107Issue #2797141 by Driskell, daffie, andypost, Charlie ChX Negyesi,...,!10082Issue #3267754 by lauriii: AjaxTest is failing,!9277Issue #3262500 by catch, andypost: Mark drupal_find_theme_functions() @internal in Drupal 9,!85673265330-fix-missing-hyphens: Create patch to MR and fix remaining words,!8394[warning] array_flip(): Can only flip STRING and INTEGER values, when saving a non-revisionable custom content entity,!8357Issue #2994000 by Lendude, Pasqualle, quietone, pameeela: Notice in logs when...,!7780issue 3443822: fix for 'No route found for the specified format html. Supported formats: json, xml.',!7416Simplify the HTML of field.html.twig,!7150Revert "Issue #3137119 by munish.kumar, johnwebdev, Jaypan, jungle, xjm,...,!6445Issue #3034692: Renamed the getHandler function which return the configuration of a handler instance on given display,!5013Issue #3071143: Table Render Array Example Is Incorrect,!4848Issue #1566662: Update module should send notifications on Thursdays,!4792Issue #2230689: Remove redundant "Italic" style,!4782Issue #2662898: "Links" field not displaying on custom view modes,!4488Issue #3376281: Random machine names no longer need to be wrapped in strtolower(),!4220Issue #3368223: Link field > Access to internal links is not checked on display.,!4173Issue #2123543: Add string context and location filters to the translate interface,!3884Issue #3356842,!3870Issue #3087868,!3812Draft: Issue #3339373 by alexpott, andypost, mondrake:...,!3736Issue #3294005: Refactor Claro's form--password-confirm stylesheet,!3686Issue #3219967 against 9.5.x,!3683Issue #2939397: Clearing AliasManager cache with root path raises warning,!3543Issue #3344259: Allow ajax dialog to have focus configurable,!3437Issue #3106205: Length of menu_tree.url and menu_tree.route_param_key are too short (255 characters),!3356Issue #3209129: Scrolling problems when adding a block via layout builder,!3000Issue #793660: Check for failure of hook_install,!2982Issue #3301562: Translate the default settings for this plugin (TimestampAgoFormatter),!2940Issue #3320240: Entity count query returns a string instead of int,!2921Issue #1383696: Allow a custom HTML element to be selected for a grouping field,!2920Issue #3260175: Saving media entity without an owner crashes,!2857Issue #3314541: Remove unnecessary fill from SVG icon for the "Media Library" CKEditor 5 button — enabling dark mode support in contrib,!2841Resolve #3296811 "Resourceresponsetrait needs a",!2733Issue #3293855: Update the outdated user_help text for user.admin_permissions and the description of the select box on the role settings page,!2447Issue #3293135: shouldUpdateThumbnail does not update thumbnail is source field changed,!2280Issue #3280415: Metapackage Generator Breaks Under Composer --no-dev,!2205Quote all names in the regions section.,!2050Issue #3272969: Remove UnqiueField constraint.,!1956Issue #3268872: hook_views_invalidate_cache not called when a view is deleted,!1935Issue #3114887: Error responses are stored when using the Download migration process,!1896Issue #2940605: Can only intentionally re-render an entity with references 20 times,!1627Issue #3082958: Add gitignore(s) to composer-ready project templates,!1459Issue #3087632: menu_name max length is too long,!1428Issue #2576927: Grouped exposed filters fails validation for autocomplete widget,!1283Issue #2922435: "Add new comment" and "@count comments" links are not following accessibility good practices,!1213Issue #3236497: Allow other modules to opt out of security release message from update_page_top,!1014Issue #3226806: Move filter implementations from filter.module to plugin classes,!939Issue #2971209: Allow the MediaLibraryUiBuilder service to use an alternative view display,!878Issue #3221534: throw an exception when IDs passed to loadMultiple() are badly formed,!866Issue #2845319: The highlighting of the 'Home' menu-link does not respect query strings and fragment identifiers,!8293023322 - Contextual Links Style Update,!695Issue #2817657: Add methods to assert that a sequence of strings appears on the page in a given order,!204Issue #3040556: It is not possible to react to an entity being duplicated,!88Issue #3163299: Ajax exposed filters not working for multiple instances of the same Views block placed on one page
......@@ -348,6 +348,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.
Please register or to comment