Merge pull request #1843 from Safelite/CSR-2072-fix-insurance-search-dropdown
CSR-2072 fix insurance search dropdown after API was updated and case…
This commit is contained in:
commit
5ef80b4a83
1 changed files with 17 additions and 3 deletions
|
|
@ -96,15 +96,29 @@ export default {
|
||||||
findMatches(request, response) {
|
findMatches(request, response) {
|
||||||
const matches = [];
|
const matches = [];
|
||||||
const term = request?.term?.toUpperCase();
|
const term = request?.term?.toUpperCase();
|
||||||
|
const nonPriorityMatches = [];
|
||||||
|
|
||||||
this.searchableInsuranceCompanyList.forEach((company, index) => {
|
this.searchableInsuranceCompanyList.forEach((company, index) => {
|
||||||
if (
|
if (
|
||||||
company.accountName.indexOf(term) !== -1 ||
|
company.accountName.toUpperCase().indexOf(term) !== -1 ||
|
||||||
company.altTerms.indexOf(term) !== -1
|
company.altTerms.toUpperCase().indexOf(term) !== -1
|
||||||
) {
|
) {
|
||||||
matches.push(company.accountName);
|
matches.push(company.accountName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
response(matches);
|
|
||||||
|
// Prioritize matched typed entries to top of list
|
||||||
|
const priorityMatches = matches.filter((companyName, index) => {
|
||||||
|
if (companyName.toUpperCase().indexOf(term) === 0) {
|
||||||
|
return companyName;
|
||||||
|
} else {
|
||||||
|
nonPriorityMatches.push(companyName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const prioritizedMatches = [...priorityMatches, ...nonPriorityMatches];
|
||||||
|
|
||||||
|
response(prioritizedMatches);
|
||||||
},
|
},
|
||||||
selectInsuranceCompany(parentAccountName) {
|
selectInsuranceCompany(parentAccountName) {
|
||||||
// this runs upon user selection within jQueryUI Autocomplete
|
// this runs upon user selection within jQueryUI Autocomplete
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue