Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
<click selector="body" stepKey="clickBodyToCorrectFocusGrouped"/>
<click selector="{{AdminProductFormGroupedProductsSection.addProductsToGroup}}" stepKey="clickAddProductsToGroup"/>
<waitForElementVisible selector="{{AdminAddProductsToGroupPanel.filters}}" stepKey="waitForGroupedProductModal"/>
<click selector="{{AdminProductGridPaginationSection.perPageDropdown}}" stepKey="clickProductPerPageDropdown"/>
<click selector="{{AdminProductGridPaginationSection.perPageOption('50')}}" stepKey="selectProductsPerPage"/>
<actionGroup ref="FilterProductGridBySku2ActionGroup" stepKey="filterGroupedProducts">
<argument name="sku" value="api-simple-product"/>
</actionGroup>
Expand Down
28 changes: 16 additions & 12 deletions app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ define([
* @returns {Multiselect} Chainable.
*/
togglePage: function () {
var total = this.getIds().length,
selected = this.getPageSelections().length;

if (this.isPageSelected() && selected !== total) {
return this.selectPage();
}

return this.isPageSelected() ? this.deselectPage() : this.selectPage();
},

Expand Down Expand Up @@ -308,15 +315,7 @@ define([
* @returns {Multiselect} Chainable.
*/
countSelected: function () {
var total = this.totalRecords(),
excluded = this.excluded().length,
selected = this.selected().length;

if (this.excludeMode()) {
selected = total - excluded;
}

this.totalSelected(selected);
this.totalSelected(this.selected().length);

return this;
},
Expand Down Expand Up @@ -438,13 +437,15 @@ define([
excluded = this.excluded().length,
totalSelected = this.totalSelected(),
totalRecords = this.totalRecords(),
allSelected = totalRecords && totalSelected === totalRecords;
pageTotal = this.getIds().length,
pageSelected = this.getPageSelections().length,
allSelected = totalRecords && pageTotal === pageSelected;

if (this.excludeMode()) {
if (excluded === totalRecords && !this.preserveSelectionsOnFilter) {
this.deselectAll();
}
} else if (totalRecords && selected === totalRecords && !this.preserveSelectionsOnFilter) {
} else if (totalRecords && selected === totalRecords && !this.preserveSelectionsOnFilter && allSelected) {
this.selectAll();
}

Expand Down Expand Up @@ -482,10 +483,13 @@ define([
onRowsChange: function () {
var newSelections;

if (this.excludeMode()) {
if (this.excludeMode() && !this.selected()) {
newSelections = _.union(this.getIds(true), this.selected());

this.selected(newSelections);
} else {
this.updateState();
this.excludeMode(false);
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,20 @@ define([

expect(multiSelect.allSelected()).toBeFalsy();
expect(multiSelect.excluded().toString()).toEqual('');
expect(multiSelect.selected().toString()).toEqual('3,4,1,2');
expect(multiSelect.selected().toString()).toEqual('1,2');
});

it('Select all rows all over the Grid and deselects all records', function () {
multiSelect.rows([{
id: 1
}, {
id: 2
}]);

multiSelect.selectAll();
multiSelect.deselectAll();
multiSelect.indetermine(2);
expect(multiSelect.togglePage().selected()).toEqual([1, 2]);
});

it('Select all rows all over the Grid without all rows on current page but with specific rows on another page',
Expand All @@ -154,7 +167,7 @@ define([
}, {
id: 6
}]);

multiSelect.selectPage();
expect(multiSelect.allSelected()).toBeFalsy();
expect(multiSelect.excluded().toString()).toEqual('3,4');
expect(multiSelect.selected().toString()).toEqual('5,6');
Expand Down