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
......@@ -184,7 +184,7 @@ function can_build_group() {
* Returns TRUE if the exposed filter works like a grouped filter.
*/
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) {
* Validate the build group options form.
*/
function build_group_validate($form, &$form_state) {
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'])) {
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') {
form_error($form['group_info']['identifier'], t('This identifier is not allowed.'));
}
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.'));
}
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.'));
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.'));
}
}
if (!empty($form_state['values']['options']['group_info']['group_items'])) {
......
......@@ -65,6 +65,13 @@ function testExposedAdminUi() {
// Be sure that the button is called exposed.
$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.
$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.
......@@ -72,6 +79,12 @@ function testExposedAdminUi() {
// Check the label of the grouped exposed button
$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.
$edit = array();
$edit['options[expose][identifier]'] = '';
......@@ -91,6 +104,14 @@ function testExposedAdminUi() {
// Click the Grouped Filters button.
$this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type');
$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
// add more items to the list.
$this->helperButtonHasLabel('edit-options-group-info-add-group', t('Add another item'));
......@@ -125,6 +146,16 @@ function testExposedAdminUi() {
$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'));
// 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.
$edit = array();
$this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/sort/created', $edit, t('Expose sort'));
......
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