mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-21 23:58:06 +00:00
Adds radio-button proxy component called radio-button-composer. Ember radio button only passes along radio value to container component, the proxy bind the name of the radio target, effectively providng two arguments, and also ensures the requried components of name, groupValue and value are passed along on instantiation
This commit is contained in:
parent
543716c624
commit
25c3524ead
34
wherehows-web/app/components/radio-button-composer.js
Normal file
34
wherehows-web/app/components/radio-button-composer.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,11 @@
|
|||||||
|
{{#radio-button
|
||||||
|
value=value
|
||||||
|
groupValue=groupValue
|
||||||
|
required=required
|
||||||
|
disabled=disabled
|
||||||
|
name=name
|
||||||
|
radioId=radioId
|
||||||
|
radioClass=radioClass
|
||||||
|
changed=(action "changed" name)}}
|
||||||
|
{{yield}}
|
||||||
|
{{/radio-button}}
|
Loading…
x
Reference in New Issue
Block a user