Commit 24be3674 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

* Fix wrong windows closing, corrupt window data and other various issues

parent 61dcfb12
......@@ -50,10 +50,21 @@ Ext.extend(Ext.ux.JsonStore, Ext.data.JsonStore, {
// Create a generic window and specify the window, form and submission ajax configuration
Ext.ux.GenericFormWindow = function(windowConfig,formConfig,submitAjaxConfig) {
var panelID = Ext.id();
var windowID = Ext.id();
// Override button text?
var submitButtonText = 'Save';
if (submitAjaxConfig && submitAjaxConfig.submitButtonText) {
submitButtonText = submitAjaxConfig.submitButtonText;
}
// Form configuration
formConfig = Ext.apply({
xtype: 'progressformpanel',
id: 'formpanel',
id: panelID,
// AJAX connector
url: 'ajax.php',
......@@ -71,11 +82,11 @@ Ext.ux.GenericFormWindow = function(windowConfig,formConfig,submitAjaxConfig) {
// Buttons for the form
buttons: [
{
text: 'Save',
text: submitButtonText,
formBind: true,
handler: function() {
var panel = this.ownerCt;
var win = panel.ownerCt;
var panel = Ext.getCmp(panelID);
var win = Ext.getCmp(windowID);
var ajaxParams;
......@@ -98,18 +109,23 @@ Ext.ux.GenericFormWindow = function(windowConfig,formConfig,submitAjaxConfig) {
// Close window on success
success: function() {
win.close();
// Check if we have a custom function to execute on success
if (submitAjaxConfig.onSuccess) {
submitAjaxConfig.onSuccess();
}
}
});
}
},{
text: 'Cancel',
handler: function() {
var panel = this.ownerCt;
var win = panel.ownerCt;
var win = Ext.getCmp(windowID);
win.close();
}
}
]
],
// Align buttons
buttonAlign: 'center'
}, formConfig);
// Add any extra buttons we may have
......@@ -122,9 +138,10 @@ Ext.ux.GenericFormWindow = function(windowConfig,formConfig,submitAjaxConfig) {
// Apply our own window configuration
windowConfig = Ext.apply({
id: windowID,
layout: 'fit',
items: [
new Ext.ux.ProgressFormPanel(formConfig)
new Ext.ux.ProgressFormPanel(formConfig,submitAjaxConfig)
]
}, windowConfig);
......@@ -140,6 +157,9 @@ Ext.extend(Ext.ux.GenericFormWindow, Ext.Window, {
// Generic grid window
Ext.ux.GenericGridWindow = function(windowConfig,gridConfig,storeConfig,filtersConfig) {
var panelID = Ext.id();
var windowID = Ext.id();
// Setup data store
storeConfig = Ext.apply({
......@@ -155,7 +175,7 @@ Ext.ux.GenericGridWindow = function(windowConfig,gridConfig,storeConfig,filtersC
// Grid configuration
gridConfig = Ext.apply({
xtype: 'gridpanel',
id: 'gridpanel',
id: panelID,
plain: true,
......@@ -182,13 +202,12 @@ Ext.ux.GenericGridWindow = function(windowConfig,gridConfig,storeConfig,filtersC
{
text:'Close',
handler: function() {
var grid = this.ownerCt;
var win = grid.ownerCt;
var win = Ext.getCmp(windowID);
win.close();
}
}
],
buttonAlign:'center',
buttonAlign: 'center',
// Bottom bar
bbar: new Ext.PagingToolbar({
......@@ -204,6 +223,7 @@ Ext.ux.GenericGridWindow = function(windowConfig,gridConfig,storeConfig,filtersC
// Apply our own window configuration
windowConfig = Ext.apply({
id: windowID,
items: [
new Ext.grid.GridPanel(gridConfig)
]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment