mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
Custom fields: better error reporting when an exception occurs while finalizing the form
SVN:trunk[3956]
This commit is contained in:
@@ -69,13 +69,23 @@ $(function()
|
||||
json_obj: this.options.oWizardHelper.UpdateWizardToJSON()
|
||||
},
|
||||
function(data){
|
||||
me._onUpdateSuccess(data, sFormPath);
|
||||
if ('form' in data) {
|
||||
me._onUpdateSuccess(data, sFormPath);
|
||||
}
|
||||
}
|
||||
)
|
||||
.fail(function(data){ me._onUpdateFailure(data, sFormPath); })
|
||||
.always(function(data){
|
||||
me.alignColumns();
|
||||
$(me.element.find('[data-form-path="' + sFormPath + '"]')).unblock();
|
||||
var oContainer = $(me.element.find('[data-form-path="' + sFormPath + '"]'));
|
||||
oContainer.unblock();
|
||||
if ('error' in data) {
|
||||
oContainer.block({message: data.error});
|
||||
console.log('Update field failure: '+data.error);
|
||||
$('.blockOverlay').click(function(){
|
||||
oContainer.unblock();
|
||||
});
|
||||
}
|
||||
me._onUpdateAlways(data, sFormPath);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -2456,17 +2456,25 @@ EOF
|
||||
$sRequestedFieldsFormPath = utils::ReadParam('form_path', '');
|
||||
$sJson = utils::ReadParam('json_obj', '', false, 'raw_data');
|
||||
|
||||
$oWizardHelper = WizardHelper::FromJSON($sJson);
|
||||
$oObj = $oWizardHelper->GetTargetObject();
|
||||
|
||||
$oOrmCustomFieldValue = $oObj->Get($sAttCode);
|
||||
$oForm = $oOrmCustomFieldValue->GetForm();
|
||||
$oSubForm = $oForm->FindSubForm($sRequestedFieldsFormPath);
|
||||
$oRenderer = new \Combodo\iTop\Renderer\Console\ConsoleFormRenderer($oSubForm);
|
||||
$aRenderRes = $oRenderer->Render($aRequestedFields);
|
||||
|
||||
$aResult = array();
|
||||
$aResult['form']['updated_fields'] = $aRenderRes;
|
||||
|
||||
try
|
||||
{
|
||||
$oWizardHelper = WizardHelper::FromJSON($sJson);
|
||||
$oObj = $oWizardHelper->GetTargetObject();
|
||||
|
||||
$oOrmCustomFieldValue = $oObj->Get($sAttCode);
|
||||
$oForm = $oOrmCustomFieldValue->GetForm();
|
||||
$oSubForm = $oForm->FindSubForm($sRequestedFieldsFormPath);
|
||||
$oRenderer = new \Combodo\iTop\Renderer\Console\ConsoleFormRenderer($oSubForm);
|
||||
$aRenderRes = $oRenderer->Render($aRequestedFields);
|
||||
|
||||
$aResult['form']['updated_fields'] = $aRenderRes;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$aResult['error'] = $e->getMessage();
|
||||
}
|
||||
$oPage->add(json_encode($aResult));
|
||||
break;
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ class Form
|
||||
{
|
||||
if (!array_key_exists($sSomeId, $this->aFields))
|
||||
{
|
||||
throw new Exception('Missing dependancy : Field ' . $sImpactedBy . ' expecting field ' . $sSomeId . ' which is not in the Form');
|
||||
throw new Exception('Unmet dependency : Field ' . $sImpactedBy . ' expecting field ' . $sSomeId . ' which is not in the Form');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user