Skip to content

Commit cf90992

Browse files
author
Sergii Kovalenko
committed
MAGETWO-63321: Issue when deleting item from Product options grid containing more than 20 options
1 parent 787a46b commit cf90992

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ define([
270270
*/
271271
deleteHandler: function (index, id) {
272272
var defaultState;
273+
273274
this.setDefaultState();
274275
defaultState = this.defaultPagesState[this.currentPage()];
275276
this.processingDeleteRecord(index, id);
@@ -725,6 +726,7 @@ define([
725726
}
726727

727728
this.initChildren();
729+
728730
return true;
729731
},
730732

@@ -876,7 +878,13 @@ define([
876878
this._sort();
877879
},
878880

879-
_reducePages: function() {
881+
/**
882+
* Reduce the number of pages
883+
*
884+
* @private
885+
* @return void
886+
*/
887+
_reducePages: function () {
880888
if (this.pages() < ~~this.currentPage()) {
881889
this.currentPage(this.pages());
882890
}

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dynamic-rows/dynamic.rows.test.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,28 @@ define([
1212
var model,
1313
ElementMock = function (index) {
1414
return {
15-
destroy: function () {},
15+
destroy: new Function (),
1616
index: index
1717
};
1818
};
1919

20-
beforeEach(function(done) {
20+
/**
21+
* Run before each test method
22+
*
23+
* @return void
24+
*/
25+
beforeEach(function (done) {
2126
model = new DynamicRows({});
2227
done();
2328
});
2429

30+
/**
31+
* Testing changePage and delete record methods
32+
*
33+
* @return void
34+
*/
2535
describe('Magento_Ui/js/dynamic-rows/dynamic-rows', function () {
26-
it('changePage without Records', function() {
36+
it('changePage without Records', function () {
2737
model.recordData = function () {
2838
return {
2939
length: 0
@@ -33,21 +43,27 @@ define([
3343
expect(model.changePage(1)).toBeFalsy();
3444
});
3545

36-
it('changePage with Fake Page', function() {
46+
it('changePage with Fake Page', function () {
3747
model.pages = function () {
3848
return 3;
3949
};
4050

4151
expect(model.changePage(4)).toBeFalsy();
4252
});
4353

44-
it('changePage', function() {
54+
it('changePage', function () {
4555
model.startIndex = 0;
4656
model.pageSize = 3;
4757
model.relatedData = [
48-
{"a": "b"},
49-
{"b": "c"},
50-
{"v": "g"}
58+
{
59+
'a': 'b'
60+
},
61+
{
62+
'b': 'c'
63+
},
64+
{
65+
'v': 'g'
66+
}
5167
];
5268

5369
model.pages = function () {
@@ -62,7 +78,8 @@ define([
6278
var elems,
6379
recordInstanceMock = new ElementMock(1),
6480
elem2 = new ElementMock(2);
65-
spyOn(recordInstanceMock, "destroy");
81+
82+
spyOn(recordInstanceMock, 'destroy');
6683
model.recordData({1: {}});
6784
elems = [
6885
recordInstanceMock,

0 commit comments

Comments
 (0)