Skip to content

Commit

Permalink
Merge pull request #4250 from eawag-rdm/autocomplete_tagsep
Browse files Browse the repository at this point in the history
autocomplete tagsep - fix
  • Loading branch information
smotornyuk committed May 30, 2018
2 parents 6be86af + c8c06c7 commit 7a8d37d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 6 additions & 3 deletions ckan/public/base/javascript/modules/autocomplete.js
Expand Up @@ -2,14 +2,15 @@
* a list of terms from an API endpoint (provided using data-module-source).
*
* source - A url pointing to an API autocomplete endpoint.
* interval - The interval between requests in milliseconds (default: 1000).
* interval - The interval between requests in milliseconds (default: 300).
* items - The max number of items to display (default: 10)
* tags - Boolean attribute if true will create a tag input.
* key - A string of the key you want to be the form value to end up on
* from the ajax returned results
* label - A string of the label you want to appear within the dropdown for
* returned results
*
* tokensep - A string that contains characters which will be interpreted
* as separators for tags when typed or pasted (default ",").
* Examples
*
* // <input name="tags" data-module="autocomplete" data-module-source="http://" />
Expand All @@ -24,6 +25,7 @@ this.ckan.module('autocomplete', function (jQuery) {
label: false,
items: 10,
source: null,
tokensep: ',',
interval: 300,
dropdownClass: '',
containerClass: ''
Expand All @@ -50,7 +52,8 @@ this.ckan.module('autocomplete', function (jQuery) {
formatNoMatches: this.formatNoMatches,
formatInputTooShort: this.formatInputTooShort,
dropdownCssClass: this.options.dropdownClass,
containerCssClass: this.options.containerClass
containerCssClass: this.options.containerClass,
tokenSeparators: this.options.tokensep.split('')
};

// Different keys are required depending on whether the select is
Expand Down
12 changes: 8 additions & 4 deletions ckan/public/base/test/spec/modules/autocomplete.spec.js
Expand Up @@ -65,7 +65,8 @@ describe('ckan.modules.AutocompleteModule()', function () {
formatNoMatches: this.module.formatNoMatches,
formatInputTooShort: this.module.formatInputTooShort,
createSearchChoice: this.module.formatTerm, // Not used by tags.
initSelection: this.module.formatInitialValue
initSelection: this.module.formatInitialValue,
tokenSeparators: [',']
});
});

Expand All @@ -82,7 +83,8 @@ describe('ckan.modules.AutocompleteModule()', function () {
formatResult: this.module.formatResult,
formatNoMatches: this.module.formatNoMatches,
formatInputTooShort: this.module.formatInputTooShort,
initSelection: this.module.formatInitialValue
initSelection: this.module.formatInitialValue,
tokenSeparators: [',']
});

it('should watch the keydown event on the select2 input');
Expand All @@ -100,7 +102,8 @@ describe('ckan.modules.AutocompleteModule()', function () {
formatResult: this.module.formatResult,
formatNoMatches: this.module.formatNoMatches,
formatInputTooShort: this.module.formatInputTooShort,
initSelection: this.module.formatInitialValue
initSelection: this.module.formatInitialValue,
tokenSeparators: [',']
});
});

Expand All @@ -117,7 +120,8 @@ describe('ckan.modules.AutocompleteModule()', function () {
formatResult: this.module.formatResult,
formatNoMatches: this.module.formatNoMatches,
formatInputTooShort: this.module.formatInputTooShort,
initSelection: this.module.formatInitialValue
initSelection: this.module.formatInitialValue,
tokenSeparators: [',']
});
});

Expand Down

0 comments on commit 7a8d37d

Please sign in to comment.