2019-10-30 21:48:24 +08:00
|
|
|
import { next } from "@ember/runloop";
|
2019-10-24 00:30:52 +08:00
|
|
|
import Component from "@ember/component";
|
2018-06-15 23:03:24 +08:00
|
|
|
import { observes, on } from "ember-addons/ember-computed-decorators";
|
2016-09-10 03:57:44 +08:00
|
|
|
|
2019-10-24 00:30:52 +08:00
|
|
|
export default Component.extend({
|
2018-06-15 23:03:24 +08:00
|
|
|
tagName: "label",
|
2016-09-10 03:57:44 +08:00
|
|
|
|
|
|
|
click(e) {
|
|
|
|
e.preventDefault();
|
2019-05-27 16:15:39 +08:00
|
|
|
this.onChange(this.radioValue);
|
2016-09-10 03:57:44 +08:00
|
|
|
},
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
@observes("value")
|
|
|
|
@on("init")
|
2016-09-10 03:57:44 +08:00
|
|
|
updateVal() {
|
2019-05-27 16:15:39 +08:00
|
|
|
const checked = this.value === this.radioValue;
|
2019-10-30 21:48:24 +08:00
|
|
|
next(
|
2019-07-16 18:45:15 +08:00
|
|
|
() => (this.element.querySelector("input[type=radio]").checked = checked)
|
|
|
|
);
|
2016-09-10 03:57:44 +08:00
|
|
|
}
|
|
|
|
});
|