datahub/wherehows-web/app/components/radio-button-composer.js

35 lines
687 B
JavaScript

import Ember from 'ember';
const {
Component,
get
} = Ember;
export default Component.extend({
tagName: '',
didReceiveAttrs() {
this._super(...arguments);
const attrs = this.attrs;
['name', 'groupValue', 'value'].forEach(attr => {
if (!(attr in attrs)) {
throw new Error(
`Attribute '${attr}' is required to be passed in when instantiating this component.`
);
}
});
},
actions: {
changed() {
const closureAction = get(this, 'attrs.changed');
if (typeof closureAction === 'function') {
return closureAction(...arguments);
}
this.sendAction('changed', ...arguments);
}
}
});