Created
August 21, 2009 23:34
-
-
Save hannahwhy/172508 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.on('beforewrite', function (store, action, record, options) { | |
var proceed = !!(record.event && !record.event.phantom); | |
if (proceed && record.createInProgress) { | |
queued.push(record); | |
return false; | |
} | |
if (proceed && record.phantom) { | |
record.createInProgress = true; | |
} | |
}, this); | |
this.on('write', function (store, action, result, res, rs) { | |
Ext.each(rs, function (record) { | |
record.createInProgress = false; | |
}, this); | |
Ext.each(queued, function (record) { | |
record.commit(); | |
}, this); | |
queued = []; | |
}, this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PathCore.ExtExtensions.Store = Ext.extend(Ext.ux.data.serverSideErrors.Store, { | |
pendingRecords: [], | |
constructor: function (config) { | |
PathCore.ExtExtensions.Store.superclass.constructor.call(this, config); | |
}, | |
execute: function (action, rs, options) { | |
var didRequest = false, | |
partitioned = Ext.partition(rs, function (record) { | |
return record.responsePending; | |
}), | |
pending = partitioned[0], | |
quiescent = partitioned[1]; | |
this.pendingRecords.push(pending); | |
if (quiescent.length > 0) { | |
didRequest = PathCore.ExtExtensions.Store.superclass.execute.call(this, action, $.extend([], quiescent), options); | |
if (didRequest) { | |
this.touch(quiescent, true); | |
} | |
} | |
return didRequest; | |
}, | |
onCreateRecords: function (success, rs, data) { | |
this.touch(rs, false); | |
PathCore.ExtExtensions.Store.superclass.onCreateRecords.call(this, success, rs, data); | |
this.resubmitPending(); | |
}, | |
onUpdateRecords: function (success, rs, data) { | |
this.touch(rs, false); | |
PathCore.ExtExtensions.Store.superclass.onUpdateRecords.call(this, success, rs, data); | |
this.resubmitPending(); | |
}, | |
onDestroyRecords: function (success, rs, data) { | |
this.touch(rs, false); | |
PathCore.ExtExtensions.Store.superclass.onDestroyRecords.call(this, success, rs, data); | |
this.resubmitPending(); | |
}, | |
touch: function (rs, activate) { | |
Ext.each(rs, function (record) { | |
record.responsePending = activate; | |
}, this); | |
}, | |
resubmitPending: function () { | |
var pending = Ext.flatten($.extend([], this.pendingRecords)); | |
this.pendingRecords = []; | |
Ext.each(pending, function (record) { | |
record.commit(); | |
}, this); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment