Skip to content

Commit 367e740

Browse files
author
Sergii Kovalenko
committed
MAGETWO-63321: Issue when deleting item from Product options grid containing more than 20 options
1 parent 896e10f commit 367e740

File tree

2 files changed

+59
-4
lines changed

2 files changed

+59
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,6 @@ define([
633633
getChildItems: function (data, page) {
634634
var dataRecord = data || this.relatedData,
635635
startIndex;
636-
637636
this.startIndex = (~~this.currentPage() - 1) * this.pageSize;
638637

639638
startIndex = page || this.startIndex;
@@ -672,9 +671,8 @@ define([
672671
this.bubble('addChild', false);
673672

674673
if (this.relatedData.length && this.relatedData.length % this.pageSize === 0) {
675-
this.clear();
676674
this.pages(this.pages() + 1);
677-
this.currentPage(this.pages());
675+
this.nextPage();
678676
} else if (~~this.currentPage() !== this.pages()) {
679677
this.currentPage(this.pages());
680678
}
@@ -717,8 +715,8 @@ define([
717715
return false;
718716
}
719717

720-
this.clear();
721718
this.initChildren();
719+
return true;
722720
},
723721

724722
/**
@@ -743,13 +741,15 @@ define([
743741
* Change page to next
744742
*/
745743
nextPage: function () {
744+
this.clear();
746745
this.currentPage(this.currentPage() + 1);
747746
},
748747

749748
/**
750749
* Change page to previous
751750
*/
752751
previousPage: function () {
752+
this.clear();
753753
this.currentPage(this.currentPage() - 1);
754754
},
755755

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/* eslint-disable max-nested-callbacks */
7+
define([
8+
'Magento_Ui/js/dynamic-rows/dynamic-rows'
9+
], function (DynamicRows) {
10+
'use strict';
11+
12+
var model;
13+
14+
beforeEach(function(done) {
15+
model = new DynamicRows({});
16+
done();
17+
});
18+
19+
describe('Magento_Ui/js/dynamic-rows/dynamic-rows', function () {
20+
it('changePage without Records', function() {
21+
model.recordData = function () {
22+
return {
23+
length: 0
24+
};
25+
};
26+
27+
expect(model.changePage(1)).toBeFalsy();
28+
});
29+
30+
it('changePage with Fake Page', function() {
31+
model.pages = function () {
32+
return 3;
33+
};
34+
35+
expect(model.changePage(4)).toBeFalsy();
36+
});
37+
38+
it('changePage', function() {
39+
model.startIndex = 0;
40+
model.pageSize = 3;
41+
model.relatedData = [
42+
{"a": "b"},
43+
{"b": "c"},
44+
{"v": "g"}
45+
];
46+
47+
model.pages = function () {
48+
return 3;
49+
};
50+
model.changePage(2);
51+
52+
expect(model.templates.record.recordId).toBe(2);//last record number is 3
53+
});
54+
});
55+
});

0 commit comments

Comments
 (0)