create table display on event "table not found"

This commit is contained in:
lutranf
2014-08-27 16:46:27 +02:00
parent a9d54bcc4a
commit 27df89b0aa
4 changed files with 42 additions and 18 deletions

View File

@@ -43,7 +43,7 @@ databap.onResize = function()
//self.maximizeElem($('#keywords'), false, $('#table'));
};
function Table(iTableId)
function Table(oTable)
{
this.DISPLAY_EDIT = 'edit';
@@ -54,8 +54,9 @@ function Table(iTableId)
this.ERROR_CLASS = 'form_error';
this.sDisplay = '';
this.iTableId = iTableId || 0;
this.sTableName = '';
this.oTable = oTable;
this.iTableId = ($.type(oTable)=='number')?oTable:0;
this.sTableName = ($.type(oTable)=='string')?oTable:'';
this.sFeedBackBoxId = '#validation';
tableself = this;
@@ -64,7 +65,7 @@ function Table(iTableId)
$('#validation').addButton('dummy', '', function(){}, this.ACTION_BTN_ID, '', this.ACTION_BTN_ID);
this.$Button = databap.tmp(this.ACTION_BTN_ID);
if(this.iTableId>0 || this.iTableId!='')
if(this.iTableId>0 || this.sTableName!='')
{
this.applyTableInfo();
}
@@ -80,8 +81,21 @@ Table.prototype.applyTableInfo = function()
{
if(asData.result == databap.consts.error)
{
tableself.setDisplay(tableself.DISPLAY_ERROR);
databap.addErrorBefore(asData.desc, tableself.sFeedBackBoxId);
if(asData.desc == databap.consts.errors.not_found)
{
databap.addErrorBefore('Table '+tableself.oTable+' introuvable', tableself.sFeedBackBoxId);
if(tableself.sTableName!='')
{
tableself.setDisplay(tableself.DISPLAY_EDIT);
$('#title').val(tableself.sTableName).focus();
databap.addSuccessBefore('Mais vous pouvez la créer !', tableself.sFeedBackBoxId);
}
}
else
{
tableself.setDisplay(tableself.DISPLAY_ERROR);
databap.addErrorBefore(asData.desc, tableself.sFeedBackBoxId);
}
}
else
{
@@ -97,7 +111,7 @@ Table.prototype.applyTableInfo = function()
databap.updateScrollBar();
}
},
{id:this.iTableId},
{id:this.oTable},
'json',
function(){debug('Error: Unknown error thrown');},
true
@@ -146,7 +160,7 @@ Table.prototype.save = function()
{
if(asData.result == databap.consts.success)
{
databap.goToInternalLink('table', asData.name.toLowerCase());
databap.goToInternalLink('table', asData.name.toUpperCase());
//tableself.iTableId = asData.name;
//tableself.applyTableInfo();
}