Skip to content

Commit

Permalink
firefying 'apply' event in basepack
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Schyska committed Mar 18, 2012
1 parent a07958d commit 4bb5164
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions lib/netzke/basepack/grid_panel/javascripts/event_handling.js
Expand Up @@ -37,38 +37,39 @@
},

onApply: function(){
var newRecords = [],
updatedRecords = [],
store = this.getStore();

Ext.each(store.getUpdatedRecords().concat(store.getNewRecords()),
function(r) {
if (r.isNew) {
newRecords.push(r.data); // HACK: r.data seems private
} else {
updatedRecords.push(Ext.apply(r.getChanges(), {id:r.getId()}));
}
},
this);
if (this.fireEvent('apply') {
var newRecords = [],
updatedRecords = [],
store = this.getStore();

if (newRecords.length > 0 || updatedRecords.length > 0) {
var params = {};
Ext.each(store.getUpdatedRecords().concat(store.getNewRecords()),
function(r) {
if (r.isNew) {
newRecords.push(r.data); // HACK: r.data seems private
} else {
updatedRecords.push(Ext.apply(r.getChanges(), {id:r.getId()}));
}
},
this);

if (newRecords.length > 0) {
params.created_records = Ext.encode(newRecords);
}
if (newRecords.length > 0 || updatedRecords.length > 0) {
var params = {};

if (updatedRecords.length > 0) {
params.updated_records = Ext.encode(updatedRecords);
}
if (newRecords.length > 0) {
params.created_records = Ext.encode(newRecords);
}

if (this.getStore().getProxy().extraParams !== {}) {
params.base_params = Ext.encode(this.getStore().getProxy().extraParams);
}
if (updatedRecords.length > 0) {
params.updated_records = Ext.encode(updatedRecords);
}

this.postData(params);
}
if (this.getStore().getProxy().extraParams !== {}) {
params.base_params = Ext.encode(this.getStore().getProxy().extraParams);
}

this.postData(params);
}
}
},

// Handlers for tools
Expand Down Expand Up @@ -174,4 +175,4 @@
this.searchWindow.destroy();
}
}
}
}

0 comments on commit 4bb5164

Please sign in to comment.