Unverified Commit 76d1e6ff authored by lauriii's avatar lauriii

Issue #3161207 by kndr, Mirakolous, ranjith_kumar_k_u, anmolgoyal74, lauriii,...

Issue #3161207 by kndr, Mirakolous, ranjith_kumar_k_u, anmolgoyal74, lauriii, paulocs, tanubansal, Abhijith S, Lendude: Operator labels are not redrawn on filter removal

(cherry picked from commit 22c3d048)
parent 6f5b187d
......@@ -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.
*
......@@ -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);
......@@ -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;
......@@ -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
......@@ -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.
*/
......
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