Skip to content

Commit

Permalink
Merge pull request #7 from joqkey/issue-6
Browse files Browse the repository at this point in the history
Issue #6 - multi select filtering fix
  • Loading branch information
macjohnny authored Mar 19, 2018
2 parents cfb60d5 + e363972 commit 0e53216
Show file tree
Hide file tree
Showing 8 changed files with 374 additions and 88 deletions.
3 changes: 3 additions & 0 deletions .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
"test": {
"karma": {
"config": "./karma.conf.js"
},
"codeCoverage": {
"exclude": ["src/app/app.component.ts"]
}
},
"defaults": {
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## 1.0.1

* Bugfix: don't clear initial selection with `multi="true"` [#6](https://github.com/bithost-gmbh/ngx-mat-select-search/issues/6)

Thanks to @joqkey


## 1.0.0

* Initial Release
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function (config) {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
reports: [ 'html', 'lcovonly', 'text-summary' ],
fixWebpackSourcePaths: true
},
angularCli: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"start": "ng serve",
"build": "ng build --prod",
"build.ci": "npm run build -- --progress=false",
"test": "ng test",
"test": "ng test --watch=false --code-coverage",
"test.ci": "npm run test -- --progress=false --watch=false",
"lint": "ng lint",
"e2e": "ng e2e",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h3>Single selection</h3>
<h3>Multiple selection</h3>
<p>
<mat-form-field>
<mat-select [formControl]="bankMultiCtrl" placeholder="Banks" [multiple]="true">
<mat-select [formControl]="bankMultiCtrl" placeholder="Banks" [multiple]="true" #multiSelect>
<ngx-mat-select-search [formControl]="bankMultiFilterCtrl"></ngx-mat-select-search>
<mat-option *ngFor="let bank of filteredBanksMulti | async" [value]="bank">
{{bank.name}}
Expand Down
3 changes: 3 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
public filteredBanksMulti: ReplaySubject<Bank[]> = new ReplaySubject<Bank[]>(1);

@ViewChild('singleSelect') singleSelect: MatSelect;
@ViewChild('multiSelect') multiSelect: MatSelect;

/** Subject that emits when the component has been destroyed. */
private _onDestroy = new Subject<void>();

ngOnInit() {
// set initial selection
this.bankCtrl.setValue(this.banks[10]);
this.bankMultiCtrl.setValue([this.banks[10], this.banks[11], this.banks[12]]);

// load the initial bank list
this.filteredBanks.next(this.banks.slice());
Expand Down Expand Up @@ -109,6 +111,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
// this needs to be done after the filteredBanks are loaded initially
// and after the mat-option elements are available
this.singleSelect.compareWith = (a: Bank, b: Bank) => a.id === b.id;
this.multiSelect.compareWith = (a: Bank, b: Bank) => a.id === b.id;
});
}

Expand Down
Loading

0 comments on commit 0e53216

Please sign in to comment.