Skip to content

Commit 766d662

Browse files
authored
Merge branch 'master' into roadmap-upadte-m19-30nov21
2 parents 02752a6 + ee82480 commit 766d662

34 files changed

+1115
-142
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
All notable changes for each version of this project will be documented in this file.
44

5+
## 13.0.1
6+
7+
### New Features
8+
- Add `igxSummary` directive in order to re-template the default summary cell layout.
9+
- Expose `summaryTemplate` input in order to bind the column summary template through API.
10+
- Expose `summaryRowHeight` property which overrides the default hight of the summary row.
11+
- Code example below:
12+
13+
```html
14+
<igx-column ... [hasSummary]="true">
15+
<ng-template igxSummary let-summaryResult>
16+
<span> My custom summary template</span>
17+
<span>{{ summaryResult[0].label }} - {{ summaryResult[0].summaryResult }}</span>
18+
</ng-template>
19+
</igx-column>
20+
```
21+
- Please, refer to the [Summaries](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/summaries#summary-template) topic for more information.
22+
523
## 13.0.0
624

725
### New Features

projects/igniteui-angular/src/lib/accordion/accordion.component.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,29 @@ describe('Rendering Tests', () => {
166166
expect(accordion.panelCollapsed.emit).toHaveBeenCalledTimes(5);
167167
}));
168168

