Skip to content
Snippets Groups Projects
Commit bba216e9 authored by Henrik Askjer's avatar Henrik Askjer
Browse files

Merge branch 'replace_suggestion_api' into 'master'

Replace suggestion api

See merge request spraksamlingane/beta.ordbok.uib.no!48
parents d68167bc b5a7397f
No related branches found
No related tags found
No related merge requests found
......@@ -27,8 +27,8 @@
>
<template v-slot:item="data">
<span class="search-hit">
{{data.item.label}}
</span>
{{data.item.label}}
</span>
({{data.item.lang? data.item.lang[1] ? "bm, nn" : {"bob": "bm", "nob": "nn"}[data.item.lang[0]] : 'fritekstsøk'}})
</template>
</v-combobox>
......@@ -37,7 +37,6 @@
<script>
import axios from "axios"
import debounce from "debounce"
export default {
props: {
......@@ -50,30 +49,6 @@
search: null,
select: null,
suggesting: null,
debounced: debounce(function(q, self) {
self.loading = true
return axios.get(self.endpoint + 'suggest?', { params: {q: q,
dict: self.$parent.lang,
n: 9}} )
.then(
function(response) {
if (self.$refs.autocomplete.searchInput == q & self.suggesting) {
let hits = []
response.data.forEach((item, i) => {
let hit = {q: q, match: item[0], label: item[0], articles: []}
hit.lang = item[1]
hits.push(hit)
});
// whitespace necessary because duplicates aren't allowed in the dropdown
hits.push({q: q, label: q + ' '})
self.items = hits
}
self.loading = false
})
}, 100)
}
},
watch: {
......@@ -115,7 +90,7 @@
this.items = []
this.suggesting = false
}, 1)
}
// If blurred
else {
......@@ -136,7 +111,29 @@
this.items[0] = {q: q, label: q}
}
}
this.debounced(q, this)
let self = this
axios.get(self.endpoint + 'suggest?', { params: {q: q,
dict: self.$parent.lang,
n: 9}} )
.then(
function(response) {
if (self.$refs.autocomplete.searchInput == q & self.suggesting) {
let hits = []
response.data.forEach((item, i) => {
let hit = {q: q, match: item[0], label: item[0], articles: []}
hit.lang = item[1]
hits.push(hit)
});
// whitespace necessary because duplicates aren't allowed in the dropdown
hits.push({q: q, label: q + ' '})
self.items = hits
}
self.loading = false
})
},
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment