Skip to content

Commit 8644cfd

Browse files
committed
feat(igx-combo): Filter pipe implemented, sample adjustments, #1260
1 parent 7133f3e commit 8644cfd

File tree

5 files changed

+41
-19
lines changed

5 files changed

+41
-19
lines changed

demos/app/combo/sample.component.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
<page-header title="Combo" description="Combo lets you choose value from a list"></page-header>
33
<section class="sample-content">
44
<p>Change data to:</p>
5-
<button class="igx-button" (click)="changeData('primitive')">Primitve</button>
6-
<button class="igx-button" (click)="changeData('complex')">Complex</button>
7-
<button class="igx-button" (click)="changeData()">Initial</button>
5+
<button class="igx-button" igxRipple (click)="changeData('primitive')">Primitve</button>
6+
<button class="igx-button" igxRipple (click)="changeData('complex')">Complex</button>
7+
<button class="igx-button" igxRipple (click)="changeData()">Initial</button>
88
<igx-combo [placeholder]="'Location'" [data]="items" [filterable]="true" [primaryKey]="'field'" [width]="'400px'">
9-
<ng-template #dropdownItemTemplate let-display let-key="primaryKey">
9+
<ng-template #dropdownItemTemplate let-display let-key="primaryKey" let-data="data">
1010
<div>
11-
<span class="small-red-circle"></span>{{display[key]}}
11+
<span class="small-red-circle"></span>
12+
<p class="display-value--main">State: {{display[key]}}</p>
13+
<p class="display-value--sub">Region: {{display.county}}</p>
1214
</div>
1315
</ng-template>
14-
<ng-template #dropdownFooter>
15-
<div class="footer-class">This is a footer</div>
16-
</ng-template>
1716
<ng-template #dropdownHeader>
1817
<div class="header-class">This is a header</div>
1918
</ng-template>
19+
<ng-template #dropdownFooter>
20+
<div class="footer-class">This is a footer</div>
21+
</ng-template>
2022
</igx-combo>
2123
</section>
2224
</div>

demos/app/combo/sample.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export class ComboSampleComponent implements OnInit {
125125
}
126126
this.items.push(item);
127127
this.initData = this.items;
128-
this.currentDataType = "initial";
129128
}
130129
}
131130

src/combo/combo.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ng-template #complex let-display let-key="primaryKey">
1+
<ng-template #complex let-display let-data="data" let-key="primaryKey">
22
{{display[key]}}
33
</ng-template>
44
<ng-template #primitive let-display>
@@ -23,7 +23,7 @@
2323
</igx-drop-down-item>
2424
<ng-template #content>
2525
<igx-drop-down-item #content *ngFor="let item of data | comboFiltering:filteringExpressions:filteringLogic:caller:pipeTrigger">
26-
<ng-container *ngTemplateOutlet="template; context: {$implicit: item, primaryKey: primaryKey};"></ng-container>
26+
<ng-container *ngTemplateOutlet="template; context: {$implicit: item, data: data, primaryKey: primaryKey};"></ng-container>
2727
</igx-drop-down-item>
2828
</ng-template>
2929
<ng-container *ngTemplateOutlet="dropdownFooter; context: {$impicit: this}">

src/combo/combo.component.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,26 @@ describe("Combo", () => {
1010
}));
1111

1212
it("Initialize combo", () => {
13+
// TO DO
14+
});
15+
16+
it("Initialize combo", () => {
17+
// TO DO
18+
});
19+
20+
it("Initialize combo", () => {
21+
// TO DO
22+
});
1323

24+
it("Initialize combo", () => {
25+
// TO DO
26+
});
27+
28+
it("Initialize combo", () => {
29+
// TO DO
30+
});
31+
32+
it("Initialize combo", () => {
33+
// TO DO
1434
});
1535
});

src/combo/combo.component.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ export class IgxComboComponent implements OnInit, OnDestroy {
127127

128128
}
129129

130-
protected prepare_filtering_expression(state, searchVal, condition, ignoreCase) {
131-
const newExpression = { searchVal, condition, ignoreCase };
132-
state.push(newExpression);
130+
protected prepare_filtering_expression(searchVal, condition, ignoreCase, fieldName?) {
131+
if (fieldName !== undefined) {
132+
return [{ fieldName, searchVal, condition, ignoreCase }];
133+
}
134+
return [{ searchVal, condition, ignoreCase }];
133135
}
134136

135-
public filter(term, condition, ignoreCase) {
136-
const filteringState = this.filteringExpressions;
137-
this.prepare_filtering_expression(filteringState, term, condition, ignoreCase);
138-
this.filteringExpressions = filteringState;
137+
public filter(term, condition, ignoreCase, primaryKey?) {
138+
this.filteringExpressions = this.prepare_filtering_expression(term, condition, ignoreCase, primaryKey);
139139
}
140140

141141
public get displayedData() {
@@ -146,7 +146,8 @@ export class IgxComboComponent implements OnInit, OnDestroy {
146146
}
147147
public hanldeKeyDown(evt) {
148148
if (this.filterable) {
149-
this.filter(evt.target.value, STRING_FILTERS.contains, true);
149+
this.filter(evt.target.value, STRING_FILTERS.contains,
150+
true, this.getDataType() === DataTypes.PRIMITIVE ? undefined : this.primaryKey);
150151
}
151152
}
152153

0 commit comments

Comments
 (0)