lib/netzke/form_panel_js.rb in netzke-basepack-0.5.4 vs lib/netzke/form_panel_js.rb in netzke-basepack-0.5.5
- old
+ new
@@ -48,27 +48,27 @@
this.reader = new Ext.data.RecordArrayReader({root:"data"}, Record);
delete this.clmns; // we don't need them anymore
// Now let Ext.form.FormPanel do the rest
- Ext.netzke.cache.FormPanel.superclass.initComponent.call(this);
+ #{js_full_class_name}.superclass.initComponent.call(this);
// Apply event
this.addEvents('apply');
}
END_OF_JAVASCRIPT
# Defaults for each field
:defaults => {
- # :anchor => '-20', # to leave some space for the scrollbar
- :width => 180,
+ :anchor => '-20', # to leave some space for the scrollbar
+ # :width => 180, # we do NOT want fixed size because it doesn't look nice when resizing
:listeners => {
# On "return" key, submit the form
:specialkey => {
:fn => <<-END_OF_JAVASCRIPT.l
function(field, event){
- if (event.getKey() == 13) this.ownerCt.apply();
+ if (event.getKey() == 13) this.ownerCt.onApply();
}
END_OF_JAVASCRIPT
}
}
},
@@ -83,11 +83,11 @@
}
END_OF_JAVASCRIPT
:load_record => <<-END_OF_JAVASCRIPT.l,
function(id, neighbour){
- this.load({id:id});
+ this.netzkeLoad({id:id});
}
END_OF_JAVASCRIPT
# :previous => <<-END_OF_JAVASCRIPT.l,
# function() {
@@ -104,14 +104,33 @@
# END_OF_JAVASCRIPT
:on_apply => <<-END_OF_JAVASCRIPT.l
function() {
if (this.fireEvent('apply', this)) {
- var values = this.form.getValues();
+ var values = this.getForm().getValues();
for (var k in values) {
if (values[k] == "") {delete values[k]}
}
- this.submit(Ext.apply((this.baseParams || {}), {data:Ext.encode(values)}));
+ if (this.fileUpload) {
+ // Not a Netzke's standard API call, because the form is multipart
+ this.getForm().submit({
+ url: this.id + '__netzke_submit',
+ params: {
+ data: Ext.encode(values)
+ },
+ failure: function(form, action){
+ // It will always be failure, as we don't play along with the Ext success indication (not returning {success: true})
+ this.bulkExecute(Ext.decode(action.response.responseText));
+ this.fireEvent('submitsuccess');
+ },
+ scope: this
+ });
+ } else {
+ // Submit the data and process the result
+ this.netzkeSubmit(Ext.apply((this.baseParams || {}), {data:Ext.encode(values)}), function(result){
+ if (result === "ok") {this.fireEvent("submitsuccess")};
+ }, this);
+ }
}
}
END_OF_JAVASCRIPT
}
end
\ No newline at end of file