2018-06-15 11:03:24 -04:00
|
|
|
import {
|
|
|
|
default as computed,
|
|
|
|
observes
|
|
|
|
} from "ember-addons/ember-computed-decorators";
|
2017-04-12 10:52:52 -04:00
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
2018-06-15 11:03:24 -04:00
|
|
|
init() {
|
2017-04-12 10:52:52 -04:00
|
|
|
this._super();
|
|
|
|
this.set("checkedInternal", this.get("checked"));
|
|
|
|
},
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
classNames: ["inline-edit"],
|
2017-04-12 10:52:52 -04:00
|
|
|
|
|
|
|
@observes("checked")
|
|
|
|
checkedChanged() {
|
|
|
|
this.set("checkedInternal", this.get("checked"));
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed("labelKey")
|
|
|
|
label(key) {
|
|
|
|
return I18n.t(key);
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed("checked", "checkedInternal")
|
|
|
|
changed(checked, checkedInternal) {
|
2018-06-15 11:03:24 -04:00
|
|
|
return !!checked !== !!checkedInternal;
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2018-06-15 11:03:24 -04:00
|
|
|
cancelled() {
|
2017-04-12 10:52:52 -04:00
|
|
|
this.set("checkedInternal", this.get("checked"));
|
|
|
|
},
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
finished() {
|
2017-04-12 10:52:52 -04:00
|
|
|
this.set("checked", this.get("checkedInternal"));
|
|
|
|
this.sendAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|