Skip to content

Commit 764034c

Browse files
committed
chore(*): Add CHANGELOG and some tests
1 parent 29bb460 commit 764034c

File tree

3 files changed

+197
-0
lines changed

3 files changed

+197
-0
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ All notable changes for each version of this project will be documented in this
2020
### New Features
2121
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
2222
- When triggering an export of the grid via the toolbar and the export takes more than 500 milliseconds, the export button becomes disabled and an indeterminate progress bar is shown at the bottom of the toolbar until the export is finished.
23+
- Added ability to spawn row adding UI through exoposed methods. Note that rowEditing should be enabled.
24+
- `beginAddRow` method which starts the adding row UI.
25+
- `beginAddChild` method which starts the adding child UI.
26+
```typescript
27+
this.grid.beginAddRow(rowID);
28+
```
29+
- Added an input properties to `IgxGridEditingActions` component to show/hide add row and add child buttons which trigger the UI based on context expression.
30+
```html
31+
<igx-tree-grid [rowEditing]="true">
32+
<igx-action-strip #actionStrip>
33+
<igx-grid-editing-actions [addRow]="true" [addChild]="actionStrip.context.level < 3">
34+
</igx-grid-editing-actions>
35+
</igx-action-strip>
36+
</igx-tree-grid>
37+
```
2338
- ` IGX_INPUT_GROUP_TYPE` injection token
2439
- Allows for setting an input group `type` on a global level, so all input-group instances, including components using such an instance as a template will have their input group type set to the one specified by the token. It can be overridden on a component level by explicitly setting a `type`.
2540
- ` IgxExcelExporterService`
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { IgxGridModule, IgxGridComponent } from './public_api';
2+
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
3+
import { async, TestBed, fakeAsync } from '@angular/core/testing';
4+
import { configureTestSuite } from '../../test-utils/configure-suite';
5+
import { DebugElement } from '@angular/core';
6+
import { GridFunctions } from '../../test-utils/grid-functions.spec';
7+
import {
8+
IgxAddRowComponent
9+
} from '../../test-utils/grid-samples.spec';
10+
11+
import { By } from '@angular/platform-browser';
12+
import { IgxActionStripComponent } from '../../action-strip/action-strip.component';
13+
import { IgxActionStripModule } from '../../action-strip/action-strip.module';
14+
import { UIInteractions } from '../../test-utils/ui-interactions.spec';
15+
16+
describe('IgxGrid - Row Adding #grid', () => {
17+
let fixture;
18+
let grid: IgxGridComponent;
19+
let gridContent: DebugElement;
20+
let actionStrip: IgxActionStripComponent;
21+
configureTestSuite();
22+
beforeAll(async(() => {
23+
TestBed.configureTestingModule({
24+
declarations: [
25+
IgxAddRowComponent
26+
],
27+
imports: [
28+
NoopAnimationsModule,
29+
IgxActionStripModule,
30+
IgxGridModule]
31+
}).compileComponents();
32+
}));
33+
34+
describe('General tests', () => {
35+
beforeEach(fakeAsync(/** height/width setter rAF */() => {
36+
fixture = TestBed.createComponent(IgxAddRowComponent);
37+
fixture.detectChanges();
38+
grid = fixture.componentInstance.grid;
39+
gridContent = GridFunctions.getGridContent(fixture);
40+
actionStrip = fixture.componentInstance.actionStrip;
41+
}));
42+
43+
it('Should be able to enter add row mode on action strip click', () => {
44+
const row = grid.rowList.first;
45+
actionStrip.show(row);
46+
fixture.detectChanges();
47+
const addRowIcon = fixture.debugElement.queryAll(By.css(`igx-grid-editing-actions igx-icon`))[1];
48+
addRowIcon.parent.triggerEventHandler('click', new Event('click'));
49+
fixture.detectChanges();
50+
const addRow = grid.getRowByIndex(1);
51+
expect(addRow.addRow).toBeTrue();
52+
});
53+
54+
it('Should be able to enter add row mode through the exposed API method (w/ and w/o rowID)', () => {
55+
grid.beginAddRow();
56+
fixture.detectChanges();
57+
let addRow = grid.getRowByIndex(1);
58+
expect(addRow.addRow).toBeTrue();
59+
60+
UIInteractions.triggerEventHandlerKeyDown('escape', gridContent);
61+
fixture.detectChanges();
62+
addRow = grid.getRowByIndex(1);
63+
expect(addRow.addRow).toBeFalse();
64+
65+
grid.beginAddRow('ANATR');
66+
fixture.detectChanges();
67+
addRow = grid.getRowByIndex(2);
68+
expect(addRow.addRow).toBeTrue();
69+
});
70+
71+
it('Should display the banner above the row if there is no room underneath it', () => {
72+
grid.paging = true;
73+
grid.perPage = 7;
74+
fixture.detectChanges();
75+
76+
const lastRow = grid.rowList.last;
77+
const lastRowIndex = lastRow.index;
78+
actionStrip.show(lastRow);
79+
fixture.detectChanges();
80+
81+
const addRowIcon = fixture.debugElement.queryAll(By.css(`igx-grid-editing-actions igx-icon`))[1];
82+
addRowIcon.parent.triggerEventHandler('click', new Event('click'));
83+
fixture.detectChanges();
84+
85+
86+
const addRow = grid.getRowByIndex(lastRowIndex + 1);
87+
expect(addRow.addRow).toBeTrue();
88+
89+
const banner = GridFunctions.getRowEditingOverlay(fixture);
90+
fixture.detectChanges();
91+
const bannerBottom = banner.getBoundingClientRect().bottom;
92+
const addRowTop = addRow.nativeElement.getBoundingClientRect().top;
93+
94+
// The banner appears above the row
95+
expect(bannerBottom).toBeLessThanOrEqual(addRowTop);
96+
97+
// No much space between the row and the banner
98+
expect(addRowTop - bannerBottom).toBeLessThan(2);
99+
});
100+
101+
it('Should not be able to enter add row mode when rowEditing is disabled', () => {
102+
grid.rowEditable = false;
103+
fixture.detectChanges();
104+
105+
grid.beginAddRow();
106+
fixture.detectChanges();
107+
108+
const banner = GridFunctions.getRowEditingOverlay(fixture);
109+
expect(banner).toBeNull();
110+
expect(grid.getRowByIndex(1).addRow).toBeFalse();
111+
});
112+
113+
});
114+
});

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

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { IgxGridExcelStyleFilteringComponent } from '../grids/filtering/excel-st
2020
import { FilteringLogic } from '../data-operations/filtering-expression.interface';
2121
import { SortingDirection } from '../data-operations/sorting-expression.interface';
2222
import { ISortingStrategy } from '../data-operations/sorting-strategy';
23+
import { IgxActionStripComponent } from '../action-strip/action-strip.component';
2324

