This repository was archived by the owner on Jan 29, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -62,8 +62,9 @@ <h5 *ngIf="info && info.length > 0 && info !== 'team'" class='name center'>
62
62
< div class ="col-sm-6 promote typeahead ">
63
63
< mat-form-field appearance ="fill " style ="width: 100%; background-color: white; ">
64
64
< 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 ">
67
68
{{ comp.name }}
68
69
</ mat-option >
69
70
</ mat-select >
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export class PromoteComponent implements OnInit {
26
26
userReadCompany : Company
27
27
28
28
companies : Company [ ]
29
+ selectedCompanies : Company [ ]
29
30
searchedCompany : Company
30
31
31
32
me : User
@@ -124,9 +125,12 @@ export class PromoteComponent implements OnInit {
124
125
//Filtering companies from companies and partners array
125
126
let companies = companiesPartners . filter ( ( company ) => {
126
127
return company . advertisementLvl != "other" ;
128
+ } ) . sort ( ( a , b ) => {
129
+ return a . name . localeCompare ( b . name )
127
130
} ) ;
128
131
129
132
this . companies = companies
133
+ this . selectedCompanies = companies ;
130
134
} )
131
135
}
132
136
@@ -172,8 +176,15 @@ export class PromoteComponent implements OnInit {
172
176
173
177
this . userRead = user
174
178
this . receiveUser ( { user :user , company :null } )
175
-
176
179
} )
177
180
}
178
181
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
+ }
179
190
}
You can’t perform that action at this time.
0 commit comments