Loading core/modules/views_ui/js/views-admin.es6.js +32 −32 Original line number Diff line number Diff line Loading @@ -629,38 +629,6 @@ }, }; /** * Rearranges the filters. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attach handlers to make it possible to rearrange the filters in the form * in question. * @see Drupal.viewsUi.RearrangeFilterHandler */ Drupal.behaviors.viewsUiRearrangeFilter = { attach(context) { // Only act on the rearrange filter form. if ( typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined' ) { return; } const $context = $(context); const $table = $context .find('#views-rearrange-filters') .once('views-rearrange-filters'); const $operator = $context .find('.js-form-item-filter-groups-operator') .once('views-rearrange-filters'); if ($table.length) { new Drupal.viewsUi.RearrangeFilterHandler($table, $operator); } }, }; /** * Improve the UI of the rearrange filters dialog box. * Loading Loading @@ -1322,4 +1290,36 @@ }); }, }; /** * Rearranges the filters. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attach handlers to make it possible to rearrange the filters in the form * in question. * @see Drupal.viewsUi.RearrangeFilterHandler */ Drupal.behaviors.viewsUiRearrangeFilter = { attach(context) { // Only act on the rearrange filter form. if ( typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined' ) { return; } const $context = $(context); const $table = $context .find('#views-rearrange-filters') .once('views-rearrange-filters'); const $operator = $context .find('.js-form-item-filter-groups-operator') .once('views-rearrange-filters'); if ($table.length) { new Drupal.viewsUi.RearrangeFilterHandler($table, $operator); } }, }; })(jQuery, Drupal, drupalSettings); core/modules/views_ui/js/views-admin.js +15 −15 Original line number Diff line number Diff line Loading @@ -296,21 +296,6 @@ } } }; Drupal.behaviors.viewsUiRearrangeFilter = { attach: function attach(context) { if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined') { return; } var $context = $(context); var $table = $context.find('#views-rearrange-filters').once('views-rearrange-filters'); var $operator = $context.find('.js-form-item-filter-groups-operator').once('views-rearrange-filters'); if ($table.length) { new Drupal.viewsUi.RearrangeFilterHandler($table, $operator); } } }; Drupal.viewsUi.RearrangeFilterHandler = function ($table, $operator) { this.table = $table; Loading Loading @@ -602,4 +587,19 @@ }); } }; Drupal.behaviors.viewsUiRearrangeFilter = { attach: function attach(context) { if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined') { return; } var $context = $(context); var $table = $context.find('#views-rearrange-filters').once('views-rearrange-filters'); var $operator = $context.find('.js-form-item-filter-groups-operator').once('views-rearrange-filters'); if ($table.length) { new Drupal.viewsUi.RearrangeFilterHandler($table, $operator); } } }; })(jQuery, Drupal, drupalSettings); No newline at end of file core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php +48 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,54 @@ public function testFilterCriteriaDialog() { $this->assertFalse($remove_link->isVisible(), 'Remove group should be invisible after drag.'); } /** * Tests operator labels. */ public function testOperatorLabels() { // Open the "Frontpage" view. $this->drupalGet('admin/structure/views/view/frontpage'); $session = $this->getSession(); $page = $session->getPage(); // Open the "Rearrange filter criteria" dialog. $this->openFilterDialog(); // Get the last filter on the list. $row = $page->findAll('css', '.draggable'); $row_count = count($row); $last_row = array_pop($row); $penultimate_row = array_pop($row); // Drag the last row before the penultimate row. $drag_handle = $last_row->find('css', '.tabledrag-handle'); $drag_handle->dragTo($penultimate_row); // Assert there are valid number of visible operator labels. $operator_label = $page->findAll('css', '.views-operator-label'); $this->assertEquals($row_count - 1, count($operator_label), 'There are valid number of operator labels after drag.'); // Get the last filter on the rearranged list. $row = $page->findAll('css', '.draggable'); $last_row = array_pop($row); $penultimate_row = array_pop($row); // Assert the operator label in the penultimate row is shown. $operator_label = $penultimate_row->find('css', '.views-operator-label'); $this->assertTrue($operator_label->isVisible(), 'Operator label in the penultimate row is not visible after drag.'); // Assert the operator label in the last row is not shown. $operator_label = $last_row->find('css', '.views-operator-label'); $this->assertNull($operator_label, 'Operator label in the last row is not visible after drag.'); // Remove the last filter. $remove_link = $last_row->find('css', '.views-remove-link'); $remove_link->click(); // The current last filter shouldn't have the operator label. $operator_label = $penultimate_row->find('css', '.views-operator-label'); $this->assertNull($operator_label, 'The penultimate filter has no operator label after the last filter is removed.'); } /** * Uses the 'And/Or Rearrange' link for filters to open a dialog. */ Loading Loading
core/modules/views_ui/js/views-admin.es6.js +32 −32 Original line number Diff line number Diff line Loading @@ -629,38 +629,6 @@ }, }; /** * Rearranges the filters. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attach handlers to make it possible to rearrange the filters in the form * in question. * @see Drupal.viewsUi.RearrangeFilterHandler */ Drupal.behaviors.viewsUiRearrangeFilter = { attach(context) { // Only act on the rearrange filter form. if ( typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined' ) { return; } const $context = $(context); const $table = $context .find('#views-rearrange-filters') .once('views-rearrange-filters'); const $operator = $context .find('.js-form-item-filter-groups-operator') .once('views-rearrange-filters'); if ($table.length) { new Drupal.viewsUi.RearrangeFilterHandler($table, $operator); } }, }; /** * Improve the UI of the rearrange filters dialog box. * Loading Loading @@ -1322,4 +1290,36 @@ }); }, }; /** * Rearranges the filters. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attach handlers to make it possible to rearrange the filters in the form * in question. * @see Drupal.viewsUi.RearrangeFilterHandler */ Drupal.behaviors.viewsUiRearrangeFilter = { attach(context) { // Only act on the rearrange filter form. if ( typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined' ) { return; } const $context = $(context); const $table = $context .find('#views-rearrange-filters') .once('views-rearrange-filters'); const $operator = $context .find('.js-form-item-filter-groups-operator') .once('views-rearrange-filters'); if ($table.length) { new Drupal.viewsUi.RearrangeFilterHandler($table, $operator); } }, }; })(jQuery, Drupal, drupalSettings);
core/modules/views_ui/js/views-admin.js +15 −15 Original line number Diff line number Diff line Loading @@ -296,21 +296,6 @@ } } }; Drupal.behaviors.viewsUiRearrangeFilter = { attach: function attach(context) { if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined') { return; } var $context = $(context); var $table = $context.find('#views-rearrange-filters').once('views-rearrange-filters'); var $operator = $context.find('.js-form-item-filter-groups-operator').once('views-rearrange-filters'); if ($table.length) { new Drupal.viewsUi.RearrangeFilterHandler($table, $operator); } } }; Drupal.viewsUi.RearrangeFilterHandler = function ($table, $operator) { this.table = $table; Loading Loading @@ -602,4 +587,19 @@ }); } }; Drupal.behaviors.viewsUiRearrangeFilter = { attach: function attach(context) { if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined') { return; } var $context = $(context); var $table = $context.find('#views-rearrange-filters').once('views-rearrange-filters'); var $operator = $context.find('.js-form-item-filter-groups-operator').once('views-rearrange-filters'); if ($table.length) { new Drupal.viewsUi.RearrangeFilterHandler($table, $operator); } } }; })(jQuery, Drupal, drupalSettings); No newline at end of file
core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php +48 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,54 @@ public function testFilterCriteriaDialog() { $this->assertFalse($remove_link->isVisible(), 'Remove group should be invisible after drag.'); } /** * Tests operator labels. */ public function testOperatorLabels() { // Open the "Frontpage" view. $this->drupalGet('admin/structure/views/view/frontpage'); $session = $this->getSession(); $page = $session->getPage(); // Open the "Rearrange filter criteria" dialog. $this->openFilterDialog(); // Get the last filter on the list. $row = $page->findAll('css', '.draggable'); $row_count = count($row); $last_row = array_pop($row); $penultimate_row = array_pop($row); // Drag the last row before the penultimate row. $drag_handle = $last_row->find('css', '.tabledrag-handle'); $drag_handle->dragTo($penultimate_row); // Assert there are valid number of visible operator labels. $operator_label = $page->findAll('css', '.views-operator-label'); $this->assertEquals($row_count - 1, count($operator_label), 'There are valid number of operator labels after drag.'); // Get the last filter on the rearranged list. $row = $page->findAll('css', '.draggable'); $last_row = array_pop($row); $penultimate_row = array_pop($row); // Assert the operator label in the penultimate row is shown. $operator_label = $penultimate_row->find('css', '.views-operator-label'); $this->assertTrue($operator_label->isVisible(), 'Operator label in the penultimate row is not visible after drag.'); // Assert the operator label in the last row is not shown. $operator_label = $last_row->find('css', '.views-operator-label'); $this->assertNull($operator_label, 'Operator label in the last row is not visible after drag.'); // Remove the last filter. $remove_link = $last_row->find('css', '.views-remove-link'); $remove_link->click(); // The current last filter shouldn't have the operator label. $operator_label = $penultimate_row->find('css', '.views-operator-label'); $this->assertNull($operator_label, 'The penultimate filter has no operator label after the last filter is removed.'); } /** * Uses the 'And/Or Rearrange' link for filters to open a dialog. */ Loading