2425
@Component({
2526
template: `<div style="width: 800px; height: 600px;">
@@ -2163,3 +2164,70 @@ export class MRLTestComponent {
21632164
];
21642165
data = SampleTestData.contactInfoDataFull();
21652166
}
2167+
2168+
@Component({
2169+
template: `
2170+
<igx-grid #grid [data]="data" [width]="'800px'" [height]="'500px'"
2171+
[rowEditable]="true" [primaryKey]="'ID'">
2172+
<igx-column *ngFor="let c of columns" [sortable]="true" [field]="c.field" [header]="c.field"
2173+
[width]="c.width">
2174+
</igx-column>
2175+
2176+
<igx-action-strip #actionStrip>
2177+
<igx-grid-editing-actions [addRow]='true'></igx-grid-editing-actions>
2178+
</igx-action-strip>
2179+
</igx-grid>
2180+
`
2181+
})
2182+
export class IgxAddRowComponent implements OnInit {
2183+
@ViewChild('actionStrip', { read: IgxActionStripComponent, static: true })
2184+
public actionStrip: IgxActionStripComponent;
2185+
2186+
@ViewChild('grid', { read: IgxGridComponent, static: true })
2187+
public grid: IgxGridComponent;
2188+
2189+
data: any[];
2190+
columns: any[];
2191+
2192+
ngOnInit() {
2193+
2194+
this.columns = [
2195+
{ field: 'ID', width: '200px', hidden: false },
2196+
{ field: 'CompanyName', width: '200px' },
2197+
{ field: 'ContactName', width: '200px', pinned: false },
2198+
{ field: 'ContactTitle', width: '300px', pinned: false },
2199+
];
2200+
2201+
this.data = [
2202+
// tslint:disable:max-line-length
2203+
{ 'ID': 'ALFKI', 'CompanyName': 'Alfreds Futterkiste', 'ContactName': 'Maria Anders', 'ContactTitle': 'Sales Representative'},
2204+
{ 'ID': 'ANATR', 'CompanyName': 'Ana Trujillo Emparedados y helados', 'ContactName': 'Ana Trujillo', 'ContactTitle': 'Owner'},
2205+
{ 'ID': 'ANTON', 'CompanyName': 'Antonio Moreno Taquería', 'ContactName': 'Antonio Moreno', 'ContactTitle': 'Owner'},
2206+
{ 'ID': 'AROUT', 'CompanyName': 'Around the Horn', 'ContactName': 'Thomas Hardy', 'ContactTitle': 'Sales Representative'},
2207+
{ 'ID': 'BERGS', 'CompanyName': 'Berglunds snabbköp', 'ContactName': 'Christina Berglund', 'ContactTitle': 'Order Administrator' },
2208+
{ 'ID': 'BLAUS', 'CompanyName': 'Blauer See Delikatessen', 'ContactName': 'Hanna Moos', 'ContactTitle': 'Sales Representative'},
2209+
{ 'ID': 'BLONP', 'CompanyName': 'Blondesddsl père et fils', 'ContactName': 'Frédérique Citeaux', 'ContactTitle': 'Marketing Manager'},
2210+
{ 'ID': 'BOLID', 'CompanyName': 'Bólido Comidas preparadas', 'ContactName': 'Martín Sommer', 'ContactTitle': 'Owner'},
2211+
{ 'ID': 'BONAP', 'CompanyName': 'Bon app\'', 'ContactName': 'Laurence Lebihan', 'ContactTitle': 'Owner'},
2212+
{ 'ID': 'BOTTM', 'CompanyName': 'Bottom-Dollar Markets', 'ContactName': 'Elizabeth Lincoln', 'ContactTitle': 'Accounting Manager' },
2213+
{ 'ID': 'BSBEV', 'CompanyName': 'B\'s Beverages', 'ContactName': 'Victoria Ashworth', 'ContactTitle': 'Sales Representative', 'Address': 'Fauntleroy Circus', 'City': 'London', 'Region': null, 'PostalCode': 'EC2 5NT', 'Country': 'UK', 'Phone': '(171) 555-1212', 'Fax': null },
2214+
{ 'ID': 'CACTU', 'CompanyName': 'Cactus Comidas para llevar', 'ContactName': 'Patricio Simpson', 'ContactTitle': 'Sales Agent', 'Address': 'Cerrito 333', 'City': 'Buenos Aires', 'Region': null, 'PostalCode': '1010', 'Country': 'Argentina', 'Phone': '(1) 135-5555', 'Fax': '(1) 135-4892' },
2215+
{ 'ID': 'CENTC', 'CompanyName': 'Centro comercial Moctezuma', 'ContactName': 'Francisco Chang', 'ContactTitle': 'Marketing Manager', 'Address': 'Sierras de Granada 9993', 'City': 'México D.F.', 'Region': null, 'PostalCode': '05022', 'Country': 'Mexico', 'Phone': '(5) 555-3392', 'Fax': '(5) 555-7293' },
2216+
{ 'ID': 'CHOPS', 'CompanyName': 'Chop-suey Chinese', 'ContactName': 'Yang Wang', 'ContactTitle': 'Owner', 'Address': 'Hauptstr. 29', 'City': 'Bern', 'Region': null, 'PostalCode': '3012', 'Country': 'Switzerland', 'Phone': '0452-076545', 'Fax': null },
2217+
{ 'ID': 'COMMI', 'CompanyName': 'Comércio Mineiro', 'ContactName': 'Pedro Afonso', 'ContactTitle': 'Sales Associate', 'Address': 'Av. dos Lusíadas, 23', 'City': 'Sao Paulo', 'Region': 'SP', 'PostalCode': '05432-043', 'Country': 'Brazil', 'Phone': '(11) 555-7647', 'Fax': null },
2218+
{ 'ID': 'CONSH', 'CompanyName': 'Consolidated Holdings', 'ContactName': 'Elizabeth Brown', 'ContactTitle': 'Sales Representative', 'Address': 'Berkeley Gardens 12 Brewery', 'City': 'London', 'Region': null, 'PostalCode': 'WX1 6LT', 'Country': 'UK', 'Phone': '(171) 555-2282', 'Fax': '(171) 555-9199' },
2219+
{ 'ID': 'DRACD', 'CompanyName': 'Drachenblut Delikatessen', 'ContactName': 'Sven Ottlieb', 'ContactTitle': 'Order Administrator', 'Address': 'Walserweg 21', 'City': 'Aachen', 'Region': null, 'PostalCode': '52066', 'Country': 'Germany', 'Phone': '0241-039123', 'Fax': '0241-059428' },
2220+
{ 'ID': 'DUMON', 'CompanyName': 'Du monde entier', 'ContactName': 'Janine Labrune', 'ContactTitle': 'Owner', 'Address': '67, rue des Cinquante Otages', 'City': 'Nantes', 'Region': null, 'PostalCode': '44000', 'Country': 'France', 'Phone': '40.67.88.88', 'Fax': '40.67.89.89' },
2221+
{ 'ID': 'EASTC', 'CompanyName': 'Eastern Connection', 'ContactName': 'Ann Devon', 'ContactTitle': 'Sales Agent', 'Address': '35 King George', 'City': 'London', 'Region': null, 'PostalCode': 'WX3 6FW', 'Country': 'UK', 'Phone': '(171) 555-0297', 'Fax': '(171) 555-3373' },
2222+
{ 'ID': 'ERNSH', 'CompanyName': 'Ernst Handel', 'ContactName': 'Roland Mendel', 'ContactTitle': 'Sales Manager', 'Address': 'Kirchgasse 6', 'City': 'Graz', 'Region': null, 'PostalCode': '8010', 'Country': 'Austria', 'Phone': '7675-3425', 'Fax': '7675-3426' },
2223+
{ 'ID': 'FAMIA', 'CompanyName': 'Familia Arquibaldo', 'ContactName': 'Aria Cruz', 'ContactTitle': 'Marketing Assistant', 'Address': 'Rua Orós, 92', 'City': 'Sao Paulo', 'Region': 'SP', 'PostalCode': '05442-030', 'Country': 'Brazil', 'Phone': '(11) 555-9857', 'Fax': null },
2224+
{ 'ID': 'FISSA', 'CompanyName': 'FISSA Fabrica Inter. Salchichas S.A.', 'ContactName': 'Diego Roel', 'ContactTitle': 'Accounting Manager', 'Address': 'C/ Moralzarzal, 86', 'City': 'Madrid', 'Region': null, 'PostalCode': '28034', 'Country': 'Spain', 'Phone': '(91) 555 94 44', 'Fax': '(91) 555 55 93' },
2225+
{ 'ID': 'FOLIG', 'CompanyName': 'Folies gourmandes', 'ContactName': 'Martine Rancé', 'ContactTitle': 'Assistant Sales Agent', 'Address': '184, chaussée de Tournai', 'City': 'Lille', 'Region': null, 'PostalCode': '59000', 'Country': 'France', 'Phone': '20.16.10.16', 'Fax': '20.16.10.17' },
2226+
{ 'ID': 'FOLKO', 'CompanyName': 'Folk och fä HB', 'ContactName': 'Maria Larsson', 'ContactTitle': 'Owner', 'Address': 'Åkergatan 24', 'City': 'Bräcke', 'Region': null, 'PostalCode': 'S-844 67', 'Country': 'Sweden', 'Phone': '0695-34 67 21', 'Fax': null },
2227+
{ 'ID': 'FRANK', 'CompanyName': 'Frankenversand', 'ContactName': 'Peter Franken', 'ContactTitle': 'Marketing Manager', 'Address': 'Berliner Platz 43', 'City': 'München', 'Region': null, 'PostalCode': '80805', 'Country': 'Germany', 'Phone': '089-0877310', 'Fax': '089-0877451' },
2228+
{ 'ID': 'FRANR', 'CompanyName': 'France restauration', 'ContactName': 'Carine Schmitt', 'ContactTitle': 'Marketing Manager', 'Address': '54, rue Royale', 'City': 'Nantes', 'Region': null, 'PostalCode': '44000', 'Country': 'France', 'Phone': '40.32.21.21', 'Fax': '40.32.21.20' },
2229+
{ 'ID': 'FRANS', 'CompanyName': 'Franchi S.p.A.', 'ContactName': 'Paolo Accorti', 'ContactTitle': 'Sales Representative', 'Address': 'Via Monte Bianco 34', 'City': 'Torino', 'Region': null, 'PostalCode': '10100', 'Country': 'Italy', 'Phone': '011-4988260', 'Fax': '011-4988261' }
2230+
];
2231+
// tslint:enable:max-line-length
2232+
}
2233+
}

0 commit comments

Comments
 (0)