Skip to content

Commit

Permalink
Remove deprecated sendAction and attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
btecu committed Sep 13, 2018
1 parent 3118a4f commit 2995ad4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions addon/components/select-dropdown-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export default Component.extend({
classNameBindings: ['model.isSelected:es-highlight'],

click() {
this.attrs.select(this.get('model'));
this.select(this.get('model'));
},

mouseEnter() {
this.attrs.hover(this.get('model'));
this.hover(this.get('model'));
}
});
4 changes: 2 additions & 2 deletions addon/components/select-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default Component.extend({
},

select(node) {
this.attrs.select(node.content || node.id, true);
this.select(node.content || node.id, true);
}
},

Expand Down Expand Up @@ -150,7 +150,7 @@ export default Component.extend({
if (selected && this.get('list').includes(selected)) {
this.send('select', selected);
} else if (this.get('freeText')) {
this.attrs.select(this.get('token'));
this.select(this.get('token'));
}
},

Expand Down
23 changes: 15 additions & 8 deletions addon/components/x-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ export default Component.extend(Evented, {

this.set('token', query);
this.set('isDirty', true);
this.sendAction('onChange', query);

if (this.onChange) {
this.onChange(query);
}

if (isPresent(query)) {
this.open();
Expand All @@ -145,7 +148,11 @@ export default Component.extend(Evented, {

clear() {
this.setOption('', false, !this.get('multiple'));
this.sendAction('onClear');

if (this.onClear) {
this.onClear();
}

this.send('focus');
},

Expand Down Expand Up @@ -184,7 +191,7 @@ export default Component.extend(Evented, {
let values = this.get('values');
if (isPresent(values) && this.get('token') === '') {
let last = this.getElement(values, get(values, 'length') - 1);
this.attrs.onRemove(last);
this.onRemove(last);
e.preventDefault();
}

Expand Down Expand Up @@ -221,13 +228,13 @@ export default Component.extend(Evented, {
},

remove(selection) {
this.attrs.onRemove(selection);
this.onRemove(selection);
this.send('focus');
},

select(option, selected) {
let isNew = !selected && this.get('freeText') && this.get('isDirty');
let allowNew = isPresent(this.attrs.onCreate);
let allowNew = isPresent(this.onCreate);
let valid = isPresent(option);

/* Notify when option is either
Expand All @@ -236,7 +243,7 @@ export default Component.extend(Evented, {
let notify = selected || isNew && !allowNew;

if (allowNew && valid && isNew) {
this.attrs.onCreate(option);
this.onCreate(option);
}

this.setOption(option, selected, notify);
Expand Down Expand Up @@ -308,8 +315,8 @@ export default Component.extend(Evented, {

this.set('isDirty', false);

if (notify) {
this.sendAction('onSelect', value, option, selected);
if (notify && this.onSelect) {
this.onSelect(value, option, selected);
this.set('isOpen', false);
}
}
Expand Down

0 comments on commit 2995ad4

Please sign in to comment.