8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-26 22:52:26 +00:00

Ajoute des suggestions quand rien n'est écrit

This commit is contained in:
Maël Kervella 2017-10-06 00:27:34 +00:00
parent df360ddea7
commit 18c27f8369

View file

@ -142,7 +142,7 @@ def typeahead_choices( f_value ) :
'];' '];'
def typeahead_engine () : def typeahead_engine () :
return 'var choices = new Bloodhound({ ' \ return 'var engine = new Bloodhound({ ' \
'datumTokenizer: Bloodhound.tokenizers.obj.whitespace("value"), ' \ 'datumTokenizer: Bloodhound.tokenizers.obj.whitespace("value"), ' \
'queryTokenizer: Bloodhound.tokenizers.whitespace, ' \ 'queryTokenizer: Bloodhound.tokenizers.whitespace, ' \
'local: choices, ' \ 'local: choices, ' \
@ -153,7 +153,7 @@ def typeahead_datasets( f_name ) :
return '{ ' \ return '{ ' \
'hint: true, ' \ 'hint: true, ' \
'highlight: true, ' \ 'highlight: true, ' \
'minLength: 1 ' \ 'minLength: 0 ' \
'}, ' \ '}, ' \
'{ ' \ '{ ' \
'templates: { ' \ 'templates: { ' \
@ -161,7 +161,18 @@ def typeahead_datasets( f_name ) :
'}, ' \ '}, ' \
'display: "value", ' \ 'display: "value", ' \
'name: "'+f_name+'", ' \ 'name: "'+f_name+'", ' \
'source: choices ' \ 'source: function(q, sync) {' \
'if (q === "") {' \
'var nb = 10;' \
'var first = [] ;' \
'for ( var i = 0 ; i < nb ; i++ ) {' \
'first.push(choices[i].value);' \
'}' \
'sync(engine.get(first));' \
'} else {' \
'engine.search(q, sync)' \
'}' \
'}' \
'}' '}'
def typeahead_updater( f_name ): def typeahead_updater( f_name ):