Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit 5b22eea

Browse files
authored
Merge pull request #444 from sinfo/adds-search-promote
adds search field to promote
2 parents b84269a + 27fca79 commit 5b22eea

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/app/user/promote/promote.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ <h5 *ngIf="info && info.length > 0 && info !== 'team'" class='name center'>
6262
<div class="col-sm-6 promote typeahead">
6363
<mat-form-field appearance="fill" style="width: 100%; background-color: white;">
6464
<mat-label>Search for company</mat-label>
65-
<mat-select name="searchCompany" id="searchCompany" style="background-color: white;" name="searchCompany" [(ngModel)]="searchedCompany">
66-
<mat-option style="background-color: white;" *ngFor="let comp of companies" [value]="comp">
65+
<mat-select name="searchCompany" id="searchCompany" name="searchCompany">
66+
<input (keyup)="onKey($event.target.value)" style="width: 100%;">
67+
<mat-option *ngFor="let comp of selectedCompanies" [value]="comp.name">
6768
{{ comp.name }}
6869
</mat-option>
6970
</mat-select>

src/app/user/promote/promote.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class PromoteComponent implements OnInit {
2626
userReadCompany: Company
2727

2828
companies: Company[]
29+
selectedCompanies: Company[]
2930
searchedCompany: Company
3031

3132
me: User
@@ -124,9 +125,12 @@ export class PromoteComponent implements OnInit {
124125
//Filtering companies from companies and partners array
125126
let companies = companiesPartners.filter((company) => {
126127
return company.advertisementLvl != "other";
128+
}).sort((a, b) => {
129+
return a.name.localeCompare(b.name)
127130
});
128131

129132
this.companies = companies
133+
this.selectedCompanies = companies;
130134
})
131135
}
132136

@@ -172,8 +176,15 @@ export class PromoteComponent implements OnInit {
172176

173177
this.userRead = user
174178
this.receiveUser({user:user, company:null})
175-
176179
})
177180
}
178181

182+
onKey(value) {
183+
this.selectedCompanies = this.search(value);
184+
}
185+
186+
search(value: string) {
187+
let filter = value.toLowerCase();
188+
return this.companies.filter(comp => comp.name.toLowerCase().includes(filter));
189+
}
179190
}

0 commit comments

Comments
 (0)