mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-23 10:18:56 +02:00
Added a stimulus controller for tagsinput.
This commit is contained in:
parent
f276c436ae
commit
f21c339046
3 changed files with 33 additions and 42 deletions
|
@ -8,10 +8,6 @@ import "bootstrap-fileinput/css/fileinput.css"
|
|||
import "./lib/jquery.tristate"
|
||||
import "bootstrap-fileinput";
|
||||
|
||||
import 'corejs-typeahead';
|
||||
const Bloodhound = require('corejs-typeahead/dist/bloodhound.js');
|
||||
import './lib/tagsinput';
|
||||
|
||||
|
||||
|
||||
const RegisterEventHelper = class {
|
||||
|
@ -25,8 +21,6 @@ const RegisterEventHelper = class {
|
|||
|
||||
this.registerSpecialCharInput();
|
||||
this.registerHoverPics();
|
||||
|
||||
this.registerAutocompleteTagsinput();
|
||||
}
|
||||
|
||||
registerLoadHandler(fn) {
|
||||
|
@ -96,42 +90,6 @@ const RegisterEventHelper = class {
|
|||
});
|
||||
})
|
||||
}
|
||||
|
||||
registerAutocompleteTagsinput() {
|
||||
this.registerLoadHandler(() => {
|
||||
$('input.tagsinput').each(function() {
|
||||
|
||||
//Use typeahead if an autocomplete url was specified.
|
||||
if($(this).data('autocomplete')) {
|
||||
|
||||
//@ts-ignore
|
||||
var engine = new Bloodhound({
|
||||
//@ts-ignore
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(''),
|
||||
//@ts-ignore
|
||||
queryTokenizer: Bloodhound.tokenizers.obj.whitespace(''),
|
||||
remote: {
|
||||
url: $(this).data('autocomplete'),
|
||||
wildcard: 'QUERY'
|
||||
}
|
||||
});
|
||||
|
||||
//@ts-ignore
|
||||
$(this).tagsinput({
|
||||
typeaheadjs: {
|
||||
name: 'tags',
|
||||
source: engine.ttAdapter()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else { //Init tagsinput without typeahead
|
||||
//@ts-ignore
|
||||
$(this).tagsinput();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
registerSpecialCharInput() {
|
||||
this.registerLoadHandler(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue