2020-05-13 16:23:41 -04:00
|
|
|
import I18n from "I18n";
|
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";
|
2015-11-23 16:45:05 -05:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
|
|
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
2020-08-26 12:57:13 -04:00
|
|
|
import bootbox from "bootbox";
|
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
|
2015-11-23 16:45:05 -05:00
|
|
|
.save(buffered.getProperties("value"))
|
|
|
|
.then(() => {
|
|
|
|
this.commitBuffer();
|
|
|
|
this.set("saved", true);
|
|
|
|
})
|
|
|
|
.catch(popupAjaxError);
|
|
|
|
},
|
|
|
|
|
|
|
|
revertChanges() {
|
|
|
|
this.set("saved", false);
|
|
|
|
bootbox.confirm(I18n.t("admin.site_text.revert_confirm"), (result) => {
|
|
|
|
if (result) {
|
2019-05-27 04:15:39 -04:00
|
|
|
this.siteText
|
2015-11-23 16:45:05 -05:00
|
|
|
.revert()
|
|
|
|
.then((props) => {
|
2019-05-27 04:15:39 -04:00
|
|
|
const buffered = this.buffered;
|
2015-11-23 16:45:05 -05:00
|
|
|
buffered.setProperties(props);
|
|
|
|
this.commitBuffer();
|
|
|
|
})
|
|
|
|
.catch(popupAjaxError);
|
|
|
|
}
|
|
|
|
});
|
2013-09-16 14:08:55 -04:00
|
|
|
},
|
2013-04-04 12:59:44 -04:00
|
|
|
},
|
2013-09-16 14:08:55 -04:00
|
|
|
});
|