diff --git a/addon/components/paper-radio-base.hbs b/addon/components/paper-radio-base.hbs index 6ad9f686f..6ee21459e 100644 --- a/addon/components/paper-radio-base.hbs +++ b/addon/components/paper-radio-base.hbs @@ -4,6 +4,7 @@ {{if @warn " md-warn"}} {{if @accent " md-accent"}} {{if @primary " md-primary"}} + {{if @secondary " md-secondary"}} {{if this.focused " md-focused"}} {{@class}}' aria-checked={{this.ariaChecked}} diff --git a/addon/components/paper-radio-base.js b/addon/components/paper-radio-base.js index 2ff4c0324..798142656 100644 --- a/addon/components/paper-radio-base.js +++ b/addon/components/paper-radio-base.js @@ -47,18 +47,10 @@ export default class PaperRadioBase extends Focusable { super(owner, args); this.labelId = `${guidFor(this)}-label`; - this.shouldRegister = this.args.shouldRegister || false; + this.skipProxy = this.args.skipProxy || false; this.toggle = this.args.toggle || false; - if (this.shouldRegister) { - assert( - 'A parent component should be supplied to when shouldRegister=true', - this.args.parentComponent - ); - this.parent = this.args.parentComponent; - } - assert( ' requires an `onChange` action or null for no action.', this.args.onChange !== undefined @@ -72,10 +64,6 @@ export default class PaperRadioBase extends Focusable { @action didInsertNode(element) { this.element = element; this.registerListeners(element); - - if (this.shouldRegister) { - this.parent.registerChild(this); - } } @action didUpdateNode() { @@ -92,10 +80,6 @@ export default class PaperRadioBase extends Focusable { willDestroy() { super.willDestroy(...arguments); - - if (this.shouldRegister) { - this.parent.unregisterChild(this); - } } get value() { @@ -130,8 +114,4 @@ export default class PaperRadioBase extends Focusable { } } } - - processProxy() { - this.onClick(); - } } diff --git a/addon/components/paper-radio-proxiable.js b/addon/components/paper-radio-proxiable.js index 14e673fd5..444ebbd53 100644 --- a/addon/components/paper-radio-proxiable.js +++ b/addon/components/paper-radio-proxiable.js @@ -1,10 +1,14 @@ /** * @module ember-paper */ -import PaperRadioBase from './paper-radio-base'; +import PaperRadio from './paper-radio'; /** * @class PaperRadio * @extends PaperRadioBase */ -export default class PaperRadioProxiable extends PaperRadioBase {} +export default class PaperRadioProxiable extends PaperRadio { + processProxy() { + this.onClick(); + } +} diff --git a/addon/components/paper-radio.js b/addon/components/paper-radio.js index 15b71715e..e02b8f2f8 100644 --- a/addon/components/paper-radio.js +++ b/addon/components/paper-radio.js @@ -2,9 +2,61 @@ * @module ember-paper */ import PaperRadioBase from './paper-radio-base'; +import { action } from '@ember/object'; +import { assert } from '@ember/debug'; /** * @class PaperRadio * @extends PaperRadioBase */ -export default class PaperRadio extends PaperRadioBase {} +export default class PaperRadio extends PaperRadioBase { + /** + * The parent this component is bound to. + * @type {PaperRadioGroup|PaperForm|PaperItem|PaperTabs} + */ + parent; + /** + * Marks whether the component should register itself to the supplied parent + * @type {Boolean} + */ + shouldRegister; + /** + * Marks whether the component should skip being proxied. + * @type {Boolean} + */ + skipProxy; + + constructor(owner, args) { + super(owner, args); + + this.skipProxy = this.args.skipProxy || false; + this.shouldRegister = this.args.shouldRegister || false; + if (this.shouldRegister) { + assert( + 'A parent component should be supplied to when shouldRegister=true', + this.args.parentComponent + ); + this.parent = this.args.parentComponent; + } + } + + /** + * Performs any required DOM setup. + * @param element + */ + @action didInsertNode(element) { + super.didInsertNode(element); + + if (this.shouldRegister) { + this.parent.registerChild(this); + } + } + + willDestroy() { + super.willDestroy(...arguments); + + if (this.shouldRegister) { + this.parent.unregisterChild(this); + } + } +}