Skip to content

Commit

Permalink
No value chips when empty string (#37)
Browse files Browse the repository at this point in the history
* WIP on changing empty text chips to text no value chips

* Changed so translatable

* changed to computed property noValueLabel
  • Loading branch information
JockeCK authored and Patrik Kullman committed May 24, 2019
1 parent fd4dc17 commit abff4ac
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions paper-autocomplete-chips.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@
type: Boolean
},

noValueLabel: {
type: String,
computed: '_("No value", t)'
},

/**
* `<paper-autocomplete>` `queryFn`
*/
Expand All @@ -210,13 +215,13 @@
return;
}
return {
text: textValue.toString(),
text: textValue.toString() === '' ? this.noValueLabel : textValue.toString(),
value: item
};
}
const objText = item.toString();
return {
text: objText,
text: objText === '' ? this.noValueLabel : objText,
value: objText
};
},
Expand Down Expand Up @@ -350,6 +355,7 @@

};
}

/**
* Clear the selected items.
* @param {object} event Polymer event object.
Expand All @@ -373,10 +379,11 @@
* @returns {void}
*/
_getChipText(item, textProperty) {
if (typeof item === 'object') {
return this.get(textProperty, item) || item.text;
let localItem = item;
if (typeof text === 'object') {
localItem = this.get(textProperty, localItem) || localItem.text;
}
return item;
return localItem !== '' ? localItem : this.noValueLabel;
}
/**
* Update the selected items and request handle of suggestions.
Expand Down

0 comments on commit abff4ac

Please sign in to comment.