create table display on event "table not found"
This commit is contained in:
@@ -59,9 +59,13 @@ class Databap extends PhpObject
|
||||
const NAME_PASS_SEP = '-';
|
||||
|
||||
//HTTP Requests response
|
||||
const DISCONNECTED = '__DISCONNECTED__';
|
||||
const ERROR = '__ERROR__';
|
||||
const SUCCESS = '__SUCCESS__';
|
||||
const DISCONNECTED = '__DISCONNECTED__';
|
||||
const NOT_FOUND = '__NOT_FOUND__';
|
||||
const FAIL_INSERT = '__FAIL_INSERT__';
|
||||
const FAIL_UPDATE = '__FAIL_UPDATE__';
|
||||
const FAIL_DELETE = '__FAIL_DELETE__';
|
||||
|
||||
//Chat Constants
|
||||
//TODO Transfer these constants to chat page
|
||||
@@ -366,7 +370,7 @@ class Databap extends PhpObject
|
||||
'version_date'=>self::VERSION_DATE,
|
||||
'default_page'=>$sPage,
|
||||
'default_id'=>$oItemId,
|
||||
'disconnected'=>self::DISCONNECTED,
|
||||
'errors'=>array('disconnected'=>self::DISCONNECTED, 'not_found'=>self::NOT_FOUND, 'insert'=>self::FAIL_INSERT, 'update'=>self::FAIL_UPDATE, 'delete'=>self::FAIL_DELETE),
|
||||
'success'=>self::SUCCESS,
|
||||
'error'=>self::ERROR,
|
||||
'keep_alive'=>self::KEEP_ALIVE,
|
||||
@@ -982,7 +986,7 @@ class Databap extends PhpObject
|
||||
$sRightTableLink = '<a href="'.$this->getInternalLink('table', $asTable['title']).'" target="_blank">table '.self::getTableFormat($asTable['title']).'</a>';
|
||||
$asTable['warning'] = ($bReadById && $iTableId!=$this->getUpToDateId(self::TABL_TABLE, $iTableId))?'Il existe une documentation plus à jour pour la '.$sRightTableLink:'';
|
||||
}
|
||||
else $sDesc = 'Table '.$oTableId.' introuvable';
|
||||
else $sDesc = self::NOT_FOUND;
|
||||
|
||||
return $this->getJsonPostResult($bSuccess, $sDesc, $asTable);
|
||||
}
|
||||
@@ -1132,6 +1136,7 @@ class Databap extends PhpObject
|
||||
$asTable['title'] = self::getTableFormat($asTable['title']);
|
||||
$asTable['description'] = self::getDescriptionFormat($asTable['description']);
|
||||
$asTable['led'] = self::getDateFormat($asTable['led']);
|
||||
//$asTable['keywords'] = ToolBox::findReplaceLinks($asTable['description']);
|
||||
}
|
||||
return $asTable;
|
||||
}
|
||||
|
||||
18
jquery/databap.js
vendored
18
jquery/databap.js
vendored
@@ -476,7 +476,7 @@ function Databap()
|
||||
data: vars,
|
||||
success: function(result)
|
||||
{
|
||||
if(result==self.consts.disconnected) databap.refresh();
|
||||
if(result==self.consts.errors.disconnected) databap.refresh();
|
||||
else if((result==self.consts.error || typeof result.success != 'undefined' && result.success==self.consts.error) && typeof fOnError !== 'undefined') fOnError();
|
||||
else
|
||||
{
|
||||
@@ -488,7 +488,7 @@ function Databap()
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
if(jqXHR.responseText==self.consts.disconnected) databap.refresh();
|
||||
if(jqXHR.responseText==self.consts.errors.disconnected) databap.refresh();
|
||||
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = true;
|
||||
@@ -817,22 +817,26 @@ function Databap()
|
||||
return self.consts.mask_folder+sPageName+'.html?'+self.consts.time;
|
||||
};
|
||||
|
||||
this.addPunctuation = function(sMsg)
|
||||
{
|
||||
var asPunctuations = ['?', '!', '.', ',', ':', ';', '-', '/'];
|
||||
return sMsg+($.inArray(sMsg.slice(-1), asPunctuations)==-1?'.':'');
|
||||
};
|
||||
|
||||
this.addErrorBefore = function(msg, elem)
|
||||
{
|
||||
msg = msg+'.';
|
||||
self.addMsgBefore(msg, 'error', elem);
|
||||
self.addMsgBefore(this.addPunctuation(msg), 'error', elem);
|
||||
};
|
||||
|
||||
this.addWarningBefore = function(msg, elem)
|
||||
{
|
||||
msg = 'Attention : '+msg+'.';
|
||||
msg = 'Attention : '+this.addPunctuation(msg);
|
||||
self.addMsgBefore(msg, 'warning', elem);
|
||||
};
|
||||
|
||||
this.addSuccessBefore = function(msg, elem)
|
||||
{
|
||||
msg = msg+'.';
|
||||
self.addMsgBefore(msg, 'success', elem);
|
||||
self.addMsgBefore(this.addPunctuation(msg), 'success', elem);
|
||||
};
|
||||
|
||||
this.addMsgBefore = function(msg, msgClass, elem)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -79,10 +80,23 @@ Table.prototype.applyTableInfo = function()
|
||||
function(asData)
|
||||
{
|
||||
if(asData.result == databap.consts.error)
|
||||
{
|
||||
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
|
||||
{
|
||||
tableself.sTableName = asData.title;
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user