Skip to content

Commit d4fa2c9

Browse files
committed
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular into ha-mutliview-calendar-2
2 parents 08b5093 + 8c707d8 commit d4fa2c9

10 files changed

+322
-697
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

+241-240
Large diffs are not rendered by default.

projects/igniteui-angular/src/lib/grids/grid/grid-row-selection.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,7 @@ describe('IgxGrid - Row Selection #grid', () => {
18751875
}));
18761876
});
18771877

1878-
describe('Custom selectors', () => {
1878+
describe('Custom row selectors', () => {
18791879
let fix;
18801880
let grid;
18811881

@@ -1929,7 +1929,7 @@ describe('IgxGrid - Row Selection #grid', () => {
19291929
fix.detectChanges();
19301930

19311931
const firstRootRow = grid.getRowByIndex(0);
1932-
expect(firstRootRow.nativeElement.querySelector('.rowNumber').textContent).toEqual('30');
1932+
expect(firstRootRow.nativeElement.querySelector('.rowNumber').textContent).toEqual('15');
19331933
});
19341934
});
19351935
});

projects/igniteui-angular/src/lib/grids/grid/grid-row.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<ng-template *ngTemplateOutlet="
1212
this.grid.rowSelectorTemplate ? this.grid.rowSelectorTemplate : rowSelectorBaseTemplate;
1313
context: { $implicit: {
14-
index: (this.grid.groupingExpressions ? this.grid.filteredSortedData.indexOf(this.rowData) : this.index) +
15-
this.grid.page * this.grid.perPage,
14+
index: this.grid.groupingExpressions.length > 0 ? this.grid.filteredSortedData.indexOf(this.rowData) :
15+
this.index + this.grid.page * this.grid.perPage,
1616
rowID: rowID, selected: selected }}">
1717
</ng-template>
1818
</div>

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
context: { $implicit: {
4040
selectedCount: this.selectionService.filteredSelectedRowIds.length,
4141
totalCount: this.totalRowsCountAfterFilter,
42-
selectAll: selectAllRows,
43-
deselectAll: deselectAllRows }}">
42+
selectAll: selectAllRows.bind(this),
43+
deselectAll: deselectAllRows.bind(this) }}">
4444
</ng-template>
4545
</div>
4646
</ng-container>

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.selection.spec.ts

+41-42
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
IgxHierarchicalGridRowSelectionNoTransactionsComponent
1515
} from '../../test-utils/hierarhical-grid-components.spec';
1616
import { IgxRowSelectorsModule } from '../igx-row-selectors.module';
17-
import { HelperUtils } from '../../test-utils/helper-utils.spec';
1817
import { GridSelectionFunctions } from '../../test-utils/grid-functions.spec';
1918
import { GridSelectionMode } from '../common/enums';
2019

@@ -742,7 +741,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
742741
});
743742
});
744743