169+
it(`Should collapse all expanded and not disabled panels except for the last one when setting singleBranchExpand to true`, () => {
170+
expect(accordion.panels[0].collapsed).toBeTrue();
171+
expect(accordion.panels[1].collapsed).toBeTrue();
172+
expect(accordion.panels[2].collapsed).toBeFalse();
173+
expect(accordion.panels[3].collapsed).toBeFalse();
174+
175+
accordion.panels[1].collapsed = false;
176+
fix.detectChanges();
177+
178+
expect(accordion.panels[0].collapsed).toBeTrue();
179+
expect(accordion.panels[1].collapsed).toBeFalse();
180+
expect(accordion.panels[2].collapsed).toBeFalse();
181+
expect(accordion.panels[3].collapsed).toBeFalse();
182+
183+
accordion.singleBranchExpand = true;
184+
fix.detectChanges();
185+
186+
expect(accordion.panels[0].collapsed).toBeTrue();
187+
expect(accordion.panels[1].collapsed).toBeTrue();
188+
expect(accordion.panels[2].collapsed).toBeFalse();
189+
expect(accordion.panels[3].collapsed).toBeFalse();
190+
});
191+
169192
it('Should emit ing and ed events when expand panel state is toggled', fakeAsync(() => {
170193
spyOn(accordion.panelExpanded, 'emit').and.callThrough();
171194
spyOn(accordion.panelExpanding, 'emit').and.callThrough();

projects/igniteui-angular/src/lib/accordion/accordion.component.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AfterContentInit, AfterViewInit, Component, ContentChildren, EventEmitter,
1+
import { AfterContentInit, AfterViewInit, ChangeDetectorRef, Component, ContentChildren, EventEmitter,
22
HostBinding, Input, OnDestroy, Output, QueryList } from '@angular/core';
33
import { fromEvent, Subject } from 'rxjs';
44
import { takeUntil } from 'rxjs/operators';
@@ -113,7 +113,16 @@ export class IgxAccordionComponent implements AfterContentInit, AfterViewInit, O
113113
* ```
114114
*/
115115
@Input()
116-
public singleBranchExpand = false;
116+
public get singleBranchExpand(): boolean {
117+
return this._singleBranchExpand;
118+
}
119+
120+
public set singleBranchExpand(val: boolean) {
121+
this._singleBranchExpand = val;
122+
if (val) {
123+
this.collapseAllExceptLast();
124+
}
125+
}
117126

118127
/**
119128
* Emitted before a panel is expanded.
@@ -200,12 +209,16 @@ export class IgxAccordionComponent implements AfterContentInit, AfterViewInit, O
200209
private _destroy$ = new Subject<void>();
201210
private _unsubChildren$ = new Subject<void>();
202211
private _enabledPanels!: IgxExpansionPanelComponent[];
212+
private _singleBranchExpand = false;
203213

204-
constructor() { }
214+
constructor(private cdr: ChangeDetectorRef) { }
205215

206216
/** @hidden @internal **/
207217
public ngAfterContentInit(): void {
208218
this.updatePanelsAnimation();
219+
if (this.singleBranchExpand) {
220+
this.collapseAllExceptLast();
221+
}
209222
}
210223

211224
/** @hidden @internal **/
@@ -256,6 +269,16 @@ export class IgxAccordionComponent implements AfterContentInit, AfterViewInit, O
256269
this.panels.forEach(panel => panel.collapse());
257270
}
258271

272+
private collapseAllExceptLast(): void {
273+
const lastExpanded = this.panels?.filter(p => !p.collapsed && !p.header.disabled).pop();
274+
this.panels?.forEach((p: IgxExpansionPanelComponent) => {
275+
if (p !== lastExpanded && !p.header.disabled) {
276+
p.collapsed = true;
277+
}
278+
});
279+
this.cdr.detectChanges();
280+
}
281+
259282
private handleKeydown(event: KeyboardEvent, panel: IgxExpansionPanelComponent): void {
260283
const key = event.key.toLowerCase();
261284
if (!(ACCORDION_NAVIGATION_KEYS.has(key))) {

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('igxCombo', () => {
9595
get: mockNgControl
9696
});
9797
mockSelection.get.and.returnValue(new Set([]));
98-
const mockIconService = new IgxIconService(null, null, null);
98+
const mockIconService = new IgxIconService(null, null, null, null);
9999
it('should correctly implement interface methods - ControlValueAccessor ', () => {
100100
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
101101
mockIconService, null, null, mockInjector);

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@
11171117
z-index: 10000;
11181118

11191119
%igx-grid__hierarchical-expander--empty {
1120-
border-#{$right}: 1px solid transparent;
1120+
border-#{$right}: rem(1px) solid var-get($theme, 'header-border-color');
11211121
}
11221122
}
11231123

projects/igniteui-angular/src/lib/grids/columns/column.component.ts

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import {
4343
IgxCellHeaderTemplateDirective,
4444
IgxCellEditorTemplateDirective,
4545
IgxCollapsibleIndicatorTemplateDirective,
46-
IgxFilterCellTemplateDirective
46+
IgxFilterCellTemplateDirective,
47+
IgxSummaryTemplateDirective
4748
} from './templates.directive';
4849
import { MRLResizeColumnInfo, MRLColumnSizeInfo, IColumnPipeArgs } from './interfaces';
4950
import { DropPosition } from '../moving/moving.service';
@@ -833,6 +834,11 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
833834
*/
834835
@ContentChild(IgxFilterCellTemplateDirective, { read: IgxFilterCellTemplateDirective })
835836
public filterCellTemplateDirective: IgxFilterCellTemplateDirective;
837+
/**
838+
* @hidden
839+
*/
840+
@ContentChild(IgxSummaryTemplateDirective, { read: IgxSummaryTemplateDirective })
841+
protected summaryTemplateDirective: IgxSummaryTemplateDirective;
836842
/**
837843
* @hidden
838844
*/
@@ -853,7 +859,6 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
853859
*/
854860
@ContentChild(IgxCollapsibleIndicatorTemplateDirective, { read: IgxCollapsibleIndicatorTemplateDirective, static: false })
855861
protected collapseIndicatorTemplate: IgxCollapsibleIndicatorTemplateDirective;
856-
857862
/**
858863
* @hidden
859864
*/
@@ -1109,6 +1114,39 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
11091114
return '80';
11101115
}
11111116
}
1117+
/**
1118+
* Returns a reference to the `summaryTemplate`.
1119+
* ```typescript
1120+
* let summaryTemplate = this.column.summaryTemplate;
1121+
* ```
1122+
*
1123+
* @memberof IgxColumnComponent
1124+
*/
1125+
@notifyChanges()
1126+
@WatchColumnChanges()
1127+
@Input()
1128+
public get summaryTemplate(): TemplateRef<any> {
1129+
return this._summaryTemplate;
1130+
}
1131+
/**
1132+
* Sets the summary template.
1133+
* ```html
1134+
* <ng-template #summaryTemplate igxSummary let-summaryResults>
1135+
* <p>{{ summaryResults[0].label }}: {{ summaryResults[0].summaryResult }}</p>
1136+
* <p>{{ summaryResults[1].label }}: {{ summaryResults[1].summaryResult }}</p>
1137+
* </ng-template>
1138+
* ```
1139+
* ```typescript
1140+
* @ViewChild("'summaryTemplate'", {read: TemplateRef })
1141+
* public summaryTemplate: TemplateRef<any>;
1142+
* this.column.summaryTemplate = this.summaryTemplate;
1143+
* ```
1144+
*
1145+
* @memberof IgxColumnComponent
1146+
*/
1147+
public set summaryTemplate(template: TemplateRef<any>) {
1148+
this._summaryTemplate = template;
1149+
}
11121150
/**
11131151
* Returns a reference to the `bodyTemplate`.
11141152
* ```typescript
@@ -1565,6 +1603,10 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
15651603
* @hidden
15661604
*/
15671605
protected _headerTemplate: TemplateRef<any>;
1606+
/**
1607+
* @hidden
1608+
*/
1609+
protected _summaryTemplate: TemplateRef<any>;
15681610
/**
15691611
* @hidden
15701612
*/
@@ -1672,6 +1714,9 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
16721714
* @hidden
16731715
*/
16741716
public ngAfterContentInit(): void {
1717+
if (this.summaryTemplateDirective) {
1718+
this._summaryTemplate = this.summaryTemplateDirective.template;
1719+
}
16751720
if (this.cellTemplate) {
16761721
this._bodyTemplate = this.cellTemplate.template;
16771722
}

projects/igniteui-angular/src/lib/grids/columns/column.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import {
88
IgxCellHeaderTemplateDirective,
99
IgxCellTemplateDirective,
1010
IgxCollapsibleIndicatorTemplateDirective,
11-
IgxFilterCellTemplateDirective
11+
IgxFilterCellTemplateDirective,
12+
IgxSummaryTemplateDirective
1213
} from './templates.directive';
1314

14-
1515
@NgModule({
1616
declarations: [
1717
IgxFilterCellTemplateDirective,
18+
IgxSummaryTemplateDirective,
1819
IgxCellTemplateDirective,
1920
IgxCellHeaderTemplateDirective,
2021
IgxCellFooterTemplateDirective,
@@ -31,6 +32,7 @@ import {
3132
],
3233
exports: [
3334
IgxFilterCellTemplateDirective,
35+
IgxSummaryTemplateDirective,
3436
IgxCellTemplateDirective,
3537
IgxCellHeaderTemplateDirective,
3638
IgxCellFooterTemplateDirective,

projects/igniteui-angular/src/lib/grids/columns/templates.directive.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,11 @@ export class IgxCollapsibleIndicatorTemplateDirective {
5050

5151
constructor(public template: TemplateRef<any>) { }
5252
}
53+
54+
@Directive({
55+
selector: '[igxSummary]'
56+
})
57+
export class IgxSummaryTemplateDirective {
58+
59+
constructor(public template: TemplateRef<any>) { }
60+
}

projects/igniteui-angular/src/lib/grids/common/grid.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export interface ColumnType {
157157
filteringExpressionsTree: FilteringExpressionsTree;
158158
hasSummary: boolean;
159159
summaries: any;
160+
summaryTemplate: TemplateRef<any>;
160161
pinned: boolean;
161162
expanded: boolean;
162163
selected: boolean;
@@ -372,6 +373,7 @@ export interface GridType extends IGridDataBindable {
372373
dataWithAddedInTransactionRows: any[];
373374
transactions: TransactionService<Transaction, State>;
374375
defaultSummaryHeight: number;
376+
summaryRowHeight: number;
375377
rowEditingOverlay: IgxToggleDirective;
376378
totalRowsCountAfterFilter: number;
377379
_totalRecords: number;

projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ export class IgxGridFilteringRowComponent implements AfterViewInit, OnDestroy {
7272
this.expression.searchVal = null;
7373
const index = this.expressionsList.findIndex(item => item.expression === this.expression);
7474
if (index === 0 && this.expressionsList.length === 1) {
75-
this.clearFiltering();
75+
this.filteringService.clearFilter(this.column.field);
76+
77+
if (this.expression.condition.isUnary) {
78+
this.resetExpression();
79+
}
80+
7681
return;
7782
}
7883
} else {

0 commit comments

Comments
 (0)