Permalink
Browse files

firefying 'apply' event in basepack

  • Loading branch information...
1 parent a07958d commit 4bb51646872a93a07bba5bbf87fdae47d4135518 @pschyska committed Mar 18, 2012
Showing with 28 additions and 27 deletions.
  1. +28 −27 lib/netzke/basepack/grid_panel/javascripts/event_handling.js
@@ -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
@@ -174,4 +175,4 @@
this.searchWindow.destroy();
}
}
-}
+}

0 comments on commit 4bb5164

Please sign in to comment.