- Ppgrade jquery
- Early detection of table existency (on creation) - Replaced deprecated ajax calls (defer)
This commit is contained in:
@@ -938,7 +938,7 @@ class Databap extends PhpObject
|
||||
return self::jsonExport($asDoc);
|
||||
}
|
||||
|
||||
public function addTable($sSystem, $sTitle, $sDescription, $sKeyWords, $iPrevTableId=0)
|
||||
public function addTable($sSystem, $sTitle, $sDescription, $sKeyWords, $iPrevTableId, $bSimul=false)
|
||||
{
|
||||
$bCreation = ($iPrevTableId==0);
|
||||
$iDbTableId = 0;
|
||||
@@ -955,7 +955,7 @@ class Databap extends PhpObject
|
||||
//Check for existing table with the same name
|
||||
if($bCreation && $this->checkValue(self::TABL_TABLE, array('title'=>$sTitle))) $sDesc = 'Une documentation existe déjà pour la '.$sRightTableLink;
|
||||
elseif(!$bCreation && $iPrevTableId!=$this->getUpToDateId(self::TABL_TABLE, $sTitle)) $sDesc = 'Une version plus récente de cette documentation existe : '.$sRightTableLink;
|
||||
else
|
||||
elseif(!$bSimul)
|
||||
{
|
||||
//Load table into database
|
||||
$asData = array(MySqlManager::getId(self::USER_TABLE)=>$this->getUserId(), 'title'=>$sTitle, 'description'=>$sDescription, 'system'=>$sSystem, 'keywords'=>$sKeyWords);
|
||||
|
||||
@@ -50,6 +50,7 @@ $bFirstConn = isset($_GET['first_conn'])?$_GET['first_conn']:false;
|
||||
$iMessageId = isset($_GET['message_id'])?$_GET['message_id']:0;
|
||||
$oItemId = isset($_REQUEST['id'])?$_REQUEST['id']:0;
|
||||
$sSystem = isset($_POST['system'])?$_POST['system']:'';
|
||||
$bSimul = isset($_POST['simul'])?$_POST['simul']:false;
|
||||
$sResult = '';
|
||||
|
||||
//Launching application
|
||||
@@ -110,7 +111,7 @@ if($bUserOk && $sAction!=Databap::EXT_ACCESS)
|
||||
$sResult = $oDatabap->getDoc($oItemId);
|
||||
break;
|
||||
case 'add_table':
|
||||
$sResult = $oDatabap->addTable($sSystem, $sTitle, $sDescription, $sKeyWords, $oItemId);
|
||||
$sResult = $oDatabap->addTable($sSystem, $sTitle, $sDescription, $sKeyWords, $oItemId, $bSimul);
|
||||
break;
|
||||
case 'get_table':
|
||||
$sResult = $oDatabap->getTable($oItemId);
|
||||
|
||||
98
jquery/databap.js
vendored
98
jquery/databap.js
vendored
@@ -429,37 +429,35 @@ function Databap()
|
||||
}
|
||||
};
|
||||
|
||||
this.saveForm = function(action, $form, fOnSuccess, bProcessIcon, dataType)
|
||||
this.saveForm = function(action, $form, fOnSuccess, bProcessIcon, dataType, asVars)
|
||||
{
|
||||
var sFormVars = $form.serialize();
|
||||
var sFormVars = $form.serialize()+($.isEmptyObject(asVars)?'':'&'+$.param(asVars));
|
||||
bProcessIcon = bProcessIcon || false;
|
||||
if(bProcessIcon) self.addBufferIcon();
|
||||
if(!dataType) dataType = 'text';
|
||||
|
||||
self.vars.loading = true;
|
||||
$.ajax
|
||||
(
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
url: self.getActionLink(action),
|
||||
data: sFormVars,
|
||||
success:function(result)
|
||||
{
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = false;
|
||||
if(bProcessIcon) self.resetIcon();
|
||||
fOnSuccess(result);
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = true;
|
||||
debug('Error databap.js 331');
|
||||
self.showError(textStatus);
|
||||
},
|
||||
dataType: dataType
|
||||
}
|
||||
);
|
||||
})
|
||||
.done(function(result)
|
||||
{
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = false;
|
||||
if(bProcessIcon) self.resetIcon();
|
||||
fOnSuccess(result);
|
||||
})
|
||||
.fail(function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = true;
|
||||
debug('Error databap.js 331');
|
||||
self.showError(textStatus);
|
||||
});
|
||||
};
|
||||
|
||||
this.getInfo = function(action, fOnSuccess, vars, type, fOnError, bProcessIcon)
|
||||
@@ -471,41 +469,39 @@ function Databap()
|
||||
|
||||
vars['a'] = action;
|
||||
self.vars.loading = true;
|
||||
$.ajax
|
||||
(
|
||||
$.ajax(
|
||||
{
|
||||
url: self.consts.process_url,
|
||||
data: vars,
|
||||
success: function(result)
|
||||
{
|
||||
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
|
||||
{
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = false;
|
||||
if(bProcessIcon) self.resetIcon();
|
||||
fOnSuccess(result);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
if(jqXHR.responseText==self.consts.errors.disconnected) databap.refresh();
|
||||
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = true;
|
||||
debug('Error databap.js 361');
|
||||
if(bProcessIcon) self.resetIcon();
|
||||
if(!fOnError)
|
||||
{
|
||||
self.showError(textStatus);
|
||||
debug(textStatus+' '+errorThrown);
|
||||
}
|
||||
else fOnError(textStatus);
|
||||
},
|
||||
dataType: type
|
||||
}
|
||||
);
|
||||
})
|
||||
.done(function(result)
|
||||
{
|
||||
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
|
||||
{
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = false;
|
||||
if(bProcessIcon) self.resetIcon();
|
||||
fOnSuccess(result);
|
||||
}
|
||||
})
|
||||
.fail(function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
if(jqXHR.responseText==self.consts.errors.disconnected) databap.refresh();
|
||||
|
||||
self.vars.loading = false;
|
||||
self.vars.disconnected = true;
|
||||
debug('Error databap.js 361');
|
||||
if(bProcessIcon) self.resetIcon();
|
||||
if(!fOnError)
|
||||
{
|
||||
self.showError(textStatus);
|
||||
debug(textStatus+' '+errorThrown);
|
||||
}
|
||||
else fOnError(textStatus);
|
||||
});
|
||||
};
|
||||
|
||||
this.getSyncInfo = function(action, vars)
|
||||
|
||||
10
jquery/jquery.min.js
vendored
10
jquery/jquery.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -60,7 +60,7 @@ function Table(oTable)
|
||||
this.sFeedBackBoxId = '#validation';
|
||||
tableself = this;
|
||||
|
||||
$('#title').addDefaultValue('Nom de la table');
|
||||
$('#title').addDefaultValue('Nom de la table').blur(tableself.checkTitle);
|
||||
$('#description').addDefaultValue('Description');
|
||||
$('#validation').addButton('dummy', '', function(){}, this.ACTION_BTN_ID, '', this.ACTION_BTN_ID);
|
||||
this.$Button = databap.tmp(this.ACTION_BTN_ID);
|
||||
@@ -143,10 +143,11 @@ Table.prototype.setDisplay = function(sDisplay)
|
||||
databap.updateScrollBar();
|
||||
};
|
||||
|
||||
Table.prototype.save = function()
|
||||
Table.prototype.save = function(bSimul)
|
||||
{
|
||||
bSimul = bSimul || false;
|
||||
var $Form = $('#table_info');
|
||||
if($Form.checkForm())
|
||||
if(bSimul || $Form.checkForm())
|
||||
{
|
||||
databap.saveForm
|
||||
(
|
||||
@@ -154,19 +155,19 @@ Table.prototype.save = function()
|
||||
$Form,
|
||||
function(asData)
|
||||
{
|
||||
if(asData.result == databap.consts.success)
|
||||
{
|
||||
databap.goToInternalLink('table', asData.name.toUpperCase());
|
||||
//tableself.iTableId = asData.name;
|
||||
//tableself.applyTableInfo();
|
||||
}
|
||||
else databap.addErrorBefore(asData.desc, tableself.sFeedBackBoxId);
|
||||
if(asData.result == databap.consts.success) databap.goToInternalLink('table', asData.name.toUpperCase());
|
||||
else if(asData.desc!='') databap.addErrorBefore(asData.desc, tableself.sFeedBackBoxId);
|
||||
},
|
||||
true,
|
||||
'json'
|
||||
!bSimul,
|
||||
'json',
|
||||
{simul:bSimul?1:0}
|
||||
);
|
||||
}
|
||||
else databap.addWarningBefore('Formulaire incomplet', tableself.sFeedBackBoxId);
|
||||
};
|
||||
|
||||
Table.prototype.checkTitle = function()
|
||||
{
|
||||
if($('#title').val()!='') tableself.save(true);
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user