2019-11-07 16:38:28 -05:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-10-23 13:06:54 -04:00
|
|
|
import Controller from "@ember/controller";
|
2018-06-15 11:03:24 -04:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
|
|
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
2013-04-04 12:59:44 -04:00
|
|
|
|
2019-10-23 13:06:54 -04:00
|
|
|
export default Controller.extend(bufferedProperty("siteText"), {
|
2015-11-23 16:45:05 -05:00
|
|
|
saved: false,
|
2013-04-04 12:59:44 -04:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("buffered.value")
|
2019-07-01 21:53:16 -04:00
|
|
|
saveDisabled(value) {
|
|
|
|
return this.siteText.value === value;
|
|
|
|
},
|
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
actions: {
|
2015-08-07 14:05:08 -04:00
|
|
|
saveChanges() {
|
2019-05-27 04:15:39 -04:00
|
|
|
const buffered = this.buffered;
|
|
|
|
this.siteText
|
2018-06-15 11:03:24 -04:00
|
|
|
.save(buffered.getProperties("value"))
|
|
|
|
.then(() => {
|
|
|
|
this.commitBuffer();
|
|
|
|
this.set("saved", true);
|
|
|
|
})
|
|
|
|
.catch(popupAjaxError);
|
2015-11-23 16:45:05 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
revertChanges() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("saved", false);
|
|
|
|
bootbox.confirm(I18n.t("admin.site_text.revert_confirm"), result => {
|
2015-11-23 16:45:05 -05:00
|
|
|
if (result) {
|
2019-05-27 04:15:39 -04:00
|
|
|
this.siteText
|
2018-06-15 11:03:24 -04:00
|
|
|
.revert()
|
|
|
|
.then(props => {
|
2019-05-27 04:15:39 -04:00
|
|
|
const buffered = this.buffered;
|
2018-06-15 11:03:24 -04:00
|
|
|
buffered.setProperties(props);
|
|
|
|
this.commitBuffer();
|
|
|
|
})
|
|
|
|
.catch(popupAjaxError);
|
2015-11-23 16:45:05 -05:00
|
|
|
}
|
|
|
|
});
|
2013-09-16 14:08:55 -04:00
|
|
|
}
|
2013-04-04 12:59:44 -04:00
|
|
|
}
|
2013-09-16 14:08:55 -04:00
|
|
|
});
|