Skip to content

Commit

Permalink
Added state update for inner records, so the parent record will be ma…
Browse files Browse the repository at this point in the history
…rked as dirty if an inner record is marked dirty. Now uses built in setDirty method.
  • Loading branch information
Munter committed Mar 18, 2011
1 parent 87b5f7f commit 1a45b98
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/platform/src/data/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ Ext.data.Model = Ext.extend(Ext.util.Stateful, {
}

this.set(data);
this.dirty = false;
this.unsetDirty();

if (this.getId()) {
this.phantom = false;
}
Expand Down Expand Up @@ -357,7 +357,7 @@ Ext.data.Model = Ext.extend(Ext.util.Stateful, {
//we need to make sure we've set the updated data here. Ideally this will be redundant once the
//ModelCache is in place
me.set(record.data);
record.dirty = false;
record.unsetDirty();

if (typeof successFn == 'function') {
successFn.call(scope, record, operation);
Expand Down
30 changes: 18 additions & 12 deletions src/platform/src/util/Stateful.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Ext.util.Stateful = Ext.extend(Ext.util.Observable, {

this[this.persistanceProperty][fieldName] = value;

this.dirty = true;
this.setDirty();

if (!this.editing) {
this.afterEdit();
Expand Down Expand Up @@ -154,8 +154,19 @@ Ext.util.Stateful = Ext.extend(Ext.util.Observable, {
this.fields.each(function(field) {
this.modified[field.name] = this[this.persistanceProperty][field.name];
}, this);

if (this.innerOf) {
this.innerOf.setDirty();
}
},


unsetDirty: function() {
this.dirty = false;
this.editing = false;

delete this.modified;
},

//<debug>
markDirty : function() {
throw new Error("Stateful: markDirty has been deprecated. Please use setDirty.");
Expand Down Expand Up @@ -183,11 +194,9 @@ Ext.util.Stateful = Ext.extend(Ext.util.Observable, {
this[this.persistanceProperty][field] = modified[field];
}
}

this.dirty = false;
this.editing = false;
delete this.modified;


this.unsetDirty();

if (silent !== true) {
this.afterReject();
}
Expand All @@ -202,11 +211,8 @@ Ext.util.Stateful = Ext.extend(Ext.util.Observable, {
* store of the change (defaults to false)
*/
commit : function(silent) {
this.dirty = false;
this.editing = false;

delete this.modified;

this.unsetDirty();

if (silent !== true) {
this.afterCommit();
}
Expand Down

0 comments on commit 1a45b98

Please sign in to comment.