mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Integrated algolia autocomplete search into navbar
This commit is contained in:
parent
60942c8254
commit
18eb0467ee
2 changed files with 21 additions and 2 deletions
|
@ -24,6 +24,8 @@ import {marked} from "marked";
|
|||
|
||||
export default class extends Controller {
|
||||
|
||||
static targets = ["input"];
|
||||
|
||||
_autocomplete;
|
||||
|
||||
connect() {
|
||||
|
@ -32,9 +34,24 @@ export default class extends Controller {
|
|||
// The URL template for the part detail pages
|
||||
const part_detail_uri_template = this.element.dataset.detailUrl;
|
||||
|
||||
const that = this;
|
||||
|
||||
this._autocomplete = autocomplete({
|
||||
container: this.element,
|
||||
panelContainer: document.body,
|
||||
panelPlacement: 'end',
|
||||
placeholder: "Search for parts",
|
||||
onSubmit({state, event, ...setters}) {
|
||||
//Put the current text into each target input field
|
||||
const input = that.inputTarget;
|
||||
|
||||
if (!input) {
|
||||
return;
|
||||
}
|
||||
|
||||
input.value = state.query;
|
||||
input.form.requestSubmit();
|
||||
},
|
||||
getSources({ query }) {
|
||||
return [
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue