This commit is contained in:
James Cole
2020-10-29 14:42:24 +01:00
parent b75c221626
commit 1ed71ea742
5 changed files with 21 additions and 32 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -110,20 +110,7 @@ export default {
aSyncFunction: function (query, done) {
axios.get(this.categoryAutoCompleteURI + query)
.then(res => {
// loop over data
let escapedData = [];
let current;
for (const key in res.data) {
if (res.data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
current = res.data[key];
//current.name_html = res.data[key].name;
//current.name = this.escapeHtml(res.data[key].name);
//current.name = res.data[key].name;
escapedData.push(current);
}
}
done(escapedData);
done(res.data);
})
.catch(err => {
// any error handler

View File

@@ -53,7 +53,15 @@
:target="target"
item-key="description"
v-on:input="selectedItem"
></typeahead>
>
<template slot="item" slot-scope="props">
<li v-for="(item, index) in props.items" :class="{active:props.activeIndex===index}">
<a role="button" @click="props.select(item)">
<span v-html="betterHighlight(item)"></span>
</a>
</li>
</template>
</typeahead>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
@@ -83,23 +91,17 @@ export default {
aSyncFunction: function (query, done) {
axios.get(this.descriptionAutoCompleteURI + query)
.then(res => {
// loop over data
let escapedData = [];
let current;
for (const key in res.data) {
if (res.data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
current = res.data[key];
current.description = this.escapeHtml(res.data[key].description)
escapedData.push(current);
}
}
done(escapedData);
done(res.data);
})
.catch(err => {
// any error handler
})
},
betterHighlight: function (item) {
var inputValue = this.$refs.descr.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
var escapedName = this.escapeHtml(item.description);
return escapedName.replace(new RegExp(("" + inputValue), 'i'), '<b>$&</b>');
},
escapeHtml: function (string) {
let entityMap = {

View File

@@ -1686,9 +1686,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001135:
version "1.0.30001151"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001151.tgz#1ddfde5e6fff02aad7940b4edb7d3ac76b0cb00b"
integrity sha512-Zh3sHqskX6mHNrqUerh+fkf0N72cMxrmflzje/JyVImfpknscMnkeJrlFGJcqTmaa0iszdYptGpWMJCRQDkBVw==
version "1.0.30001153"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001153.tgz#9a0942fe777cd7178fb084693b79415ff747ecd9"
integrity sha512-qv14w7kWwm2IW7DBvAKWlCqGTmV2XxNtSejJBVplwRjhkohHuhRUpeSlPjtu9erru0+A12zCDUiSmvx/AcqVRA==
chalk@^1.1.3:
version "1.1.3"