diff --git a/drone-pr-workaround.sh b/drone-pr-workaround.sh old mode 100755 new mode 100644 diff --git a/js/ui/collection/ui.collection_widget.edit.js b/js/ui/collection/ui.collection_widget.edit.js index bddacbe0b3e2..d0a4faddc97f 100644 --- a/js/ui/collection/ui.collection_widget.edit.js +++ b/js/ui/collection/ui.collection_widget.edit.js @@ -197,6 +197,10 @@ var CollectionWidget = BaseCollectionWidget.inherit({ return !!(this._dataSource && this._dataSource.key()); }, + _getCombinedFilter: function() { + return this._dataSource && this._dataSource.filter(); + }, + keyOf: function(item) { var key = item, store = this._dataSource && this._dataSource.store(); @@ -224,9 +228,7 @@ var CollectionWidget = BaseCollectionWidget.inherit({ that._updateSelectedItems(args.addedItems, args.removedItems); } }, - filter: function() { - return that._dataSource && that._dataSource.filter(); - }, + filter: that._getCombinedFilter.bind(that), totalCount: function() { var items = that.option("items"); var dataSource = that._dataSource; @@ -573,7 +575,10 @@ var CollectionWidget = BaseCollectionWidget.inherit({ } break; case "dataSource": - this.option("selectedItemKeys", []); + if(!args.value || !args.value.length) { + this.option("selectedItemKeys", []); + } + this.callBase(args); break; case "selectedIndex": diff --git a/js/ui/list/ui.list.edit.js b/js/ui/list/ui.list.edit.js index b001528f5b43..423f9be821e3 100644 --- a/js/ui/list/ui.list.edit.js +++ b/js/ui/list/ui.list.edit.js @@ -275,6 +275,20 @@ var ListEdit = ListBase.inherit({ } }, + _getCombinedFilter: function() { + var filter, + storeLoadOptions, + dataSource = this._dataSource; + + if(dataSource) { + storeLoadOptions = { filter: dataSource.filter() }; + dataSource._addSearchFilter(storeLoadOptions); + filter = storeLoadOptions.filter; + } + + return filter; + }, + _isPageSelectAll: function() { return this.option("selectAllMode") === "page"; }, diff --git a/testing/tests/DevExpress.ui.widgets/listParts/editingTests.js b/testing/tests/DevExpress.ui.widgets/listParts/editingTests.js index 6c109d17a573..7488f07c2ebc 100644 --- a/testing/tests/DevExpress.ui.widgets/listParts/editingTests.js +++ b/testing/tests/DevExpress.ui.widgets/listParts/editingTests.js @@ -505,6 +505,42 @@ QUnit.test("selection works well after clean all selected items and selectAllMod assert.equal(selectionChangedSpy.callCount, 3, "'selectionChanged' event has been fired 3 times"); }); +//T567757 +QUnit.test("Selecting all filtered items when selectAllMode is 'allPages'", function(assert) { + //arrange + var items = [1, 2, 3, 4, 5], + $selectAll, + ds = new DataSource({ + store: items, + pageSize: 2, + paginate: true, + searchValue: "1" + }); + + var instance = $("#list").dxList({ + dataSource: ds, + showSelectionControls: true, + selectionMode: "all", + selectAllMode: "allPages" + }).dxList("instance"); + + //act + instance.selectItem(0); + + //assert + $selectAll = $("#list").find(".dx-list-select-all-checkbox"); + assert.ok($selectAll.hasClass("dx-checkbox-checked"), "selectAll checkbox is checked"); + assert.deepEqual(instance.option("selectedItems"), [1], "selected items"); + + //act + ds.searchValue(""); + ds.load(); + + //assert + $selectAll = $("#list").find(".dx-list-select-all-checkbox"); + assert.ok($selectAll.hasClass("dx-checkbox-indeterminate"), "selectAll checkbox is indeterminate"); +}); + var LIST_ITEM_SELECTED_CLASS = "dx-list-item-selected"; QUnit.module("selecting in grouped list", { diff --git a/testing/tests/DevExpress.ui/collectionWidgetParts/editingTests.js b/testing/tests/DevExpress.ui/collectionWidgetParts/editingTests.js index f4c2c8c53225..e3b390137c01 100644 --- a/testing/tests/DevExpress.ui/collectionWidgetParts/editingTests.js +++ b/testing/tests/DevExpress.ui/collectionWidgetParts/editingTests.js @@ -551,7 +551,7 @@ var runTests = function() { } }); - QUnit.test("selectedItems should be cleared if datasource instance has been changed", function(assert) { + QUnit.test("selectedItems should be cleared if datasource instance has been changed to null", function(assert) { var instance = new TestComponent($("
"), { selectionMode: "multiple", dataSource: [1, 2, 3], @@ -569,6 +569,42 @@ var runTests = function() { assert.deepEqual(instance.option("selectedItemKeys"), [], "selectedItemKeys was cleared"); }); + QUnit.test("selectedItems should be cleared if datasource instance has been changed to empty array", function(assert) { + var instance = new TestComponent($("
"), { + selectionMode: "multiple", + dataSource: [1, 2, 3], + selectedItemKeys: [1, 2] + }); + + assert.deepEqual(instance.option("selectedItems"), [1, 2], "selectedItems is correct"); + assert.deepEqual(instance.option("selectedItem"), 1, "selectedItem is correct"); + assert.deepEqual(instance.option("selectedItemKeys"), [1, 2], "selectedItem is correct"); + + instance.option("dataSource", []); + + assert.deepEqual(instance.option("selectedItems"), [], "selectedItems was cleared"); + assert.strictEqual(instance.option("selectedItem"), undefined, "selectedItem was cleared"); + assert.deepEqual(instance.option("selectedItemKeys"), [], "selectedItemKeys was cleared"); + }); + + QUnit.test("selectedItems should not be cleared if datasource instance has been changed", function(assert) { + var instance = new TestComponent($("
"), { + selectionMode: "multiple", + dataSource: [1, 2, 3], + selectedItemKeys: [1, 2] + }); + + assert.deepEqual(instance.option("selectedItems"), [1, 2], "selectedItems is correct"); + assert.deepEqual(instance.option("selectedItem"), 1, "selectedItem is correct"); + assert.deepEqual(instance.option("selectedItemKeys"), [1, 2], "selectedItem is correct"); + + instance.option("dataSource", [1, 2, 3, 4]); + + assert.deepEqual(instance.option("selectedItems"), [1, 2], "selectedItems wasn't cleared"); + assert.strictEqual(instance.option("selectedItem"), 1, "selectedItem wasn't cleared"); + assert.deepEqual(instance.option("selectedItemKeys"), [1, 2], "selectedItemKeys wasn't cleared"); + }); + QUnit.module("selecting of item keys", { beforeEach: function() {