d509588cd2
Ember update - update ember-cli, ember-data, and ember to 3.4 series
34 lines
951 B
JavaScript
34 lines
951 B
JavaScript
import Component from '@ember/component';
|
|
import { set, get, defineProperty, computed } from '@ember/object';
|
|
|
|
export default Component.extend({
|
|
tagName: 'button',
|
|
type: 'button',
|
|
toggleTarget: null,
|
|
toggleAttr: null,
|
|
classNameBindings: ['buttonClass'],
|
|
attributeBindings: ['type'],
|
|
buttonClass: 'has-text-info',
|
|
classNames: ['button', 'is-transparent'],
|
|
openLabel: 'Hide options',
|
|
closedLabel: 'More options',
|
|
init() {
|
|
this._super(...arguments);
|
|
const toggleAttr = this.get('toggleAttr');
|
|
defineProperty(
|
|
this,
|
|
'isOpen',
|
|
computed(`toggleTarget.${toggleAttr}`, () => {
|
|
const props = this.getProperties('toggleTarget', 'toggleAttr');
|
|
return get(props.toggleTarget, props.toggleAttr);
|
|
})
|
|
);
|
|
},
|
|
click() {
|
|
const target = this.get('toggleTarget');
|
|
const attr = this.get('toggleAttr');
|
|
const current = get(target, attr);
|
|
set(target, attr, !current);
|
|
},
|
|
});
|