Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beta.ordbok.uib.no
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
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
Margunn.Rauset
beta.ordbok.uib.no
Commits
6aa71596
Commit
6aa71596
authored
3 years ago
by
Henrik Askjer
Browse files
Options
Downloads
Patches
Plain Diff
Use timestamp to evaluate the need for verbatim suggestion
parent
138b0433
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
+10
-9
10 additions, 9 deletions
src/components/Autocomplete.vue
with
10 additions
and
9 deletions
src/components/Autocomplete.vue
+
10
−
9
View file @
6aa71596
...
@@ -52,10 +52,11 @@
...
@@ -52,10 +52,11 @@
}
,
}
,
watch
:
{
watch
:
{
search
(
val
)
{
search
(
val
)
{
const
time
=
Date
.
now
()
if
(
!
val
)
{
if
(
!
val
)
{
this
.
items
=
[]
this
.
items
=
[]
}
else
{
}
else
{
this
.
run_query
(
val
)
this
.
run_query
(
val
,
time
)
}
}
}
,
}
,
select
(
item
)
{
select
(
item
)
{
...
@@ -81,17 +82,17 @@
...
@@ -81,17 +82,17 @@
}
}
}
,
}
,
methods
:
{
methods
:
{
run_query
(
q
)
{
run_query
(
q
,
time
)
{
this
.
suggesting
=
true
this
.
suggesting
=
true
// Keep full text search in the list while requesting suggestions
// Keep full text search in the list while requesting suggestions
if
(
this
.
items
[
0
])
{
if
(
this
.
items
[
0
])
{
if
(
this
.
items
[
0
].
lang
)
{
if
(
this
.
items
[
0
].
time
<
time
)
{
this
.
items
.
unshift
({
q
:
q
,
label
:
q
}
)
this
.
items
.
splice
(
0
,
1
,
{
q
:
q
,
label
:
q
,
time
:
time
}
)
}
else
{
this
.
items
[
0
]
=
{
q
:
q
,
label
:
q
}
}
}
}
}
else
{
this
.
items
.
push
({
q
:
q
,
label
:
q
,
time
:
time
}
)
}
let
self
=
this
let
self
=
this
self
.
api
.
get
(
'
suggest?
'
,
{
params
:
{
q
:
q
,
dict
:
self
.
$parent
.
lang
,
n
:
9
}}
)
self
.
api
.
get
(
'
suggest?
'
,
{
params
:
{
q
:
q
,
dict
:
self
.
$parent
.
lang
,
n
:
9
}}
)
.
then
(
async
(
response
)
=>
{
.
then
(
async
(
response
)
=>
{
...
@@ -100,7 +101,7 @@
...
@@ -100,7 +101,7 @@
let
hits
=
[]
let
hits
=
[]
response
.
data
.
forEach
((
item
,
i
)
=>
{
response
.
data
.
forEach
((
item
,
i
)
=>
{
let
match
=
item
[
0
]
let
match
=
item
[
0
]
let
hit
=
{
q
:
q
,
match
:
match
,
label
:
match
}
let
hit
=
{
q
:
q
,
match
:
match
,
label
:
match
,
time
:
time
}
hit
.
article_promise
=
self
.
api
.
get
(
'
articles?
'
,
{
params
:
{
lord
:
match
,
dict
:
self
.
$parent
.
lang
}}
)
hit
.
article_promise
=
self
.
api
.
get
(
'
articles?
'
,
{
params
:
{
lord
:
match
,
dict
:
self
.
$parent
.
lang
}}
)
...
@@ -109,7 +110,7 @@
...
@@ -109,7 +110,7 @@
}
);
}
);
// whitespace necessary because duplicates aren't allowed in the dropdown
// whitespace necessary because duplicates aren't allowed in the dropdown
hits
.
push
({
q
:
q
,
label
:
q
+
'
'
}
)
hits
.
push
({
q
:
q
,
label
:
q
+
'
'
,
time
:
time
}
)
self
.
items
=
hits
self
.
items
=
hits
}
}
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