@@ -41,7 +41,8 @@ describe('IgxGridState - input properties #grid', () => {
41
41
rowSelection : true ,
42
42
columnSelection : true ,
43
43
rowPinning : true ,
44
- expansion : true
44
+ expansion : true ,
45
+ moving : true
45
46
} ;
46
47
47
48
const fix = TestBed . createComponent ( IgxGridStateComponent ) ;
@@ -66,6 +67,7 @@ describe('IgxGridState - input properties #grid', () => {
66
67
rowPinning : true ,
67
68
expansion : true ,
68
69
groupBy : false ,
70
+ moving : false
69
71
} ;
70
72
71
73
const fix = TestBed . createComponent ( IgxGridStateWithOptionsComponent ) ;
@@ -76,7 +78,7 @@ describe('IgxGridState - input properties #grid', () => {
76
78
} ) ;
77
79
78
80
it ( 'getState should return correct JSON string' , ( ) => {
79
- const initialGridState = '{"columns":[{"pinned":true,"sortable":true,"filterable":true,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"testCss","headerGroupClasses":"","maxWidth":"300px","groupable":false,"movable":false,"hidden":false,"dataType":"number","hasSummary":false,"field":"ProductID","width":"150px","header":"Product ID","resizable":true,"searchable":false,"parent":null,"columnGroup":false,"disableHiding":false},{"pinned":false,"sortable":true,"filterable":true,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","maxWidth":"300px","groupable":true,"movable":false,"hidden":false,"dataType":"string","hasSummary":false,"field":"ProductName","width":"150px","header":"Prodyct Name","resizable":true,"searchable":true,"selectable":false,"parent":null,"columnGroup":false,"disableHiding":false},{"pinned":false,"sortable":false,"filterable":true,"editable":true,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","maxWidth":"300px","groupable":false,"movable":false,"hidden":false,"dataType":"boolean","hasSummary":true,"field":"InStock","width":"140px","header":"In Stock","resizable":true,"searchable":true,"parent":null,"columnGroup":false,"disableHiding":false},{"pinned":false,"sortable":true,"filterable":false,"editable":true,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","maxWidth":"300px","groupable":true,"movable":false,"hidden":false,"dataType":"date","hasSummary":false,"field":"OrderDate","width":"110px","header":"Date ordered","resizable":false,"searchable":true,"parent":null,"columnGroup":false,"disableHiding":false}],"filtering":{"filteringOperands":[],"operator":0},"advancedFiltering":{},"sorting":[],"groupBy":{"expressions":[],"expansion":[],"defaultExpanded":true},"paging":{"index":0,"recordsPerPage":15,"metadata":{"countPages":1,"countRecords":10,"error":0}},"cellSelection":[],"rowSelection":[],"columnSelection":[],"rowPinning":[],"expansion":[]}' ;
81
+ const initialGridState = '{"columns":[{"pinned":true,"sortable":true,"filterable":true,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"testCss","headerGroupClasses":"","maxWidth":"300px","groupable":false,"movable":false,"hidden":false,"dataType":"number","hasSummary":false,"field":"ProductID","width":"150px","header":"Product ID","resizable":true,"searchable":false,"parent":null,"columnGroup":false,"disableHiding":false},{"pinned":false,"sortable":true,"filterable":true,"editable":false,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","maxWidth":"300px","groupable":true,"movable":false,"hidden":false,"dataType":"string","hasSummary":false,"field":"ProductName","width":"150px","header":"Prodyct Name","resizable":true,"searchable":true,"selectable":false,"parent":null,"columnGroup":false,"disableHiding":false},{"pinned":false,"sortable":false,"filterable":true,"editable":true,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","maxWidth":"300px","groupable":false,"movable":false,"hidden":false,"dataType":"boolean","hasSummary":true,"field":"InStock","width":"140px","header":"In Stock","resizable":true,"searchable":true,"parent":null,"columnGroup":false,"disableHiding":false},{"pinned":false,"sortable":true,"filterable":false,"editable":true,"sortingIgnoreCase":true,"filteringIgnoreCase":true,"headerClasses":"","headerGroupClasses":"","maxWidth":"300px","groupable":true,"movable":false,"hidden":false,"dataType":"date","hasSummary":false,"field":"OrderDate","width":"110px","header":"Date ordered","resizable":false,"searchable":true,"parent":null,"columnGroup":false,"disableHiding":false}],"filtering":{"filteringOperands":[],"operator":0},"advancedFiltering":{},"sorting":[],"groupBy":{"expressions":[],"expansion":[],"defaultExpanded":true},"paging":{"index":0,"recordsPerPage":15,"metadata":{"countPages":1,"countRecords":10,"error":0}},"cellSelection":[],"rowSelection":[],"columnSelection":[],"rowPinning":[],"expansion":[],"moving":true}' ;
80
82
const fix = TestBed . createComponent ( IgxGridStateComponent ) ;
81
83
fix . detectChanges ( ) ;
82
84
@@ -115,6 +117,7 @@ describe('IgxGridState - input properties #grid', () => {
115
117
116
118
const columns = fix . componentInstance . columns ;
117
119
const paging = grid . pagingState ;
120
+ const moving = grid . moving ;
118
121
const sorting = grid . sortingExpressions ;
119
122
const groupBy = grid . groupingExpressions ;
120
123
const groupByExpansion = grid . groupingExpansionState ;
@@ -127,6 +130,7 @@ describe('IgxGridState - input properties #grid', () => {
127
130
HelperFunctions . verifyGroupingExpressions ( groupBy , gridState ) ;
128
131
HelperFunctions . verifyGroupingExpansion ( groupByExpansion , gridState . groupBy ) ;
129
132
HelperFunctions . verifyFilteringExpressions ( filtering , gridState ) ;
133
+ HelperFunctions . verifyMoving ( moving , gridState ) ;
130
134
} ) ;
131
135
132
136
it ( 'getState should return corect IGridState object when options are not default' , ( ) => {
@@ -137,10 +141,12 @@ describe('IgxGridState - input properties #grid', () => {
137
141
let gridState = state . getState ( false ) as IGridState ;
138
142
expect ( gridState [ 'sorting' ] ) . toBeFalsy ( ) ;
139
143
expect ( gridState [ 'groupBy' ] ) . toBeFalsy ( ) ;
144
+ expect ( gridState [ 'moving' ] ) . toBeFalsy ( ) ;
140
145
141
- gridState = state . getState ( false , [ 'filtering' , 'sorting' , 'groupBy' ] ) as IGridState ;
146
+ gridState = state . getState ( false , [ 'filtering' , 'sorting' , 'groupBy' , 'moving' ] ) as IGridState ;
142
147
expect ( gridState [ 'sorting' ] ) . toBeFalsy ( ) ;
143
148
expect ( gridState [ 'groupBy' ] ) . toBeFalsy ( ) ;
149
+ expect ( gridState [ 'groupBy' ] ) . toBeFalsy ( ) ;
144
150
} ) ;
145
151
146
152
it ( 'getState should return corect filtering state' , ( ) => {
@@ -437,6 +443,55 @@ describe('IgxGridState - input properties #grid', () => {
437
443
expect ( grid . pinnedRows [ 0 ] . key ) . toBe ( 1 ) ;
438
444
expect ( grid . pinnedRows [ 1 ] . key ) . toBe ( 3 ) ;
439
445
} ) ;
446
+
447
+ it ( 'setState should correctly restore grid moving state from string' , ( ) => {
448
+ const fix = TestBed . createComponent ( IgxGridStateComponent ) ;
449
+ fix . detectChanges ( ) ;
450
+ const grid = fix . componentInstance . grid ;
451
+ const state = fix . componentInstance . state ;
452
+
453
+ const movingState = '{"moving":false}' ;
454
+ const initialState = '{"moving":true}' ;
455
+
456
+ let gridState = state . getState ( true , 'moving' ) ;
457
+ expect ( gridState ) . toBe ( initialState ) ;
458
+
459
+ state . setState ( movingState ) ;
460
+ expect ( grid . moving ) . toBeFalsy ( ) ;
461
+ gridState = state . getState ( true , 'moving' ) ;
462
+ expect ( gridState ) . toBe ( movingState ) ;
463
+
464
+ } ) ;
465
+
466
+ it ( 'setState should correctly restore grid moving state from object' , ( ) => {
467
+ const fix = TestBed . createComponent ( IgxGridStateComponent ) ;
468
+ fix . detectChanges ( ) ;
469
+ const grid = fix . componentInstance . grid ;
470
+ const state = fix . componentInstance . state ;
471
+ const movingState = '{"moving":false}' ;
472
+ const initialState = '{"moving":true}' ;
473
+ const movingStateObject = JSON . parse ( movingState ) ;
474
+
475
+ let gridState = state . getState ( true , 'moving' ) ;
476
+ expect ( gridState ) . toBe ( initialState ) ;
477
+
478
+ state . setState ( movingStateObject ) ;
479
+ fix . detectChanges ( ) ;
480
+
481
+ expect ( grid . moving ) . toBeFalsy ( ) ;
482
+ gridState = state . getState ( true , 'moving' ) ;
483
+ expect ( gridState ) . toBe ( movingState ) ;
484
+
485
+ grid . moving = true ;
486
+ fix . detectChanges ( ) ;
487
+
488
+ state . setState ( movingStateObject ) ;
489
+ fix . detectChanges ( ) ;
490
+
491
+ expect ( grid . moving ) . toBeFalsy ( ) ;
492
+ gridState = state . getState ( true , 'moving' ) ;
493
+ expect ( gridState ) . toBe ( movingState ) ;
494
+ } ) ;
440
495
441
496
it ( 'setState should correctly restore grid cell selection state from string' , ( ) => {
442
497
const fix = TestBed . createComponent ( IgxGridStateComponent ) ;
@@ -586,6 +641,10 @@ class HelperFunctions {
586
641
expect ( paging ) . toEqual ( jasmine . objectContaining ( gridState . paging ) ) ;
587
642
}
588
643
644
+ public static verifyMoving ( moving : boolean , gridState : IGridState ) {
645
+ expect ( moving ) . toEqual ( gridState . moving ) ;
646
+ }
647
+
589
648
public static verifyRowSelection ( selectedRows : any [ ] , gridState : IGridState ) {
590
649
gridState . rowSelection . forEach ( ( s , index ) => {
591
650
expect ( s ) . toBe ( selectedRows [ index ] ) ;
@@ -608,7 +667,7 @@ class HelperFunctions {
608
667
609
668
@Component ( {
610
669
template : `
611
- <igx-grid #grid [data]="data" [autoGenerate]="false" igxGridState rowSelection="multiple"
670
+ <igx-grid #grid [data]="data" [autoGenerate]="false" [moving]="true" igxGridState rowSelection="multiple"
612
671
cellSelection="multiple" primaryKey="ProductID">
613
672
<igx-column *ngFor="let c of columns"
614
673
[width]="c.width"
@@ -673,7 +732,8 @@ export class IgxGridStateWithOptionsComponent {
673
732
filtering : false ,
674
733
advancedFiltering : true ,
675
734
sorting : false ,
676
- groupBy : false
735
+ groupBy : false ,
736
+ moving : false
677
737
} ;
678
738
}
679
739
0 commit comments