Skip to content

Commit

Permalink
Merge pull request #444 from sinfo/adds-search-promote
Browse files Browse the repository at this point in the history
adds search field to promote
  • Loading branch information
andreromao authored Apr 14, 2024
2 parents b84269a + 27fca79 commit 5b22eea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/app/user/promote/promote.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ <h5 *ngIf="info && info.length > 0 && info !== 'team'" class='name center'>
<div class="col-sm-6 promote typeahead">
<mat-form-field appearance="fill" style="width: 100%; background-color: white;">
<mat-label>Search for company</mat-label>
<mat-select name="searchCompany" id="searchCompany" style="background-color: white;" name="searchCompany" [(ngModel)]="searchedCompany">
<mat-option style="background-color: white;" *ngFor="let comp of companies" [value]="comp">
<mat-select name="searchCompany" id="searchCompany" name="searchCompany">
<input (keyup)="onKey($event.target.value)" style="width: 100%;">
<mat-option *ngFor="let comp of selectedCompanies" [value]="comp.name">
{{ comp.name }}
</mat-option>
</mat-select>
Expand Down
13 changes: 12 additions & 1 deletion src/app/user/promote/promote.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class PromoteComponent implements OnInit {
userReadCompany: Company

companies: Company[]
selectedCompanies: Company[]
searchedCompany: Company

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

this.companies = companies
this.selectedCompanies = companies;
})
}

Expand Down Expand Up @@ -172,8 +176,15 @@ export class PromoteComponent implements OnInit {

this.userRead = user
this.receiveUser({user:user, company:null})

})
}

onKey(value) {
this.selectedCompanies = this.search(value);
}

search(value: string) {
let filter = value.toLowerCase();
return this.companies.filter(comp => comp.name.toLowerCase().includes(filter));
}
}

0 comments on commit 5b22eea

Please sign in to comment.