mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 09:05:52 +02:00
Added recent searches to search
This commit is contained in:
parent
4398b8698c
commit
a3dcd1a0a8
3 changed files with 12 additions and 4 deletions
|
@ -20,6 +20,7 @@
|
|||
import { Controller } from "@hotwired/stimulus";
|
||||
import { autocomplete } from '@algolia/autocomplete-js';
|
||||
import "@algolia/autocomplete-theme-classic/dist/theme.css";
|
||||
import { createLocalStorageRecentSearchesPlugin } from '@algolia/autocomplete-plugin-recent-searches';
|
||||
import {marked} from "marked";
|
||||
|
||||
export default class extends Controller {
|
||||
|
@ -36,10 +37,17 @@ export default class extends Controller {
|
|||
|
||||
const that = this;
|
||||
|
||||
const recentSearchesPlugin = createLocalStorageRecentSearchesPlugin({
|
||||
key: 'RECENT_SEARCH',
|
||||
limit: 5,
|
||||
});
|
||||
|
||||
this._autocomplete = autocomplete({
|
||||
container: this.element,
|
||||
panelContainer: document.body,
|
||||
panelPlacement: 'end',
|
||||
plugins: [recentSearchesPlugin],
|
||||
openOnFocus: true,
|
||||
placeholder: "Search for parts",
|
||||
onSubmit({state, event, ...setters}) {
|
||||
//Put the current text into each target input field
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@algolia/autocomplete-js": "^1.17.0",
|
||||
"@algolia/autocomplete-plugin-redirect-url": "^1.17.0",
|
||||
"@algolia/autocomplete-plugin-recent-searches": "^1.17.0",
|
||||
"@algolia/autocomplete-theme-classic": "^1.17.0",
|
||||
"@ckeditor/ckeditor5-alignment": "^41.0.0",
|
||||
"@ckeditor/ckeditor5-autoformat": "^41.0.0",
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
dependencies:
|
||||
"@algolia/autocomplete-shared" "1.17.0"
|
||||
|
||||
"@algolia/autocomplete-plugin-redirect-url@^1.17.0":
|
||||
"@algolia/autocomplete-plugin-recent-searches@^1.17.0":
|
||||
version "1.17.0"
|
||||
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-plugin-redirect-url/-/autocomplete-plugin-redirect-url-1.17.0.tgz#843a7af551a29e6c5d2a6585c17b7dcff50bee12"
|
||||
integrity sha512-C/xvPKKM0+uHRvKDi7sE/P8qEtlo9lhDEB2YQJRY9X90osqlqwY4HqRZbauz4wGnHckrG0iqIN+xcCNEFN3Jxg==
|
||||
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-plugin-recent-searches/-/autocomplete-plugin-recent-searches-1.17.0.tgz#ed340649481398feee12a9e7f1bfd66f90e1fbab"
|
||||
integrity sha512-di5ZEFx0UgK7sR5pxon9NKiFrLL26J5xwL7ihhK4rHrSdRhSvRATr9d8uaShAZIveEUTMd/cZd6C+95Y1YrcdQ==
|
||||
dependencies:
|
||||
"@algolia/autocomplete-core" "1.17.0"
|
||||
"@algolia/autocomplete-js" "1.17.0"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue