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 @@ ...@@ -27,8 +27,8 @@
> >
<template v-slot:item="data"> <template v-slot:item="data">
<span class="search-hit"> <span class="search-hit">
{{data.item.label}} {{data.item.label}}
</span> </span>
({{data.item.lang? data.item.lang[1] ? "bm, nn" : {"bob": "bm", "nob": "nn"}[data.item.lang[0]] : 'fritekstsøk'}}) ({{data.item.lang? data.item.lang[1] ? "bm, nn" : {"bob": "bm", "nob": "nn"}[data.item.lang[0]] : 'fritekstsøk'}})
</template> </template>
</v-combobox> </v-combobox>
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
<script> <script>
import axios from "axios" import axios from "axios"
import debounce from "debounce"
export default { export default {
props: { props: {
...@@ -50,30 +49,6 @@ ...@@ -50,30 +49,6 @@
search: null, search: null,
select: null, select: null,
suggesting: 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: { watch: {
...@@ -115,7 +90,7 @@ ...@@ -115,7 +90,7 @@
this.items = [] this.items = []
this.suggesting = false this.suggesting = false
}, 1) }, 1)
} }
// If blurred // If blurred
else { else {
...@@ -136,7 +111,29 @@ ...@@ -136,7 +111,29 @@
this.items[0] = {q: q, label: q} 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