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);
|
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
this.set("checkedInternal", this.checked);
|
2017-04-12 22:52:52 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
@observes("checked")
|
|
|
|
checkedChanged() {
|
2019-05-27 16:15:39 +08:00
|
|
|
this.set("checkedInternal", this.checked);
|
2017-04-12 22:52:52 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
@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() {
|
2019-05-27 16:15:39 +08:00
|
|
|
this.set("checkedInternal", this.checked);
|
2017-04-12 22:52:52 +08:00
|
|
|
},
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
finished() {
|
2019-05-27 16:15:39 +08:00
|
|
|
this.set("checked", this.checkedInternal);
|
2019-01-10 18:06:01 +08:00
|
|
|
this.action();
|
2017-04-12 22:52:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|