Catch possible errors while Starting new case. Most of errors are due an invalid JSON response from server. So now that is catched and displayed

This commit is contained in:
Hugo Loza
2010-12-22 19:21:51 +00:00
parent c9e22777e7
commit 4c7009ea41

View File

@@ -119,7 +119,7 @@ var newCaseTree = {
msg : 'Starting new case<br><br><b>' + n.attributes.text msg : 'Starting new case<br><br><b>' + n.attributes.text
+ '</b>', + '</b>',
icon : Ext.MessageBox.INFO, icon : Ext.MessageBox.INFO,
//width:300, // width:300,
wait:true, wait:true,
waitConfig: {interval:500} waitConfig: {interval:500}
}); });
@@ -205,7 +205,7 @@ var startCaseTab = {
}, },
// minWidth : 150, // minWidth : 150,
//frame: true, // frame: true,
labelAlign: 'right', labelAlign: 'right',
labelWidth: 85, labelWidth: 85,
// width:340, // width:340,
@@ -219,7 +219,7 @@ var startCaseTab = {
name: 'processName', name: 'processName',
allowBlank:false, allowBlank:false,
value: '', value: '',
//disabled: true, // disabled: true,
// readonly:true, // readonly:true,
id:"processName" id:"processName"
},{ },{
@@ -227,7 +227,7 @@ var startCaseTab = {
name: 'taskName', name: 'taskName',
allowBlank:false, allowBlank:false,
value: '', value: '',
//disabled: true, // disabled: true,
id:"taskName" id:"taskName"
},{ },{
xtype:'textarea', xtype:'textarea',
@@ -235,33 +235,33 @@ var startCaseTab = {
name: 'processDescription', name: 'processDescription',
value: '', value: '',
readOnly: true, readOnly: true,
//disabled: true, // disabled: true,
id:"processDescription" id:"processDescription"
},{ },{
fieldLabel: 'Category', fieldLabel: 'Category',
name: 'processCategory', name: 'processCategory',
value: '', value: '',
readOnly: true, readOnly: true,
//disabled: true, // disabled: true,
id:"processCategory" id:"processCategory"
}, { }, {
fieldLabel: 'Calendar', fieldLabel: 'Calendar',
name: 'calendarName', name: 'calendarName',
//disabled: true, // disabled: true,
id:"calendarName" id:"calendarName"
},{ },{
xtype:'textarea', xtype:'textarea',
fieldLabel: 'Calendar Description', fieldLabel: 'Calendar Description',
name: 'calendarDescription', name: 'calendarDescription',
value: '', value: '',
//disabled: true, // disabled: true,
readOnly: true, readOnly: true,
id:"calendarDescription" id:"calendarDescription"
},{ },{
xtype:'checkboxgroup', xtype:'checkboxgroup',
fieldLabel: 'Working days', fieldLabel: 'Working days',
name: 'calendarWorkDays', name: 'calendarWorkDays',
//disabled: true, // disabled: true,
readOnly: true, readOnly: true,
id:"calendarWorkDays", id:"calendarWorkDays",
columns: 7, columns: 7,
@@ -278,7 +278,7 @@ var startCaseTab = {
xtype:'checkbox', xtype:'checkbox',
fieldLabel: 'Debug Mode', fieldLabel: 'Debug Mode',
name: 'processDebug', name: 'processDebug',
//disabled: true, // disabled: true,
readOnly: true, readOnly: true,
id:"processDebug" id:"processDebug"
}] }]
@@ -363,7 +363,8 @@ var startCaseTab = {
function chDir( directory, loadGridOnly ) { function chDir( directory, loadGridOnly ) {
//console.info("**** Changing Directory: "+directory+" -- "+loadGridOnly); // console.info("**** Changing Directory: "+directory+" --
// "+loadGridOnly);
if( datastore.directory.replace( /\//g, '' ) == directory.replace( /\//g, '' ) if( datastore.directory.replace( /\//g, '' ) == directory.replace( /\//g, '' )
&& datastore.getTotalCount() > 0 && directory != '') { && datastore.getTotalCount() > 0 && directory != '') {
// Prevent double loading // Prevent double loading
@@ -381,12 +382,12 @@ var startCaseTab = {
} }
function expandTreeToDir( node, dir ) { function expandTreeToDir( node, dir ) {
//console.info("Expanding Tree to Dir "+node+" - "+dir); // console.info("Expanding Tree to Dir "+node+" - "+dir);
dir = dir ? dir : new String(''); dir = dir ? dir : new String('');
var dirs = dir.split('/'); var dirs = dir.split('/');
if( dirs[0] == '') { dirs.shift(); } if( dirs[0] == '') { dirs.shift(); }
if( dirs.length > 0 ) { if( dirs.length > 0 ) {
//console.log("Dir to expand... "+dirs[0]); // console.log("Dir to expand... "+dirs[0]);
node = dirTree.getNodeById( dirs[0] ); node = dirTree.getNodeById( dirs[0] );
if( !node ) return; if( !node ) return;
if( node.isExpanded() ) { if( node.isExpanded() ) {
@@ -398,7 +399,7 @@ var startCaseTab = {
} }
} }
function expandNode( node, dir ) { function expandNode( node, dir ) {
//console.info("Expanding Node "+node+" - "+dir); // console.info("Expanding Node "+node+" - "+dir);
var fulldirpath, dirpath; var fulldirpath, dirpath;
var dirs = dir.split('/'); var dirs = dir.split('/');
@@ -441,13 +442,13 @@ var startCaseTab = {
} }
function handleNodeClick( sm, node ) { function handleNodeClick( sm, node ) {
if( node && node.id ) { if( node && node.id ) {
//console.log("Node Clicked: "+node); // console.log("Node Clicked: "+node);
chDir( node.id ); chDir( node.id );
} }
} }
function showLoadingIndicator( el, replaceContent ) { function showLoadingIndicator( el, replaceContent ) {
//console.info("showLoadingIndicator"); // console.info("showLoadingIndicator");
if( !el ) return; if( !el ) return;
var loadingimg = '/images/documents/_indicator.gif'; var loadingimg = '/images/documents/_indicator.gif';
var imgtag = '<' + 'img src="'+ loadingimg + '" alt="Loading..." border="0" name="Loading" align="absmiddle" />'; var imgtag = '<' + 'img src="'+ loadingimg + '" alt="Loading..." border="0" name="Loading" align="absmiddle" />';
@@ -460,8 +461,8 @@ var startCaseTab = {
} }
} }
function getURLParam( strParamName, myWindow){ function getURLParam( strParamName, myWindow){
//console.info("getURLParam"); // console.info("getURLParam");
//console.trace(); // console.trace();
if( !myWindow ){ if( !myWindow ){
myWindow = window; myWindow = window;
} }
@@ -482,7 +483,7 @@ var startCaseTab = {
} }
function openActionDialog( caller, action ) { function openActionDialog( caller, action ) {
//console.log("Dialog open: "+caller+" ->"+action); // console.log("Dialog open: "+caller+" ->"+action);
var dialog; var dialog;
var selectedRows = ext_itemgrid.getSelectionModel().getSelections(); var selectedRows = ext_itemgrid.getSelectionModel().getSelections();
if( selectedRows.length < 1 ) { if( selectedRows.length < 1 ) {
@@ -520,16 +521,16 @@ var startCaseTab = {
minHeight:200, minHeight:200,
proxyDrag: true, proxyDrag: true,
resizable: true, resizable: true,
//renderTo: Ext.getBody(), // renderTo: Ext.getBody(),
keys: { keys: {
key: 27, key: 27,
fn : function(){ fn : function(){
dialog.hide(); dialog.hide();
} }
}//, }// ,
// animateTarget: typeof caller.getEl == 'function' // animateTarget: typeof caller.getEl == 'function'
// ? caller.getEl() : caller, // ? caller.getEl() : caller,
//title: 'dialog_title' // title: 'dialog_title'
}); });
} }
@@ -572,7 +573,7 @@ var startCaseTab = {
// so we can simply // so we can simply
// add it to the // add it to the
// Window // Window
//console.log(json); // console.log(json);
dialog.add(json); dialog.add(json);
if( json.dialogtitle ) { if( json.dialogtitle ) {
// if the // if the
@@ -653,8 +654,8 @@ var startCaseTab = {
} }
} }
function handleCallback(requestParams, node) { function handleCallback(requestParams, node) {
//console.log("handleCallback "+requestParams +" -- "+node); // console.log("handleCallback "+requestParams +" -- "+node);
//console.trace(); // console.trace();
var conn = new Ext.data.Connection(); var conn = new Ext.data.Connection();
conn.request({ conn.request({
@@ -691,7 +692,7 @@ var startCaseTab = {
}); });
} }
function getRequestParams() { function getRequestParams() {
//console.info("Get Request params "); // console.info("Get Request params ");
var selitems, dir, node; var selitems, dir, node;
var selectedRows = ext_itemgrid.getSelectionModel().getSelections(); var selectedRows = ext_itemgrid.getSelectionModel().getSelections();
if( selectedRows.length < 1 ) { if( selectedRows.length < 1 ) {
@@ -719,7 +720,7 @@ var startCaseTab = {
} }
dir = datastore.directory; dir = datastore.directory;
} }
//Ext.Msg.alert("Debug", datastore.directory ); // Ext.Msg.alert("Debug", datastore.directory );
var requestParams = { var requestParams = {
option: 'new', option: 'new',
dir: datastore.directory, dir: datastore.directory,
@@ -791,10 +792,10 @@ var startCaseTab = {
function statusBarMessage( msg, isLoading, success ) { function statusBarMessage( msg, isLoading, success ) {
//console.log("Status Bar needed"); // console.log("Status Bar needed");
var statusBar = Ext.getCmp('statusPanel'); var statusBar = Ext.getCmp('statusPanel');
if( !statusBar ) return; if( !statusBar ) return;
//console.log("Status bar acceced: "+msg); // console.log("Status bar acceced: "+msg);
if( isLoading ) { if( isLoading ) {
statusBar.showBusy(); statusBar.showBusy();
} }
@@ -821,7 +822,7 @@ var startCaseTab = {
} }
function selectFile( dir, file ) { function selectFile( dir, file ) {
//console.log("file selected: "+dir+" - "+file); // console.log("file selected: "+dir+" - "+file);
chDir( dir ); chDir( dir );
var conn = datastore.proxy.getConnection(); var conn = datastore.proxy.getConnection();
if( conn.isLoading() ) { if( conn.isLoading() ) {
@@ -972,9 +973,9 @@ var gridtb = new Ext.Toolbar(
xtype : "tbbutton", xtype : "tbbutton",
id : 'tb_home', id : 'tb_home',
icon : '/images/documents/_home.png', icon : '/images/documents/_home.png',
//text : 'Root', // text : 'Root',
tooltip : 'Root Folder', tooltip : 'Root Folder',
//cls : 'x-btn-text-icon', // cls : 'x-btn-text-icon',
cls : 'x-btn-icon', cls : 'x-btn-icon',
handler : function() { handler : function() {
chDir(''); chDir('');
@@ -984,9 +985,9 @@ var gridtb = new Ext.Toolbar(
xtype : "tbbutton", xtype : "tbbutton",
id : 'tb_reload', id : 'tb_reload',
icon : '/images/documents/_reload.png', icon : '/images/documents/_reload.png',
//text : 'Reload', // text : 'Reload',
tooltip : 'Reload', tooltip : 'Reload',
//cls : 'x-btn-text-icon', // cls : 'x-btn-text-icon',
cls : 'x-btn-icon', cls : 'x-btn-icon',
handler : loadDir handler : loadDir
}, },
@@ -995,9 +996,9 @@ var gridtb = new Ext.Toolbar(
xtype : "tbbutton", xtype : "tbbutton",
id : 'tb_search', id : 'tb_search',
icon : '/images/documents/_filefind.png', icon : '/images/documents/_filefind.png',
//text : 'Search', // text : 'Search',
tooltip : 'Search', tooltip : 'Search',
//cls : 'x-btn-text-icon', // cls : 'x-btn-text-icon',
cls : 'x-btn-icon', cls : 'x-btn-icon',
disabled : true, disabled : true,
handler : function() { handler : function() {
@@ -1081,16 +1082,15 @@ var gridtb = new Ext.Toolbar(
disabled : false, disabled : false,
handler : function() { handler : function() {
/* /*
Ext.ux.OnDemandLoad * Ext.ux.OnDemandLoad
.load("/scripts/extjs3-ext/ux.swfupload/SwfUploadPanel.css"); * .load("/scripts/extjs3-ext/ux.swfupload/SwfUploadPanel.css");
Ext.ux.OnDemandLoad * Ext.ux.OnDemandLoad
.load("/scripts/extjs3-ext/ux.swfupload/SwfUpload.js"); * .load("/scripts/extjs3-ext/ux.swfupload/SwfUpload.js");
Ext.ux.OnDemandLoad * Ext.ux.OnDemandLoad .load(
.load( * "/scripts/extjs3-ext/ux.swfupload/SwfUploadPanel.js",
"/scripts/extjs3-ext/ux.swfupload/SwfUploadPanel.js", * function(options) { openActionDialog(this, 'upload');
function(options) { * });
openActionDialog(this, 'upload'); */
});*/
openActionDialog(this, 'uploadDocument'); openActionDialog(this, 'uploadDocument');
} }
}, },
@@ -1145,10 +1145,10 @@ var gridbb = new Ext.PagingToolbar({
store : datastore, store : datastore,
pageSize : 25 , pageSize : 25 ,
displayInfo : true, displayInfo : true,
//displayMsg : '% % %', // displayMsg : '% % %',
emptyMsg : 'No items to display', emptyMsg : 'No items to display',
beforePageText : 'Page', beforePageText : 'Page',
//afterPageText : 'of %', // afterPageText : 'of %',
firstText : 'First', firstText : 'First',
lastText : 'Last', lastText : 'Last',
nextText : 'Next', nextText : 'Next',
@@ -1267,7 +1267,7 @@ var cm = new Ext.grid.ColumnModel([ {
cm.defaultSortable = true; cm.defaultSortable = true;
function handleRowClick(sm, rowIndex) { function handleRowClick(sm, rowIndex) {
//console.log("Row Clicked: "+rowIndex); // console.log("Row Clicked: "+rowIndex);
var selections = sm.getSelections(); var selections = sm.getSelections();
tb = ext_itemgrid.getTopToolbar(); tb = ext_itemgrid.getTopToolbar();
if (selections.length > 1) { if (selections.length > 1) {
@@ -1292,8 +1292,8 @@ function handleRowClick(sm, rowIndex) {
// trigger the data store load // trigger the data store load
function loadDir() { function loadDir() {
//console.info("loadDir"); // console.info("loadDir");
//console.trace(); // console.trace();
datastore.load({ datastore.load({
params : { params : {
start : 0, start : 0,
@@ -1308,7 +1308,7 @@ function loadDir() {
} }
function rowContextMenu(grid, rowIndex, e, f) { function rowContextMenu(grid, rowIndex, e, f) {
//console.log("Context menu: "+grid+" - "+rowIndex); // console.log("Context menu: "+grid+" - "+rowIndex);
if (typeof e == 'object') { if (typeof e == 'object') {
e.preventDefault(); e.preventDefault();
} else { } else {
@@ -1384,7 +1384,7 @@ gridCtxMenu = new Ext.menu.Menu({
}); });
function dirContext(node, e) { function dirContext(node, e) {
//console.log("Dir context menu: "+node); // console.log("Dir context menu: "+node);
// Select the node that was right clicked // Select the node that was right clicked
node.select(); node.select();
// Unselect all files in the grid // Unselect all files in the grid
@@ -1728,9 +1728,11 @@ var documentsTab = {
.getSelections(); .getSelections();
if (!selections[0] if (!selections[0]
.get('is_file')) { .get('is_file')) {
//console.log(datastore.directory); // console.log(datastore.directory);
chDir(/*datastore.directory chDir(/*
+ "/"+*/selections[0] * datastore.directory +
* "/"+
*/selections[0]
.get('id')); .get('id'));
} else if (selections[0] } else if (selections[0]
.get('is_editable')) { .get('is_editable')) {
@@ -1773,23 +1775,22 @@ var documentsTab = {
// alert(Ext.getCmp("locationbarcmp")); // alert(Ext.getCmp("locationbarcmp"));
// Ext.getCmp("documents"). // Ext.getCmp("documents").
/* /*
if(typeof(sw_afterlayout)!="undefined"){ * if(typeof(sw_afterlayout)!="undefined"){
//console.log("starting locatiobar"); * //console.log("starting locatiobar");
Ext.getCmp("locationbarcmp").tree = Ext.getCmp("dirTree"); * Ext.getCmp("locationbarcmp").tree =
Ext.getCmp("locationbarcmp").initComponent(); * Ext.getCmp("dirTree");
//console.log("location abr started"); * Ext.getCmp("locationbarcmp").initComponent();
return; * //console.log("location abr started"); return; }
} */
*/ // console.log(typeof(sw_afterlayout));
//console.log(typeof(sw_afterlayout));
sw_afterlayout=true; sw_afterlayout=true;
ext_itemgrid = Ext.getCmp("gridpanel"); ext_itemgrid = Ext.getCmp("gridpanel");
//console.log("variable ext_itemgrid created"); // console.log("variable ext_itemgrid created");
//console.trace(); // console.trace();
ext_itemgrid.un('celldblclick', ext_itemgrid.onCellDblClick); ext_itemgrid.un('celldblclick', ext_itemgrid.onCellDblClick);
//console.log("celldoublde click removed"); // console.log("celldoublde click removed");
dirTree = Ext.getCmp("dirTree"); dirTree = Ext.getCmp("dirTree");
//console.log("dirtree created"); // console.log("dirtree created");
/* /*
* dirTree.loader.on('load', function(loader, o, * dirTree.loader.on('load', function(loader, o,
@@ -1800,7 +1801,7 @@ var documentsTab = {
*/ */
var tsm = dirTree.getSelectionModel(); var tsm = dirTree.getSelectionModel();
//console.log("tried to gtet selection model"); // console.log("tried to gtet selection model");
tsm.on('selectionchange', tsm.on('selectionchange',
handleNodeClick); handleNodeClick);
@@ -1813,14 +1814,14 @@ var documentsTab = {
blankText : 'A name is required', blankText : 'A name is required',
selectOnFocus : true selectOnFocus : true
}); });
//console.log("tree editor created"); // console.log("tree editor created");
//console.log("before the first chdir"); // console.log("before the first chdir");
chDir(''); chDir('');
//console.log("starting locatiobar first time"); // console.log("starting locatiobar first time");
Ext.getCmp("locationbarcmp").tree = Ext.getCmp("dirTree"); Ext.getCmp("locationbarcmp").tree = Ext.getCmp("dirTree");
Ext.getCmp("locationbarcmp").initComponent(); Ext.getCmp("locationbarcmp").initComponent();
//console.log("location abr started first time"); // console.log("location abr started first time");
} }
@@ -1891,11 +1892,12 @@ Ext
otherAttributes = selectedNode.attributes.otherAttributes; otherAttributes = selectedNode.attributes.otherAttributes;
calendarDays=(otherAttributes.CALENDAR_WORK_DAYS).split("|"); calendarDays=(otherAttributes.CALENDAR_WORK_DAYS).split("|");
calendarObj={}; calendarObj={};
for(i=0;i<calendarDays.length;i++){ for(i=0;i<calendarDays.length;i++){
calendarObj[calendarDays[i]]=true; calendarObj[calendarDays[i]]=true;
} }
//console.log(otherAttributes); // console.log(otherAttributes);
Ext.getCmp('process-detail-panel').getForm().setValues({ Ext.getCmp('process-detail-panel').getForm().setValues({
processName : otherAttributes.PRO_TITLE, processName : otherAttributes.PRO_TITLE,
taskName : selectedNode.attributes.text, taskName : selectedNode.attributes.text,