Site Customization saving should use a promise instead of `success` callback.

This commit is contained in:
Robin Ward 2013-05-06 14:20:20 -04:00
parent e70526d851
commit a71a15913c
1 changed files with 11 additions and 12 deletions

View File

@ -11,7 +11,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
init: function() {
this._super();
return this.startTrackingChanges();
this.startTrackingChanges();
},
description: function() {
@ -55,7 +55,6 @@ Discourse.SiteCustomization = Discourse.Model.extend({
save: function() {
var _this = this;
this.set('savingStatus', Em.String.i18n('saving'));
this.set('saving',true);
var data = {
@ -65,19 +64,19 @@ Discourse.SiteCustomization = Discourse.Model.extend({
header: this.header,
override_default_style: this.override_default_style
};
var siteCustomization = this;
return Discourse.ajax({
url: Discourse.getURL("/admin/site_customizations") + (this.id ? '/' + this.id : ''),
data: {
site_customization: data
},
type: this.id ? 'PUT' : 'POST',
success: function(data) {
if (!_this.id) { _this.set('id', data.id); }
_this.set('savingStatus', Em.String.i18n('saved'));
_this.set('saving',false);
_this.startTrackingChanges();
}
data: { site_customization: data },
type: this.id ? 'PUT' : 'POST'
}).then(function (result) {
if (!siteCustomization.id) { siteCustomization.set('id', result.id); }
siteCustomization.set('savingStatus', Em.String.i18n('saved'));
siteCustomization.set('saving',false);
siteCustomization.startTrackingChanges();
});
},
destroy: function() {