2011-07-22 17:08:57 -04:00
|
|
|
/**
|
|
|
|
|
* Export PM Tables
|
|
|
|
|
* developed on date 2011-07-20
|
|
|
|
|
* @author Erik Amaru Ortiz <erik@colosa.com>
|
|
|
|
|
*/
|
2011-07-12 12:02:57 -04:00
|
|
|
|
2011-07-21 18:35:37 -04:00
|
|
|
var Export = function() {
|
|
|
|
|
return {
|
|
|
|
|
//config objects
|
|
|
|
|
windowConfig : {},
|
|
|
|
|
targetGridConfig : {},
|
|
|
|
|
|
|
|
|
|
// defining components
|
|
|
|
|
targetGrid : {},
|
|
|
|
|
window : {},
|
2011-07-22 17:08:57 -04:00
|
|
|
|
2011-07-21 18:35:37 -04:00
|
|
|
// init
|
|
|
|
|
init : function() {
|
|
|
|
|
Ext.form.Field.prototype.msgTarget = 'side';
|
|
|
|
|
Ext.QuickTips.init();
|
|
|
|
|
|
|
|
|
|
this.configure();
|
|
|
|
|
|
|
|
|
|
this.targetGrid = new Ext.grid.EditorGridPanel(this.targetGridConfig);
|
|
|
|
|
this.window = new Ext.Window(this.windowConfig);
|
|
|
|
|
this.window.add(this.targetGrid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}();
|
2011-07-12 12:02:57 -04:00
|
|
|
|
2011-07-22 17:08:57 -04:00
|
|
|
/**
|
|
|
|
|
* CONFIGURE ROUTINES
|
|
|
|
|
*/
|
2011-07-21 18:35:37 -04:00
|
|
|
Export.configure = function()
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* TARGET GRID CONFIG
|
|
|
|
|
*/
|
|
|
|
|
this.targetGridConfig = {
|
|
|
|
|
id : 'targetGrid',
|
2011-07-22 17:08:57 -04:00
|
|
|
title : _('ID_TABLES_TO_EXPORT'),
|
2011-07-21 18:35:37 -04:00
|
|
|
region: 'east',
|
|
|
|
|
width : 450,
|
|
|
|
|
split : true,
|
|
|
|
|
clicksToEdit: 2,
|
|
|
|
|
columnLines: true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.targetGridConfig.store = new Ext.data.ArrayStore({
|
|
|
|
|
fields: [
|
|
|
|
|
{name : 'ADD_TAB_UID'},
|
|
|
|
|
{name : 'ADD_TAB_NAME'},
|
|
|
|
|
{name : '_TYPE'},
|
|
|
|
|
{name : '_SCHEMA'},
|
|
|
|
|
{name : '_DATA'}
|
|
|
|
|
]
|
2011-07-12 12:02:57 -04:00
|
|
|
});
|
2011-07-21 18:35:37 -04:00
|
|
|
|
|
|
|
|
schemaColumn = new Ext.grid.CheckColumn({
|
2011-07-22 17:08:57 -04:00
|
|
|
header: _('ID_SCHEMA'),
|
2011-07-21 18:35:37 -04:00
|
|
|
dataIndex: '_SCHEMA',
|
|
|
|
|
width: 55,
|
|
|
|
|
checked: true
|
2011-07-12 12:02:57 -04:00
|
|
|
});
|
2011-07-21 18:35:37 -04:00
|
|
|
|
|
|
|
|
dataColumn = new Ext.grid.CheckColumn({
|
2011-07-22 17:08:57 -04:00
|
|
|
header: _('ID_DATA'),
|
2011-07-21 18:35:37 -04:00
|
|
|
dataIndex: '_DATA',
|
|
|
|
|
width: 55
|
2011-07-12 12:02:57 -04:00
|
|
|
});
|
2011-07-21 18:35:37 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
this.targetGridConfig.cm = new Ext.grid.ColumnModel({
|
|
|
|
|
defaults: {
|
|
|
|
|
sortable: true
|
|
|
|
|
},
|
|
|
|
|
columns: [
|
|
|
|
|
new Ext.grid.RowNumberer(),
|
|
|
|
|
{id:'ADD_TAB_UID', dataIndex: 'ADD_TAB_UID', hidden:true, hideable:false},
|
2011-07-22 17:08:57 -04:00
|
|
|
{header: _('ID_PMTABLE'), dataIndex: 'ADD_TAB_NAME', width: 300},
|
|
|
|
|
{header: _('ID_TYPE'), dataIndex: '_TYPE', width:100},
|
2011-07-21 18:35:37 -04:00
|
|
|
schemaColumn,
|
|
|
|
|
dataColumn
|
|
|
|
|
]
|
2011-07-12 12:02:57 -04:00
|
|
|
});
|
2011-07-21 18:35:37 -04:00
|
|
|
|
|
|
|
|
this.targetGridConfig.plugins = [schemaColumn, dataColumn];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WINDOW CONFIG
|
|
|
|
|
*/
|
|
|
|
|
this.windowConfig = {
|
|
|
|
|
title: '',
|
|
|
|
|
layout: 'fit',
|
2011-07-22 17:08:57 -04:00
|
|
|
width: 570,
|
2011-07-21 18:35:37 -04:00
|
|
|
height: 400,
|
|
|
|
|
modal: true,
|
|
|
|
|
autoScroll: true,
|
|
|
|
|
maximizable: true,
|
|
|
|
|
closeAction: 'hide',
|
|
|
|
|
maximizable : false,
|
2011-07-22 17:08:57 -04:00
|
|
|
items: []
|
2011-07-21 18:35:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.windowConfig.buttons = [{
|
|
|
|
|
text: 'Export',
|
|
|
|
|
handler: Export.submit
|
|
|
|
|
},{
|
|
|
|
|
text: 'Cancel',
|
|
|
|
|
handler: function(){
|
|
|
|
|
Export.window.hide();
|
|
|
|
|
}
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
} //end configure
|
|
|
|
|
|
2011-07-22 17:08:57 -04:00
|
|
|
/**
|
|
|
|
|
* EXPORT ROUTINE
|
|
|
|
|
*/
|
2011-07-21 18:35:37 -04:00
|
|
|
Export.submit = function()
|
|
|
|
|
{
|
|
|
|
|
var rows = Export.targetGrid.getStore();
|
|
|
|
|
var rowsData = new Array();
|
|
|
|
|
|
|
|
|
|
for (i=0; i < rows.getCount(); i++) {
|
|
|
|
|
row = rows.getAt(i);
|
|
|
|
|
if ( row.data._SCHEMA == false && row.data._DATA == false) {
|
2011-07-22 17:08:57 -04:00
|
|
|
PMExt.info(_('ID_INFO'), _('ID_PMTABLES_NOTICE_EXPORT'));
|
2011-07-21 18:35:37 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
rowsData.push(row.data);
|
|
|
|
|
}
|
2011-07-12 12:02:57 -04:00
|
|
|
|
2011-07-21 18:35:37 -04:00
|
|
|
Ext.Msg.show({
|
2011-07-22 17:08:57 -04:00
|
|
|
title : '',
|
|
|
|
|
msg : _('ID_PROCESSING'),
|
2011-07-21 18:35:37 -04:00
|
|
|
wait: true,
|
|
|
|
|
waitConfig: {interval:500}
|
|
|
|
|
});
|
2011-07-12 12:02:57 -04:00
|
|
|
|
2011-07-21 18:35:37 -04:00
|
|
|
|
|
|
|
|
Ext.Ajax.request({
|
|
|
|
|
url: 'pmTablesProxy/export',
|
|
|
|
|
params: {
|
|
|
|
|
rows : Ext.util.JSON.encode(rowsData)
|
|
|
|
|
},
|
|
|
|
|
success: function(resp){
|
|
|
|
|
Ext.Msg.hide();
|
|
|
|
|
Export.window.hide();
|
|
|
|
|
result = Ext.util.JSON.decode(resp.responseText);
|
|
|
|
|
|
|
|
|
|
if (result.success) {
|
|
|
|
|
location.href = result.link;
|
|
|
|
|
} else {
|
|
|
|
|
PMExt.error(_('ID_ERROR', result.message));
|
2011-07-12 12:02:57 -04:00
|
|
|
}
|
2011-07-21 18:35:37 -04:00
|
|
|
},
|
|
|
|
|
failure: function(obj, resp){
|
|
|
|
|
Ext.Msg.alert( _('ID_ERROR'), resp.result.msg);
|
2011-07-12 12:02:57 -04:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2011-07-21 18:35:37 -04:00
|
|
|
}
|
2011-07-12 12:02:57 -04:00
|
|
|
|
2011-07-21 18:35:37 -04:00
|
|
|
Ext.onReady(Export.init, Export, true);
|
2011-07-12 12:02:57 -04:00
|
|
|
|
|
|
|
|
|