Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beta.ordbok.uib.no
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Språksamlingane
beta.ordbok.uib.no
Commits
e918fca4
Commit
e918fca4
authored
3 years ago
by
Henrik Askjer
Browse files
Options
Downloads
Patches
Plain Diff
simplify search suggestions
parent
0fd8bc4d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/Autocomplete.vue
+12
-37
12 additions, 37 deletions
src/components/Autocomplete.vue
with
12 additions
and
37 deletions
src/components/Autocomplete.vue
+
12
−
37
View file @
e918fca4
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
clearable
clearable
hide-no-data
hide-no-data
:autofocus="!$parent.article"
:autofocus="!$parent.article"
auto-select-first
no-filter
no-filter
hide-details
hide-details
label="Søk her"
label="Søk her"
...
@@ -83,13 +82,9 @@
...
@@ -83,13 +82,9 @@
{{data.item.label
}}
{{data.item.label
}}
</span>
</span>
<span v-if=
"
(
get_lang
()
==
'
bm,nn
'
)
"
>
<span v-if=
"
(
get_lang
()
==
'
bm,nn
'
)
"
>
({{[
"
bm
"
,
"
nn
"
,
"
bm
,
nn
"
][data.item.lang-1] ||
({{[
"
bm
"
,
"
nn
"
,
"
bm
,
nn
"
][data.item.lang-1]
}}
)
[
"
søker
...
"
,
"
ingen
treff
"
,
"
avansert
søk
"
][data.item.search]
}}
)
</span>
</span>
</template>
</template>
<template slot=
"
no
-
data
"
>
<div></div>
</template>
</v-combobox>
</v-combobox>
</div>
</div>
</template>
</template>
...
@@ -123,11 +118,13 @@ import Menu from './Menu.vue'
...
@@ -123,11 +118,13 @@ import Menu from './Menu.vue'
select(item) {
select(item) {
if (item) {
if (item) {
this.items = []
this.items = []
if (typeof item != 'string') {
if (typeof item == 'string') {
item = {q: item
}
}
this.suggesting = false
this.suggesting = false
this.submit(item)
this.submit(item)
}
}
}
}
}
}
,
}
,
...
@@ -141,44 +138,22 @@ import Menu from './Menu.vue'
...
@@ -141,44 +138,22 @@ import Menu from './Menu.vue'
run_query(q, time) {
run_query(q, time) {
q = q.trim()
q = q.trim()
this.suggesting = true
this.suggesting = true
// Search options while waiting for response
var search = 0
if (this.items[0]) {
if (this.items[0].time < time) {
if (/[_*%|]/.test(q)) {
search = 2
}
// Whitespace necessary in case option already exists in dropdown
this.items.splice(0,1, {q: q, label: q +
"
"
, time: time, search: search
}
)
}
}
else {
this.items.push({q: q, label: q, time: time, search: search
}
)
}
if (!/[_*%|]/.test(q)) {
if (!/[_*%|]/.test(q)) {
let self = this
let self = this
let scope = self.$parent.scope
let params = {q, dict: self.get_lang(), n: 10, dform: 'int', meta: 'n'
}
let params = {q, dict: self.get_lang(), n: 10, scope, dform: 'int', meta: 'n'
}
if ( self.$parent.pos_selected !=
"
ALL
"
) params.wc = self.$parent.pos_selected
self.api.get('suggest?', {params
}
)
self.api.get('suggest?', {params
}
)
.then(async (response) => {
.then(async (response) => {
if (self.$refs.autocomplete.searchInput == q & self.suggesting) {
if (self.$refs.autocomplete.searchInput == q & self.suggesting) {
let suggestions = []
let suggestions = []
if (scope.includes(
"
w
"
)) {
suggestions = response.data.a.w.map(item => ({q: q, match: item[0], label: item[0], time: time, lang: [item[1]], w: true
}
))
suggestions = response.data.a.w.map(item => ({q: q, match: item[0], label: item[0], time: time, lang: [item[1]], w: true
}
))
if (suggestions.length) {
self.items = suggestions
}
}
if (scope.includes(
"
x
"
))
{
else
{
s
uggestions = suggestions.concat(response.data.a.x.map(
item =
> ({q: q, match: item[0], label: item[0], time: time, lang: [item[1]]
}
)))
s
elf.
item
s
=
[]
}
}
if (!suggestions.length) {
self.items = [{q: q, label: q, time: time, search: 1
}
]
}
else {
self.items = suggestions
}
}
}
self.loading = false
self.loading = false
}
)
}
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment