Fix newsletter editor to only save properties it changes

This commit is contained in:
Tautvidas Sipavičius
2016-10-20 13:37:32 +03:00
parent 42877236c8
commit c3a78b1ea3
2 changed files with 25 additions and 6 deletions

View File

@@ -11,7 +11,7 @@ define([
// Does not hold newsletter content nor newsletter styles, those are
// handled by other components.
Module.NewsletterModel = SuperModel.extend({
stale: ['body', 'created_at', 'deleted_at', 'updated_at'],
whitelisted: ['id', 'subject', 'preheader'],
initialize: function(options) {
this.on('change', function() {
App.getChannel().trigger('autoSave');
@@ -19,7 +19,7 @@ define([
},
toJSON: function() {
// Remove stale attributes from resulting JSON object
return _.omit(SuperModel.prototype.toJSON.call(this), this.stale);
return _.pick(SuperModel.prototype.toJSON.call(this), this.whitelisted);
},
});