Skip to content

Commit dd298ee

Browse files
authored
Merge branch 'master' into nalipiev/schematics
2 parents 21d3aa7 + ac0469a commit dd298ee

File tree

9 files changed

+113
-16
lines changed

9 files changed

+113
-16
lines changed

projects/igniteui-angular/migrations/update-15_1_0/index.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,36 @@ describe(`Update to ${version}`, () => {
218218
);
219219
});
220220

221+
it('shouldn\'t append igxStart and igxEnd directives to the child elements of the igx-card-actions if already applied', async () => {
222+
appTree.create(`/testSrc/appPrefix/component/test.component.html`,
223+
`
224+
<igx-card-actions>
225+
<span igxButton igxStart>Span</span>
226+
<button igxButton igxStart>Button</button>
227+
<button igxButton="icon" igxEnd>
228+
<igx-icon>favorite</igx-icon>
229+
</button>
230+
<igx-icon igxEnd>drag_indicator</igx-icon>
231+
</igx-card-actions>
232+
`
233+
);
234+
235+
const tree = await schematicRunner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
236+
237+
expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')).toEqual(
238+
`
239+
<igx-card-actions>
240+
<span igxButton igxStart>Span</span>
241+
<button igxButton igxStart>Button</button>
242+
<button igxButton="icon" igxEnd>
243+
<igx-icon>favorite</igx-icon>
244+
</button>
245+
<igx-icon igxEnd>drag_indicator</igx-icon>
246+
</igx-card-actions>
247+
`
248+
);
249+
});
250+
221251
it('should rename the $size property to the $scrollbar-size', async () => {
222252
appTree.create(
223253
`/testSrc/appPrefix/component/test.component.scss`,

projects/igniteui-angular/migrations/update-15_1_0/index.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default (options: Options): Rule => async (host: Tree, context: Schematic
2020
const CARD_ACTIONS = ['igx-card-actions'];
2121
const prop = ['igxButton'];
2222
const changes = new Map<string, FileChange[]>();
23-
23+
2424
const applyChanges = () => {
2525
for (const [path, change] of changes.entries()) {
2626
let buffer = host.read(path).toString();
@@ -57,25 +57,34 @@ export default (options: Options): Rule => async (host: Tree, context: Schematic
5757
const icons: any[] = [];
5858
getChildren(card_action_elem, buttons, icons);
5959

60-
icons.map(node =>getSourceOffset(node as Element))
60+
icons.map(node => getSourceOffset(node as Element))
6161
.forEach(offset => {
62-
const { startTag, file } = offset;
63-
addChange(file.url, new FileChange(startTag.end - 1, ' igxEnd'));
62+
const { startTag, file, node } = offset;
63+
const end = getAttribute(node, 'igxEnd')[0];
64+
65+
if (!end) {
66+
addChange(file.url, new FileChange(startTag.end - 1, ' igxEnd'));
67+
}
6468
})
65-
69+
6670
buttons.map(node => getSourceOffset(node as Element))
6771
.forEach(offset => {
6872
const { startTag, file, node } = offset;
6973
const { value } = getAttribute(node, prop)[0];
70-
if (value === 'icon') {
71-
addChange(file.url, new FileChange(startTag.end - 1, ' igxEnd'));
72-
} else {
74+
const start = getAttribute(node, 'igxStart')[0];
75+
const end = getAttribute(node, 'igxEnd')[0];
76+
77+
if (!start && value !== 'icon') {
7378
addChange(file.url, new FileChange(startTag.end - 1, ' igxStart'));
7479
}
80+
81+
if (!end && value === 'icon') {
82+
addChange(file.url, new FileChange(startTag.end - 1, ' igxEnd'));
83+
}
7584
});
7685
});
7786
}
78-
87+
7988
update.shouldInvokeLS = options['shouldInvokeLS'];
8089
update.addValueTransform('roundShape_is_deprecated', (args: BoundPropertyObject): void => {
8190
args.bindingType = InputPropertyType.STRING;

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ import { IgxGridValidationService } from './grid/grid-validation.service';
177177
let FAKE_ROW_ID = -1;
178178
const DEFAULT_ITEMS_PER_PAGE = 15;
179179
const MINIMUM_COLUMN_WIDTH = 136;
180-
const FILTER_ROW_HEIGHT = 50;
181180
// By default row editing overlay outlet is inside grid body so that overlay is hidden below grid header when scrolling.
182181
// In cases when grid has 1-2 rows there isn't enough space in grid body and row editing overlay should be shown above header.
183182
// Default row editing overlay height is higher then row height that is why the case is valid also for row with 2 rows.
@@ -6643,10 +6642,8 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
66436642
protected calcGridHeadRow() {
66446643
if (this.maxLevelHeaderDepth) {
66456644
this._baseFontSize = parseFloat(getComputedStyle(this.document.documentElement).getPropertyValue('font-size'));
6646-
let minSize = (this.maxLevelHeaderDepth + 1) * this.defaultRowHeight / this._baseFontSize;
6647-
if (this._allowFiltering && this._filterMode === FilterMode.quickFilter) {
6648-
minSize += (FILTER_ROW_HEIGHT + 1) / this._baseFontSize;
6649-
}
6645+
const hasFilterRow = this._allowFiltering && this._filterMode === FilterMode.quickFilter;
6646+
const minSize = (this.maxLevelHeaderDepth + 1 + (hasFilterRow ? 1 : 0)) * this.defaultRowHeight / this._baseFontSize;
66506647
this.theadRow.nativeElement.style.minHeight = `${minSize}rem`;
66516648
}
66526649
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,6 +2535,23 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
25352535
}));
25362536

25372537
// Filtering + Column Groups
2538+
it('should size correctly the header based on display density.', () => {
2539+
grid.displayDensity = "comfortable";
2540+
fix.detectChanges();
2541+
2542+
const thead = GridFunctions.getGridHeader(grid).nativeElement;
2543+
expect(thead.getBoundingClientRect().height).toEqual(grid.defaultRowHeight * 4 + 1);
2544+
2545+
grid.displayDensity = "cosy";
2546+
fix.detectChanges();
2547+
expect(thead.getBoundingClientRect().height).toEqual(grid.defaultRowHeight * 4 + 1);
2548+
2549+
grid.displayDensity = "compact";
2550+
fix.detectChanges();
2551+
expect(thead.getBoundingClientRect().height).toEqual(grid.defaultRowHeight * 4 + 1);
2552+
2553+
});
2554+
25382555
it('should position filter row correctly when grid has column groups.', fakeAsync(() => {
25392556
const thead = GridFunctions.getGridHeader(grid).nativeElement;
25402557

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-add-row-ui.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
77
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
88
import { IgxActionStripComponent } from '../../action-strip/public_api';
99
import { IgxTreeGridRowComponent } from './tree-grid-row.component';
10+
import { first } from 'rxjs/operators';
11+
import { IGridEditEventArgs } from '../public_api';
1012

1113
describe('IgxTreeGrid - Add Row UI #tGrid', () => {
1214
configureTestSuite();
@@ -192,5 +194,28 @@ describe('IgxTreeGrid - Add Row UI #tGrid', () => {
192194
treeGrid.gridAPI.crudService.endEdit(true);
193195
fix.detectChanges();
194196
});
197+
198+
it('should have correct foreignKey value for the data record in rowAdd event arguments', () => {
199+
let newRowId = null;
200+
treeGrid.rowAdd.pipe(first()).subscribe((args: IGridEditEventArgs) => {
201+
expect(args.newValue[treeGrid.foreignKey]).toBe(2);
202+
expect(args.rowData[treeGrid.foreignKey]).toBe(2);
203+
newRowId = args.newValue[treeGrid.primaryKey];
204+
});
205+
206+
treeGrid.beginAddRowById(2, true);
207+
fix.detectChanges();
208+
endTransition();
209+
210+
const addRow = treeGrid.gridAPI.get_row_by_index(2);
211+
expect(addRow.addRowUI).toBeTrue();
212+
213+
treeGrid.gridAPI.crudService.endEdit(true);
214+
fix.detectChanges();
215+
216+
expect(treeGrid.rowList.length).toBe(9);
217+
const addedRow = treeGrid.getRowByKey(newRowId);
218+
expect(addedRow.data[treeGrid.foreignKey]).toBe(2);
219+
});
195220
});
196221
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
711711
Object.keys(row.data).forEach(key => {
712712
// persist foreign key if one is set.
713713
if (this.foreignKey && key === this.foreignKey) {
714-
row.data[key] = treeRowRec.data[key];
714+
row.data[key] = treeRowRec.data[this.crudService.addRowParent?.asChild ? this.primaryKey : key];
715715
} else {
716716
row.data[key] = undefined;
717717
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.density-chooser {
2+
margin-bottom: 16px;
3+
min-width: 900px;
4+
}

src/app/grid-column-groups/grid-column-groups.sample.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<section class="sample-content">
2+
<div class="density-chooser">
3+
<igx-buttongroup [values]="displayDensities" (selected)="selectDensity($event)"></igx-buttongroup>
4+
</div>
25
<ng-template igxCollapsibleIndicator let-column="column" #ind >
36
<igx-icon [attr.draggable]="false">{{column.expanded ? 'remove' : 'add'}} </igx-icon>
47
</ng-template>
5-
<igx-grid [allowFiltering]="true" [moving]="true" [pinning]="pinningConfig" [rowSelection]="selectionMode" #grid [data]="data" displayDensity="compact">
8+
<igx-grid [displayDensity]="density" [allowFiltering]="true" [moving]="true" [pinning]="pinningConfig" [rowSelection]="selectionMode" #grid [data]="data" displayDensity="compact">
69
<igx-grid-toolbar [displayDensity]="grid.displayDensity">
710
<igx-grid-toolbar-actions>
811
<igx-grid-toolbar-pinning></igx-grid-toolbar-pinning>

src/app/grid-column-groups/grid-column-groups.sample.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { IgxGridComponent } from '../../../projects/igniteui-angular/src/lib/gri
1212
import { IgxIconComponent } from '../../../projects/igniteui-angular/src/lib/icon/icon.component';
1313
import { IgxCollapsibleIndicatorTemplateDirective } from '../../../projects/igniteui-angular/src/lib/grids/columns/templates.directive';
1414
import { ColumnPinningPosition, GridSelectionMode } from '../../../projects/igniteui-angular/src/lib/grids/common/enums';
15+
import { DisplayDensity } from '../../../projects/igniteui-angular/src/lib/core/density';
1516

1617
@Component({
1718
selector: 'app-grid-column-groups-sample',
@@ -61,12 +62,19 @@ export class GridColumnGroupsSampleComponent {
6162
];
6263
/* eslint-enable max-len */
6364

65+
public density: string = DisplayDensity.compact;
66+
public displayDensities;
6467

6568
constructor() {
6669
for (const item of this.data) {
6770
item.FullAddress = `${item.Address}, ${item.City}, ${item.Country}`;
6871
}
6972
this.selectionMode = GridSelectionMode.none;
73+
this.displayDensities = [
74+
{ label: 'comfortable', selected: this.density === 'comfortable', togglable: true },
75+
{ label: 'cosy', selected: this.density === 'cosy', togglable: true },
76+
{ label: 'compact', selected: this.density === 'compact', togglable: true }
77+
];
7078
}
7179

7280
public pinGroup() {
@@ -110,4 +118,8 @@ export class GridColumnGroupsSampleComponent {
110118

111119
this.columnGroupStates.set(columnGroup, !this.columnGroupStates.get(columnGroup));
112120
}
121+
122+
public selectDensity(event) {
123+
this.density = this.displayDensities[event.index].label;
124+
}
113125
}

0 commit comments

Comments
 (0)