CSR-1891 re-add select code, format.

This commit is contained in:
Bryan Mauger 2024-03-12 09:56:45 -04:00
parent 6301ffb542
commit 8cb712c2ad

View file

@ -60,8 +60,8 @@ const termMapping = [
}, },
{ {
term: "AAA", term: "AAA",
altTerm: "American" altTerm: "American",
} },
]; ];
export default { export default {
@ -89,19 +89,24 @@ export default {
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
const searchableInsuranceCompanyList = resultMap.insuranceCompanyList.map(( insuranceCompany ) => { const searchableInsuranceCompanyList = resultMap.insuranceCompanyList.map(
(insuranceCompany) => {
insuranceCompany.altTerms = "";
insuranceCompany.altTerms = ""; termMapping.forEach((matchingTerm) => {
if (
insuranceCompany.accountName
.toUpperCase()
.includes(matchingTerm.term.toUpperCase())
) {
insuranceCompany.altTerms =
insuranceCompany.altTerms + matchingTerm.altTerm?.toUpperCase() + " ";
}
});
termMapping.forEach((matchingTerm) => { return insuranceCompany;
if (insuranceCompany.accountName.toUpperCase().includes(matchingTerm.term.toUpperCase())) { }
insuranceCompany.altTerms = insuranceCompany.altTerms + matchingTerm.altTerm?.toUpperCase() + " "; );
}
});
return insuranceCompany;
});
// Call the "next" function to complete the transition to this page. // Call the "next" function to complete the transition to this page.
next((vm) => { next((vm) => {
@ -124,7 +129,10 @@ export default {
const matches = []; const matches = [];
const term = request?.term?.toUpperCase(); const term = request?.term?.toUpperCase();
this.originalList.forEach((company, index) => { this.originalList.forEach((company, index) => {
if (company.accountName.indexOf(term) !== -1 || company.altTerms.indexOf(term) !== -1) { if (
company.accountName.indexOf(term) !== -1 ||
company.altTerms.indexOf(term) !== -1
) {
matches.push(company.accountName); matches.push(company.accountName);
} }
}); });
@ -165,6 +173,7 @@ export default {
}, },
}, },
mounted() { mounted() {
const select = this.selectParentAccountNumber;
setTimeout(() => { setTimeout(() => {
$("#autocomplete").autocomplete({ $("#autocomplete").autocomplete({
source: this.findMatches, source: this.findMatches,
@ -179,9 +188,14 @@ export default {
let w = $(this).autocomplete("widget").find("div"); let w = $(this).autocomplete("widget").find("div");
let regExpString = "(" + this.value + ")"; let regExpString = "(" + this.value + ")";
let re = new RegExp(regExpString, "i"); let re = new RegExp(regExpString, "i");
w.html((i, html) => html.replace(re, "<span style='font-weight: bold;'>$1</span>")); w.html((i, html) =>
html.replace(re, "<span style='font-weight: bold;'>$1</span>")
);
}, 5); }, 5);
}, },
select: function (event, ui) {
select(ui.item.value);
},
}); });
}, 0); }, 0);
}, },