Skip to content
Snippets Groups Projects
Commit d1db5741 authored by Tim Plunkett's avatar Tim Plunkett Committed by Tim Plunkett
Browse files

Issue #1719496 by dagmar: Fixed Filter cannot be configured after certain conditions.

parent 5e4b5ff6
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -184,7 +184,7 @@ function can_build_group() { ...@@ -184,7 +184,7 @@ function can_build_group() {
* Returns TRUE if the exposed filter works like a grouped filter. * Returns TRUE if the exposed filter works like a grouped filter.
*/ */
function is_a_group() { function is_a_group() {
return !empty($this->options['is_grouped']); return $this->is_exposed() && !empty($this->options['is_grouped']);
} }
/** /**
...@@ -597,16 +597,18 @@ function expose_validate($form, &$form_state) { ...@@ -597,16 +597,18 @@ function expose_validate($form, &$form_state) {
* Validate the build group options form. * Validate the build group options form.
*/ */
function build_group_validate($form, &$form_state) { function build_group_validate($form, &$form_state) {
if (empty($form_state['values']['options']['group_info']['identifier'])) { if (!empty($form_state['values']['options']['group_info'])) {
form_error($form['group_info']['identifier'], t('The identifier is required if the filter is exposed.')); if (empty($form_state['values']['options']['group_info']['identifier'])) {
} form_error($form['group_info']['identifier'], t('The identifier is required if the filter is exposed.'));
}
if (!empty($form_state['values']['options']['group_info']['identifier']) && $form_state['values']['options']['group_info']['identifier'] == 'value') { if (!empty($form_state['values']['options']['group_info']['identifier']) && $form_state['values']['options']['group_info']['identifier'] == 'value') {
form_error($form['group_info']['identifier'], t('This identifier is not allowed.')); form_error($form['group_info']['identifier'], t('This identifier is not allowed.'));
} }
if (!$this->view->display_handler->is_identifier_unique($form_state['id'], $form_state['values']['options']['group_info']['identifier'])) { if (!$this->view->display_handler->is_identifier_unique($form_state['id'], $form_state['values']['options']['group_info']['identifier'])) {
form_error($form['group_info']['identifier'], t('This identifier is used by another handler.')); form_error($form['group_info']['identifier'], t('This identifier is used by another handler.'));
}
} }
if (!empty($form_state['values']['options']['group_info']['group_items'])) { if (!empty($form_state['values']['options']['group_info']['group_items'])) {
......
...@@ -65,6 +65,13 @@ function testExposedAdminUi() { ...@@ -65,6 +65,13 @@ function testExposedAdminUi() {
// Be sure that the button is called exposed. // Be sure that the button is called exposed.
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose filter')); $this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose filter'));
// The first time the filter UI is displayed, the operator and the
// value forms should be shown.
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists');
$this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists');
$this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists');
$this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists');
// Click the Expose filter button. // Click the Expose filter button.
$this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter')); $this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter'));
// Check the label of the expose button. // Check the label of the expose button.
...@@ -72,6 +79,12 @@ function testExposedAdminUi() { ...@@ -72,6 +79,12 @@ function testExposedAdminUi() {
// Check the label of the grouped exposed button // Check the label of the grouped exposed button
$this->helperButtonHasLabel('edit-options-group-button-button', t('Grouped filters')); $this->helperButtonHasLabel('edit-options-group-button-button', t('Grouped filters'));
// After exposing the filter, Operator and Value should be still here.
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists');
$this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists');
$this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists');
$this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists');
// Check the validations of the filter handler. // Check the validations of the filter handler.
$edit = array(); $edit = array();
$edit['options[expose][identifier]'] = ''; $edit['options[expose][identifier]'] = '';
...@@ -91,6 +104,14 @@ function testExposedAdminUi() { ...@@ -91,6 +104,14 @@ function testExposedAdminUi() {
// Click the Grouped Filters button. // Click the Grouped Filters button.
$this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type');
$this->drupalPost(NULL, array(), t('Grouped filters')); $this->drupalPost(NULL, array(), t('Grouped filters'));
// After click on 'Grouped Filters', the standard operator and value should
// not be displayed.
$this->assertNoFieldById('edit-options-operator-in', '', 'Operator In not exists');
$this->assertNoFieldById('edit-options-operator-not-in', '', 'Operator Not In not exists');
$this->assertNoFieldById('edit-options-value-page', '', 'Checkbox for Page not exists');
$this->assertNoFieldById('edit-options-value-article', '', 'Checkbox for Article not exists');
// Check that after click on 'Grouped Filters', a new button is shown to // Check that after click on 'Grouped Filters', a new button is shown to
// add more items to the list. // add more items to the list.
$this->helperButtonHasLabel('edit-options-group-info-add-group', t('Add another item')); $this->helperButtonHasLabel('edit-options-group-info-add-group', t('Add another item'));
...@@ -125,6 +146,16 @@ function testExposedAdminUi() { ...@@ -125,6 +146,16 @@ function testExposedAdminUi() {
$this->drupalPost(NULL, $edit, t('Apply')); $this->drupalPost(NULL, $edit, t('Apply'));
$this->assertRaw(t('The title is required if value for this item is defined.'), t('Group items should have a title')); $this->assertRaw(t('The title is required if value for this item is defined.'), t('Group items should have a title'));
// Un-expose the filter.
$this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type');
$this->drupalPost(NULL, array(), t('Hide filter'));
// After Un-exposing the filter, Operator and Value should be shown again.
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists after hide filter');
$this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists after hide filter');
$this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists after hide filter');
$this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists after hide filter');
// Click the Expose sort button. // Click the Expose sort button.
$edit = array(); $edit = array();
$this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/sort/created', $edit, t('Expose sort')); $this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/sort/created', $edit, t('Expose sort'));
......
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