File tree Expand file tree Collapse file tree 2 files changed +59
-4
lines changed
app/code/Magento/Ui/view/base/web/js/dynamic-rows
dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dynamic-rows Expand file tree Collapse file tree 2 files changed +59
-4
lines changed Original file line number Diff line number Diff line change @@ -633,7 +633,6 @@ define([
633
633
getChildItems : function ( data , page ) {
634
634
var dataRecord = data || this . relatedData ,
635
635
startIndex ;
636
-
637
636
this . startIndex = ( ~ ~ this . currentPage ( ) - 1 ) * this . pageSize ;
638
637
639
638
startIndex = page || this . startIndex ;
@@ -672,9 +671,8 @@ define([
672
671
this . bubble ( 'addChild' , false ) ;
673
672
674
673
if ( this . relatedData . length && this . relatedData . length % this . pageSize === 0 ) {
675
- this . clear ( ) ;
676
674
this . pages ( this . pages ( ) + 1 ) ;
677
- this . currentPage ( this . pages ( ) ) ;
675
+ this . nextPage ( ) ;
678
676
} else if ( ~ ~ this . currentPage ( ) !== this . pages ( ) ) {
679
677
this . currentPage ( this . pages ( ) ) ;
680
678
}
@@ -717,8 +715,8 @@ define([
717
715
return false ;
718
716
}
719
717
720
- this . clear ( ) ;
721
718
this . initChildren ( ) ;
719
+ return true ;
722
720
} ,
723
721
724
722
/**
@@ -743,13 +741,15 @@ define([
743
741
* Change page to next
744
742
*/
745
743
nextPage : function ( ) {
744
+ this . clear ( ) ;
746
745
this . currentPage ( this . currentPage ( ) + 1 ) ;
747
746
} ,
748
747
749
748
/**
750
749
* Change page to previous
751
750
*/
752
751
previousPage : function ( ) {
752
+ this . clear ( ) ;
753
753
this . currentPage ( this . currentPage ( ) - 1 ) ;
754
754
} ,
755
755
Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments