autocomplete for promoted text labels

This commit is contained in:
azivner
2018-08-06 22:52:49 +02:00
parent 90e9297ec5
commit d3e44b37e9
2 changed files with 21 additions and 1 deletions

View File

@@ -265,6 +265,26 @@ async function loadAttributes() {
if (valueAttr.type === 'label') {
if (definition.labelType === 'text') {
$input.prop("type", "text");
const attributeValues = await server.get('attributes/values/' + encodeURIComponent(valueAttr.name));
if (attributeValues.length === 0) {
return;
}
$input.autocomplete({
// shouldn't be required and autocomplete should just accept array of strings, but that fails
// because we have overriden filter() function in autocomplete.js
source: attributeValues.map(attribute => {
return {
attribute: attribute,
value: attribute
}
}),
minLength: 0
});
$input.focus(() => $input.autocomplete("search", ""));
}
else if (definition.labelType === 'number') {
$input.prop("type", "number");