fix autocomplete
This commit is contained in:
@@ -25,7 +25,7 @@ class SubmittersAutocompleteController < ApplicationController
|
|||||||
|
|
||||||
term = "#{params[:q].downcase}%"
|
term = "#{params[:q].downcase}%"
|
||||||
|
|
||||||
submitters.where(column.matches(term, false, true))
|
submitters.where(column.matches(term))
|
||||||
else
|
else
|
||||||
Submitters.search(submitters, params[:q])
|
Submitters.search(submitters, params[:q])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -45,11 +45,7 @@ export default class extends HTMLElement {
|
|||||||
this.currentFetch.then(async (resp) => {
|
this.currentFetch.then(async (resp) => {
|
||||||
const items = await resp.json()
|
const items = await resp.json()
|
||||||
|
|
||||||
if (q.length < 3) {
|
resolve(items)
|
||||||
resolve(items.filter((e) => e[this.dataset.field].startsWith(q)))
|
|
||||||
} else {
|
|
||||||
resolve(items)
|
|
||||||
}
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
resolve([])
|
resolve([])
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user