Commit b405f348 authored by catch's avatar catch

Issue #2717629 by Lendude, michielnugter, droplet, catapipper, dbyers55: Add...

Issue #2717629 by Lendude, michielnugter, droplet, catapipper, dbyers55: Add filter group for a View fails
parent 7313770a
......@@ -733,12 +733,7 @@
* The event triggered.
*/
clickAddGroupButton: function (event) {
// Due to conflicts between Drupal core's AJAX system and the Views AJAX
// system, the only way to get this to work seems to be to trigger both
// the mousedown and submit events.
this.addGroupButton
.trigger('mousedown')
.trigger('submit');
this.addGroupButton.trigger('mousedown');
event.preventDefault();
},
......@@ -750,7 +745,7 @@
* form button that should be clicked.
*/
clickRemoveGroupButton: function (event) {
this.table.find('#' + event.data.buttonId).trigger('mousedown').trigger('submit');
this.table.find('#' + event.data.buttonId).trigger('mousedown');
event.preventDefault();
},
......
......@@ -129,6 +129,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'class' => array('views-remove-group'),
),
'#group' => $id,
'#ajax' => ['url' => NULL],
);
}
$group_options[$id] = $id == 1 ? $this->t('Default group') : $this->t('Group @group', array('@group' => $id));
......
<?php
namespace Drupal\Tests\views_ui\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
/**
* Tests the View UI filter criteria group dialog.
*
* @group views_ui
*/
class FilterCriteriaTest extends JavascriptTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'views', 'views_ui'];
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$admin_user = $this->drupalCreateUser([
'administer site configuration',
'administer views',
'administer nodes',
'access content overview',
]);
// Disable automatic live preview to make the sequence of calls clearer.
\Drupal::configFactory()->getEditable('views.settings')->set('ui.always_live_preview', FALSE)->save();
$this->drupalLogin($admin_user);
}
/**
* Tests dialog for filter criteria.
*/
public function testFilterCriteriaDialog() {
$this->drupalGet('admin/structure/views/view/content_recent');
$assert_session = $this->assertSession();
$page = $this->getSession()->getPage();
// Use the 'And/Or Rearrange' link for fields to open a dialog.
$dropbutton = $page->find('css', '.views-ui-display-tab-bucket.filter .dropbutton-toggle button');
$dropbutton->click();
$add_link = $page->findById('views-rearrange-filter');
$this->assertTrue($add_link->isVisible(), 'And/Or Rearrange button found.');
$add_link->click();
$assert_session->assertWaitOnAjaxRequest();
// Add a new filter group.
$create_new_filter_group = $page->findById('views-add-group-link');
$this->assertTrue($create_new_filter_group->isVisible(), 'Add group link found.');
$create_new_filter_group->click();
$assert_session->assertWaitOnAjaxRequest();
// Assert the existence of the new filter group by checking the remove group
// link.
$remove_link = $page->findLink('Remove group');
$this->assertTrue($remove_link->isVisible(), 'New group found.');
// Remove the group again and assert the group is not present anymore.
$remove_link->click();
$assert_session->assertWaitOnAjaxRequest();
$remove_link = $page->findLink('Remove group');
$this->assertEmpty($remove_link, 'Remove button not available');
}
}
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