@@ -628,7 +628,134 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
628
628
expect ( pivotGrid . pivotConfiguration . values . map ( x => x . member ) ) . toEqual ( [ 'UnitPrice' , 'UnitsSold' ] ) ;
629
629
630
630
} ) ;
631
- // fit('should allow moving dimension between rows, columns and filters.', () => {});
631
+ it ( 'should allow moving dimension between rows, columns and filters.' , ( ) => {
632
+ const pivotGrid = fixture . componentInstance . pivotGrid ;
633
+ pivotGrid . pivotConfiguration . filters = [ {
634
+ memberName : 'SellerName' ,
635
+ enabled : true
636
+ } ] ;
637
+ fixture . detectChanges ( ) ;
638
+ const headerRow : IgxPivotHeaderRowComponent = fixture . debugElement . query ( By . directive ( IgxPivotHeaderRowComponent ) ) . componentInstance ;
639
+ const chipAreas = fixture . debugElement . queryAll ( By . directive ( IgxChipsAreaComponent ) ) ;
640
+ const colChipArea : IgxChipsAreaComponent = chipAreas [ 1 ] . componentInstance ;
641
+ const rowChipArea : IgxChipsAreaComponent = chipAreas [ 3 ] . componentInstance ;
642
+ const filterChipArea : IgxChipsAreaComponent = chipAreas [ 0 ] . componentInstance ;
643
+ const filterChip = filterChipArea . chipsList . first ;
644
+ // start drag in filter chip area.
645
+ headerRow . onDimDragStart ( { } , filterChipArea ) ;
646
+ fixture . detectChanges ( ) ;
647
+
648
+ // check drop here chips are displayed in other areas
649
+ expect ( headerRow . notificationChips . toArray ( ) [ 1 ] . nativeElement . hidden ) . toBeFalse ( ) ;
650
+ expect ( headerRow . notificationChips . toArray ( ) [ 2 ] . nativeElement . hidden ) . toBeFalse ( ) ;
651
+
652
+ const dropHereRowChip = headerRow . notificationChips . toArray ( ) [ 2 ] ;
653
+ // move Seller onto the drop here chip
654
+
655
+ // drop chip
656
+ headerRow . onDimDrop ( {
657
+ dragChip : filterChip ,
658
+ owner : dropHereRowChip
659
+ } , rowChipArea , PivotDimensionType . Row ) ;
660
+ pivotGrid . cdr . detectChanges ( ) ;
661
+
662
+ // check dimensions
663
+ expect ( pivotGrid . pivotConfiguration . filters . filter ( x => x . enabled ) . length ) . toBe ( 0 ) ;
664
+ expect ( pivotGrid . pivotConfiguration . rows . filter ( x => x . enabled ) . length ) . toBe ( 2 ) ;
665
+
666
+ const rowSellerChip = rowChipArea . chipsList . toArray ( ) [ 1 ] ;
667
+ const colChip = colChipArea . chipsList . first ;
668
+ // start drag in row chip area.
669
+ headerRow . onDimDragStart ( { } , rowChipArea ) ;
670
+ fixture . detectChanges ( ) ;
671
+
672
+ // drag Seller from row dimension as first chip in columns
673
+ headerRow . onDimDragOver ( {
674
+ dragChip : rowSellerChip ,
675
+ owner : colChip ,
676
+ originalEvent : {
677
+ offsetX : 0
678
+ }
679
+ } , PivotDimensionType . Column ) ;
680
+ fixture . detectChanges ( ) ;
681
+ //check drop indicator between chips
682
+ expect ( ( colChip . nativeElement . previousElementSibling as any ) . style . visibility ) . toBe ( '' ) ;
683
+ expect ( ( colChip . nativeElement . nextElementSibling as any ) . style . visibility ) . toBe ( 'hidden' ) ;
684
+
685
+ // drop chip
686
+ headerRow . onDimDrop ( {
687
+ dragChip : rowSellerChip ,
688
+ owner : colChip
689
+ } , colChipArea , PivotDimensionType . Column ) ;
690
+ pivotGrid . cdr . detectChanges ( ) ;
691
+
692
+ // check dimensions
693
+ expect ( pivotGrid . pivotConfiguration . filters . filter ( x => x . enabled ) . length ) . toBe ( 0 ) ;
694
+ expect ( pivotGrid . pivotConfiguration . rows . filter ( x => x . enabled ) . length ) . toBe ( 1 ) ;
695
+ expect ( pivotGrid . pivotConfiguration . columns . filter ( x => x . enabled ) . length ) . toBe ( 2 ) ;
696
+
697
+ // drag Seller over filter area
698
+ const colSellerChip = colChipArea . chipsList . toArray ( ) [ 0 ] ;
699
+ // start drag in col chip area.
700
+ headerRow . onDimDragStart ( { } , colChipArea ) ;
701
+ // drop chip
702
+ headerRow . onDimDrop ( {
703
+ dragChip : colSellerChip ,
704
+ owner : { }
705
+ } , filterChipArea , PivotDimensionType . Filter ) ;
706
+ pivotGrid . cdr . detectChanges ( ) ;
707
+
708
+ expect ( pivotGrid . pivotConfiguration . filters . filter ( x => x . enabled ) . length ) . toBe ( 1 ) ;
709
+ expect ( pivotGrid . pivotConfiguration . rows . filter ( x => x . enabled ) . length ) . toBe ( 1 ) ;
710
+ expect ( pivotGrid . pivotConfiguration . columns . filter ( x => x . enabled ) . length ) . toBe ( 1 ) ;
711
+ } ) ;
712
+
713
+ it ( 'should hide drop indicators when moving out of the drop area.' , ( ) => {
714
+ const pivotGrid = fixture . componentInstance . pivotGrid ;
715
+ pivotGrid . pivotConfiguration . rows = [
716
+ {
717
+ memberName : 'ProductCategory' ,
718
+ enabled : true
719
+ } ,
720
+ {
721
+ memberName : 'SellerName' ,
722
+ enabled : true
723
+ }
724
+ ] ;
725
+ pivotGrid . pipeTrigger ++ ;
726
+ pivotGrid . setupColumns ( ) ;
727
+ fixture . detectChanges ( ) ;
728
+
729
+ const headerRow : IgxPivotHeaderRowComponent = fixture . debugElement . query ( By . directive ( IgxPivotHeaderRowComponent ) ) . componentInstance ;
730
+ const chipAreas = fixture . debugElement . queryAll ( By . directive ( IgxChipsAreaComponent ) ) ;
731
+ const rowChipArea : IgxChipsAreaComponent = chipAreas [ 3 ] . componentInstance ;
732
+ const rowChip1 = rowChipArea . chipsList . toArray ( ) [ 0 ] ;
733
+ const rowChip2 = rowChipArea . chipsList . toArray ( ) [ 1 ] ;
734
+
735
+ // start drag in row chip area.
736
+ headerRow . onDimDragStart ( { } , rowChipArea ) ;
737
+ fixture . detectChanges ( ) ;
738
+
739
+ // drag second chip before prev chip
740
+ headerRow . onDimDragOver ( {
741
+ dragChip : rowChip2 ,
742
+ owner : rowChip1 ,
743
+ originalEvent : {
744
+ offsetX : 0
745
+ }
746
+ } , PivotDimensionType . Row ) ;
747
+ fixture . detectChanges ( ) ;
748
+
749
+ // should show the prev drop indicator for the 1st chip
750
+ expect ( ( rowChip1 . nativeElement . previousElementSibling as any ) . style . visibility ) . toBe ( '' ) ;
751
+ expect ( ( rowChip1 . nativeElement . nextElementSibling as any ) . style . visibility ) . toBe ( 'hidden' ) ;
752
+
753
+ // simulate drag area leave
754
+ headerRow . onAreaDragLeave ( { } , rowChipArea ) ;
755
+
756
+ expect ( ( rowChip1 . nativeElement . previousElementSibling as any ) . style . visibility ) . toBe ( 'hidden' ) ;
757
+ expect ( ( rowChip1 . nativeElement . nextElementSibling as any ) . style . visibility ) . toBe ( 'hidden' ) ;
758
+ } ) ;
632
759
} ) ;
633
760
} ) ;
634
761
0 commit comments