2018-06-15 23:03:24 +08:00
|
|
|
import {
|
|
|
|
default as computed,
|
|
|
|
observes
|
|
|
|
} from "ember-addons/ember-computed-decorators";
|
2017-04-12 22:52:52 +08:00
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
2019-01-10 18:06:01 +08:00
|
|
|
classNames: ["inline-edit"],
|
|
|
|
|
|
|
|
checked: null,
|
|
|
|
checkedInternal: null,
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
init() {
|
2019-01-10 18:06:01 +08:00
|
|
|
this._super(...arguments);
|
|
|
|
|
2017-04-12 22:52:52 +08:00
|
|
|
this.set("checkedInternal", this.get("checked"));
|
|
|
|
},
|
|
|
|
|
|
|
|
@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 23:03:24 +08:00
|
|
|
return !!checked !== !!checkedInternal;
|
2017-04-12 22:52:52 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2018-06-15 23:03:24 +08:00
|
|
|
cancelled() {
|
2017-04-12 22:52:52 +08:00
|
|
|
this.set("checkedInternal", this.get("checked"));
|
|
|
|
},
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
finished() {
|
2017-04-12 22:52:52 +08:00
|
|
|
this.set("checked", this.get("checkedInternal"));
|
2019-01-10 18:06:01 +08:00
|
|
|
this.action();
|
2017-04-12 22:52:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|