745-
describe('Custom selectors', () => {
744+
describe('Custom row selectors', () => {
746745
let hGrid;
747746
let firstLevelChild;
748747

@@ -757,109 +756,109 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
757756
it('Row context `select` method selects a single row', () => {
758757
// root grid
759758
const firstRootRow = hGrid.getRowByIndex(0);
760-
HelperUtils.rowCheckboxClick(firstRootRow);
759+
GridSelectionFunctions.clickRowCheckbox(firstRootRow);
761760
fix.detectChanges();
762-
HelperUtils.verifyRowSelected(hGrid.getRowByIndex(0));
763-
HelperUtils.verifyHeaderRowCheckboxState(fix, false, true);
761+
GridSelectionFunctions.verifyRowSelected(hGrid.getRowByIndex(0));
762+
GridSelectionFunctions.verifyHeaderRowCheckboxState(fix, false, true);
764763

765764
// child grid
766-
HelperUtils.expandRowIsland(2);
765+
GridSelectionFunctions.expandRowIsland(2);
767766
fix.detectChanges();
768767

769768
const childGrid = hGrid.hgridAPI.getChildGrids(false)[0];
770769
const childRow = childGrid.getRowByIndex(0);
771-
HelperUtils.rowCheckboxClick(childRow);
770+
GridSelectionFunctions.clickRowCheckbox(childRow);
772771
fix.detectChanges();
773772

774-
HelperUtils.verifyRowSelected(childRow);
775-
HelperUtils.verifyHeaderRowCheckboxState(childGrid, false, true);
773+
GridSelectionFunctions.verifyRowSelected(childRow);
774+
GridSelectionFunctions.verifyHeaderRowCheckboxState(childGrid, false, true);
776775
});
777776

778-
it('Row context `deselect` method deselects an already selected row', () => {
777+
it('Row context `deselect` method deselects an already selected row', fakeAsync(() => {
779778
// root grid
780779
const firstRootRow = hGrid.getRowByIndex(1);
781-
HelperUtils.rowCheckboxClick(firstRootRow);
780+
GridSelectionFunctions.clickRowCheckbox(firstRootRow);
782781
fix.detectChanges();
783-
HelperUtils.verifyRowSelected(firstRootRow);
784-
HelperUtils.verifyHeaderRowCheckboxState(hGrid, false, true);
782+
GridSelectionFunctions.verifyRowSelected(firstRootRow);
783+
GridSelectionFunctions.verifyHeaderRowCheckboxState(hGrid, false, true);
785784

786-
HelperUtils.rowCheckboxClick(firstRootRow);
785+
GridSelectionFunctions.clickRowCheckbox(firstRootRow);
787786
fix.detectChanges();
788-
HelperUtils.verifyRowSelected(firstRootRow, false);
789-
HelperUtils.verifyHeaderRowCheckboxState(hGrid, false, false);
787+
GridSelectionFunctions.verifyRowSelected(firstRootRow, false);
788+
GridSelectionFunctions.verifyHeaderRowCheckboxState(hGrid, false, false);
790789

791790
// child grid
792-
HelperUtils.expandRowIsland(2);
791+
GridSelectionFunctions.expandRowIsland(2);
793792
fix.detectChanges();
794793

795794
const childGrid = hGrid.hgridAPI.getChildGrids(false)[0];
796795
const childRow = childGrid.getRowByIndex(0);
797796

798-
HelperUtils.rowCheckboxClick(childRow);
797+
GridSelectionFunctions.clickRowCheckbox(childRow);
799798
fix.detectChanges();
800-
HelperUtils.verifyRowSelected(childRow);
801-
HelperUtils.verifyHeaderRowCheckboxState(childGrid, false, true);
799+
GridSelectionFunctions.verifyRowSelected(childRow);
800+
GridSelectionFunctions.verifyHeaderRowCheckboxState(childGrid, false, true);
802801

803-
HelperUtils.rowCheckboxClick(childRow);
802+
GridSelectionFunctions.clickRowCheckbox(childRow);
804803
fix.detectChanges();
805-
HelperUtils.verifyRowSelected(childRow, false);
806-
HelperUtils.verifyHeaderRowCheckboxState(childGrid, false, false);
807-
});
804+
GridSelectionFunctions.verifyRowSelected(childRow, false);
805+
GridSelectionFunctions.verifyHeaderRowCheckboxState(childGrid, false, false);
806+
}));
808807

809808
it('Header context `selectAll` method selects all rows', () => {
810809
// root grid
811-
HelperUtils.clickHeaderRowCheckbox(hGrid);
810+
GridSelectionFunctions.clickHeaderRowCheckbox(hGrid);
812811
fix.detectChanges();
813-
HelperUtils.verifyHeaderRowCheckboxState(hGrid, true, false);
812+
GridSelectionFunctions.verifyHeaderRowCheckboxState(hGrid, true, false);
814813
expect(hGrid.selectionService.areAllRowSelected()).toBeTruthy();
815814

816815
// child grid
817-
HelperUtils.expandRowIsland(2);
816+
GridSelectionFunctions.expandRowIsland(2);
818817
fix.detectChanges();
819818

820819
const childGrid = hGrid.hgridAPI.getChildGrids(false)[0];
821-
HelperUtils.clickHeaderRowCheckbox(childGrid);
820+
GridSelectionFunctions.clickHeaderRowCheckbox(childGrid);
822821
fix.detectChanges();
823822

824823
expect(childGrid.selectionService.areAllRowSelected()).toBeTruthy();
825824
});
826825

827826
it('Header context `deselectAll` method deselects all rows', () => {
828827
// root grid
829-
HelperUtils.clickHeaderRowCheckbox(hGrid);
828+
GridSelectionFunctions.clickHeaderRowCheckbox(hGrid);
830829
fix.detectChanges();
831-
HelperUtils.verifyHeaderRowCheckboxState(hGrid, true, false);
830+
GridSelectionFunctions.verifyHeaderRowCheckboxState(hGrid, true, false);
832831
expect(hGrid.selectionService.areAllRowSelected()).toBeTruthy();
833832

834-
HelperUtils.clickHeaderRowCheckbox(hGrid);
833+
GridSelectionFunctions.clickHeaderRowCheckbox(hGrid);
835834
fix.detectChanges();
836-
HelperUtils.verifyHeaderRowCheckboxState(hGrid, false, false);
835+
GridSelectionFunctions.verifyHeaderRowCheckboxState(hGrid, false, false);
837836
expect(hGrid.selectionService.areAllRowSelected()).toBeFalsy();
838837

839838
// child grid
840-
HelperUtils.expandRowIsland(2);
839+
GridSelectionFunctions.expandRowIsland(2);
841840
fix.detectChanges();
842841

843842
const childGrid = hGrid.hgridAPI.getChildGrids(false)[0];
844843

845-
HelperUtils.clickHeaderRowCheckbox(childGrid);
844+
GridSelectionFunctions.clickHeaderRowCheckbox(childGrid);
846845
fix.detectChanges();
847-
HelperUtils.verifyHeaderRowCheckboxState(childGrid, true, false);
846+
GridSelectionFunctions.verifyHeaderRowCheckboxState(childGrid, true, false);
848847
expect(childGrid.selectionService.areAllRowSelected()).toBeTruthy();
849848

850-
HelperUtils.clickHeaderRowCheckbox(childGrid);
849+
GridSelectionFunctions.clickHeaderRowCheckbox(childGrid);
851850
fix.detectChanges();
852-
HelperUtils.verifyHeaderRowCheckboxState(childGrid, false, false);
851+
GridSelectionFunctions.verifyHeaderRowCheckboxState(childGrid, false, false);
853852
expect(childGrid.selectionService.areAllRowSelected()).toBeFalsy();
854853
});
855854

856855
it('Should have the correct properties in the custom row selector header template context', () => {
857856
spyOn(fix.componentInstance, 'handleHeadSelectorClick').and.callThrough();
858857

859-
HelperUtils.headerCheckboxClick(hGrid);
858+
GridSelectionFunctions.headerCheckboxClick(hGrid);
860859
fix.detectChanges();
861860

862-
expect(fix.componentInstance.handleHeadSelectorClick).toHaveBeenCalledWith(new MouseEvent('click'), {
861+
expect(fix.componentInstance.handleHeadSelectorClick).toHaveBeenCalledWith({
863862
selectedCount: 0,
864863
totalCount: hGrid.data.length,
865864
selectAll: jasmine.anything(),
@@ -870,10 +869,10 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
870869
it('Should have the correct properties in the custom row selector template context', () => {
871870
spyOn(fix.componentInstance, 'handleRowSelectorClick').and.callThrough();
872871

873-
HelperUtils.rowCheckboxClick(hGrid.getRowByIndex(1));
872+
GridSelectionFunctions.rowCheckboxClick(hGrid.getRowByIndex(1));
874873
fix.detectChanges();
875874

876-
expect(fix.componentInstance.handleRowSelectorClick).toHaveBeenCalledWith(new MouseEvent('click'), {
875+
expect(fix.componentInstance.handleRowSelectorClick).toHaveBeenCalledWith({
877876
index: 1,
878877
rowID: '1',
879878
selected: false,
@@ -889,7 +888,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
889888
expect(hGrid.getRowByIndex(0).nativeElement.querySelector('.rowNumber').textContent).toEqual('15');
890889

891890
// child grid
892-
HelperUtils.expandRowIsland(3);
891+
GridSelectionFunctions.expandRowIsland(3);
893892
fix.detectChanges();
894893

895894
const childGrid = hGrid.hgridAPI.getChildGrids(false)[0];

projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</igx-date-picker>
2626
</ng-container>
2727
</ng-template>
28-
<ng-container *ngIf="!inEditMode">
28+
<ng-container *ngIf="!editMode">
2929
<ng-container *ngIf="level > 0">
3030
<div #indentationDiv class="igx-grid__tree-cell--padding-level-{{level}}"></div>
3131
</ng-container>

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-selection.spec.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ describe('IgxTreeGrid - Selection #tGrid', () => {
746746
it('should not persist selection after paging', () => {
747747
let rows = TreeGridFunctions.getAllRows(fix);
748748
let treeGridCell = TreeGridFunctions.getTreeCell(rows[0]);
749-
treeGridCell.nativeElement.dispatchEvent(new Event('focus'));
749+
UIInteractions.simulateClickAndSelectCellEvent(treeGridCell);
750750
fix.detectChanges();
751751

752752
expect(treeGrid.selectedCells.length).toBe(1);
@@ -765,7 +765,7 @@ describe('IgxTreeGrid - Selection #tGrid', () => {
765765

766766
rows = TreeGridFunctions.getAllRows(fix);
767767
treeGridCell = TreeGridFunctions.getTreeCell(rows[0]);
768-
treeGridCell.nativeElement.dispatchEvent(new Event('focus'));
768+
UIInteractions.simulateClickAndSelectCellEvent(treeGridCell);
769769
fix.detectChanges();
770770

771771
expect(treeGrid.selectedCells.length).toBe(1);
@@ -784,7 +784,7 @@ describe('IgxTreeGrid - Selection #tGrid', () => {
784784
it('should persist selection after filtering', fakeAsync(() => {
785785
const rows = TreeGridFunctions.getAllRows(fix);
786786
const treeGridCell = TreeGridFunctions.getTreeCell(rows[0]);
787-
treeGridCell.triggerEventHandler('focus', new Event('focus'));
787+
UIInteractions.simulateClickAndSelectCellEvent(treeGridCell);
788788
fix.detectChanges();
789789

790790
treeGrid.filter('ID', '14', IgxStringFilteringOperand.instance().condition('startsWith'), true);
@@ -812,8 +812,7 @@ describe('IgxTreeGrid - Selection #tGrid', () => {
812812

813813
const rows = TreeGridFunctions.getAllRows(fix);
814814
const treeGridCell = TreeGridFunctions.getTreeCell(rows[0]);
815-
treeGridCell.triggerEventHandler('focus', new Event('focus'));
816-
await wait(100);
815+
UIInteractions.simulateClickAndSelectCellEvent(treeGridCell);
817816
fix.detectChanges();
818817

819818
// scroll down 150 pixels
@@ -836,7 +835,7 @@ describe('IgxTreeGrid - Selection #tGrid', () => {
836835
it('should persist selection after sorting', () => {
837836
const rows = TreeGridFunctions.getAllRows(fix);
838837
const treeGridCell = TreeGridFunctions.getTreeCell(rows[0]);
839-
treeGridCell.triggerEventHandler('focus', new Event('focus'));
838+
UIInteractions.simulateClickAndSelectCellEvent(treeGridCell);
840839
fix.detectChanges();
841840

842841
expect(treeGrid.selectedCells.length).toBe(1);
@@ -854,7 +853,7 @@ describe('IgxTreeGrid - Selection #tGrid', () => {
854853
it('should persist selection after row delete', () => {
855854
const rows = TreeGridFunctions.getAllRows(fix);
856855
const treeGridCell = TreeGridFunctions.getTreeCell(rows[0]);
857-
treeGridCell.triggerEventHandler('focus', new Event('focus'));
856+
UIInteractions.simulateClickAndSelectCellEvent(treeGridCell);
858857
fix.detectChanges();
859858

860859
expect(treeGrid.selectedCells.length).toBe(1);
@@ -920,8 +919,7 @@ describe('IgxTreeGrid - Selection #tGrid', () => {
920919

921920
// select a cell
922921
const targetCell = treeGridCells[0];
923-
targetCell.triggerEventHandler('focus', new Event('focus'));
924-
tick(16);
922+
UIInteractions.simulateClickAndSelectCellEvent(targetCell);
925923
fix.detectChanges();
926924

927925
// there should be at least one selected cell

projects/igniteui-angular/src/lib/test-utils/grid-functions.spec.ts

+19
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const HEADER_ROW_CSS_CLASS = '.igx-grid__thead';
3333
const CHECKBOX_INPUT_CSS_CLASS = '.igx-checkbox__input';
3434
const SCROLL_START_CSS_CLASS = '.igx-grid__scroll-start';
3535
const CHECKBOX_ELEMENT = 'igx-checkbox';
36+
const ICON_CSS_CLASS = 'material-icons igx-icon';
37+
const CHECKBOX_LBL_CSS_CLASS = '.igx-checkbox__composite';
3638
const DEBOUNCETIME = 50;
3739

3840
export class GridFunctions {
@@ -1741,4 +1743,21 @@ export class GridSelectionFunctions {
17411743
const checkboxElement = GridSelectionFunctions.getRowCheckboxDiv(GridSelectionFunctions.getHeaderRow(parent));
17421744
checkboxElement.dispatchEvent(new Event('click', {}));
17431745
}
1746+
1747+
// select - deselect a checkbox without a handler
1748+
public static rowCheckboxClick(row) {
1749+
const checkboxElement = row.nativeElement ?
1750+
row.nativeElement.querySelector(CHECKBOX_LBL_CSS_CLASS) :
1751+
row.querySelector(CHECKBOX_LBL_CSS_CLASS);
1752+
checkboxElement.click();
1753+
}
1754+
1755+
public static headerCheckboxClick(parent) {
1756+
GridSelectionFunctions.rowCheckboxClick(GridSelectionFunctions.getHeaderRow(parent));
1757+
}
1758+
//
1759+
1760+
public static expandRowIsland(rowNumber = 1) {
1761+
(<any>document.getElementsByClassName(ICON_CSS_CLASS)[rowNumber]).click();
1762+
}
17441763
}

0 commit comments

Comments
 (0)