Custom fields: better error reporting when an exception occurs while finalizing the form

SVN:trunk[3956]
This commit is contained in:
Romain Quetiez
2016-03-18 10:35:09 +00:00
parent af87ef3623
commit 81317d4df9
3 changed files with 31 additions and 13 deletions

View File

@@ -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);
});
},

View File

@@ -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;

View File

@@ -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');
}
}
}