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

Disable full-text search and reintroduce word router name

parent 91430e15
No related branches found
Tags release_2021-11-24
No related merge requests found
......@@ -29,7 +29,7 @@
<span class="search-hit">
{{data.item.label}}
</span>
({{data.item.lang? data.item.lang[1] ? "bm, nn" : {"bob": "bm", "nob": "nn"}[data.item.lang[0]] : ["fulltekst","fritekst","avansert søk"][data.item.mode]}})
({{data.item.lang? data.item.lang[1] ? "bm, nn" : {"bob": "bm", "nob": "nn"}[data.item.lang[0]] : ["fulltekst","fritekst","avansert søk"][data.item.search]}})
</template>
<template slot="no-data">
<div></div>
......@@ -80,33 +80,39 @@
if (this.items[0]) {
if (this.items[0].time < time) {
if (/_|\*|\|/.test(q)) {
this.items.splice(0,1, {q: q, label: q, time: time, mode: 2})
} else {
this.items.splice(0,1, {q: q+"*", label: q, time: time, mode: 1})
this.items.splice(0,1, {q: q, label: q, time: time, search: 2})
}
else {
this.items.splice(0,1, {q: q+"*", label: q, time: time, search: 1})
}
}
}
else {
this.items.splice(0,1, {q: q+"*", label: q, time: time, mode: 1})
this.items.splice(0,1, {q: q+"*", label: q, time: time, search: 1})
}
let self = this
self.api.get('suggest?', {params: {q: q, dict: self.$parent.lang, n: 80, scope: 'nf'}})
self.api.get('suggest?', {params: {q: q, dict: self.$parent.lang, n: 80, scope: 'n'}})
.then(async (response) => {
if (self.$refs.autocomplete.searchInput == q & self.suggesting) {
let word_matches = response.data.a.n.map(item => ({q: q, match: item[0], label: item[0], time: time, lang: item[1]}))
let text_matches = response.data.a.f.map(item => ({q: q, match: item[0], label: item[0], time: time, mode: 0}))
let suggestions = response.data.a.n.map(item => ({q: q, match: item[0], label: item[0], time: time, lang: item[1]}))
/*
//let text_matches = response.data.a.f.map(item => ({q: q, match: item[0], label: item[0], time: time, search: 0}))
let suggestions = []
if( q.charAt(q.length-1) === '!') suggestions = text_matches.concat(word_matches)
else suggestions = word_matches.concat(text_matches)
*/
if (/_|\*|\|/.test(q)) {
suggestions.unshift({q: q, label: q, time: time, mode: 2})
} else {
suggestions.push({q: q+"*", label: q + ' ', time: time, mode: 1})
suggestions.unshift({q: q, label: q, time: time, search: 2})
}
else {
suggestions.push({q: q+"*", label: q + ' ', time: time, search: 1})
}
// whitespace necessary because duplicates aren't allowed in the dropdown
self.items = suggestions
......
......@@ -152,12 +152,11 @@ function navigate_to_search(self, query) {
}
*/
function navigate_to_word(self, word) {
function navigate_to_query(self, word) {
let query = self.event ? self.event : {q: word}
// Get article IDs
oda_api.get('articles?', {params: {lord: query.match || query.q, dict: self.lang}}).then((response) => {
oda_api.get('articles?', {params: {w: query.match || query.q, dict: self.lang, scope: "n"}}).then((response) => {
let article_ids = response.data
let unwrapped = []
for (const d in article_ids) {
......@@ -246,9 +245,10 @@ export default {
methods: {
select_result: function (event) {
this.event = event
let route = `/${this.lang}/search/${event.match || event.q}`
let name = event.search ? 'search' : 'w'
let route = `/${this.lang}/${name}/${event.match || event.q}`
this.$router.push(route)
navigate_to_word(this)
navigate_to_query(this)
// Tracking
let props = {query: event.q}
......@@ -259,9 +259,20 @@ export default {
},
update_lang_form: function (lang) {
this.lang = lang
let route = `/${this.lang}/search/${this.$route.params.query}`
let name = ""
let query = ""
if(this.$route.name == 'word') {
name = "w"
query = this.$route.params.word
}
else if (this.$route.name == 'search') {
name = "search"
query = this.$route.params.query
}
let route = `/${this.lang}/${name}/${query}`
navigate_to_query(this, query)
this.$router.push(route)
navigate_to_word(this, this.$route.params.query)
},
article_link_click: function(item) {
if (this.article && this.article.article_id == item.article_id){
......@@ -299,7 +310,11 @@ export default {
self.waiting_for_metadata = false
if(self.$route.name == 'search') {
self.lang = self.$route.params.lang
navigate_to_word(self, self.$route.params.query)
navigate_to_query(self, self.$route.params.query)
}
else if(self.$route.name == 'word') {
self.lang = self.$route.params.lang
navigate_to_query(self, self.$route.params.word)
}
else if(self.$route.name == 'lookup'){
navigate_to_article(self, self.$route.path)
......
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