Skip to content

Commit

Permalink
Use ember-power-select publicAPI in autocomplete (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustInToCoding authored and miguelcobain committed Nov 29, 2017
1 parent 5da2611 commit c76b515
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
18 changes: 9 additions & 9 deletions addon/components/paper-autocomplete-trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ export default Component.extend({
);
}),

text: computed('selected', 'searchText', '_innerText', {
text: computed('select', 'searchText', '_innerText', {
get() {
let {
selected,
select,
searchText,
_innerText
} = this.getProperties('selected', 'searchText', '_innerText');
} = this.getProperties('select', 'searchText', '_innerText');

if (selected) {
if (select && select.selected) {
return this.getSelectedAsText();
}
return searchText ? searchText : _innerText;
},
set(_, v) {
let { selected, searchText } = this.getProperties('selected', 'searchText');
let { select, searchText } = this.getProperties('select', 'searchText');
this.set('_innerText', v);

// searchText should always win
if (!selected && isPresent(searchText)) {
if (!(select && select.selected) && isPresent(searchText)) {
return searchText;
}

Expand Down Expand Up @@ -129,7 +129,7 @@ export default Component.extend({

handleInputLocal(e) {
// If something is already selected when the user types, it should clear selection
if (this.get('selected')) {
if (this.get('select.selected')) {
this.get('select').actions.select(null);
}
this.get('onInput')(e.target ? e : { target: { value: e } });
Expand All @@ -146,9 +146,9 @@ export default Component.extend({
getSelectedAsText() {
let labelPath = this.get('extra.labelPath');
if (labelPath) {
return this.get(`selected.${labelPath}`);
return this.get(`select.selected.${labelPath}`);
} else {
return this.get('selected');
return this.get('select.selected');
}
}
});
2 changes: 1 addition & 1 deletion addon/templates/components/paper-autocomplete-trigger.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
{{#if (and select.loading select.isActive)}}
{{paper-progress-linear classNameBindings="extra.label:md-inline"}}
{{/if}}
{{#if (and (or selected text) allowClear (not select.disabled))}}
{{#if (and (or select.selected text) allowClear (not select.disabled))}}
{{#paper-reset-button onReset=(action "clear") onDidTransitionOut=(action "resetButtonDestroyed") tabindex="-1"}}
{{paper-icon "close"}}
{{/paper-reset-button}}
Expand Down
1 change: 0 additions & 1 deletion addon/templates/components/paper-autocomplete.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
searchText=(readonly searchText)
validationErrorMessages=(readonly validationErrorMessages)
select=(readonly publicAPI)
selected=(readonly selected)
selectedItemComponent=(readonly selectedItemComponent)
hideAllMessages=(readonly hideAllMessages)}}
{{yield publicAPI selected}}
Expand Down

0 comments on commit c76b515

Please sign in to comment.