mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
#930 AttributeExternalFields displayed in a form are automatically refreshed when their "parent" field is modified...
SVN:trunk[3186]
This commit is contained in:
@@ -545,6 +545,7 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
||||
if ( (!$oAttDef->IsLinkSet()) && (($iFlags & OPT_ATT_HIDDEN) == 0))
|
||||
{
|
||||
$sInputId = $this->m_iFormId.'_'.$sAttCode;
|
||||
if ($oAttDef->IsWritable())
|
||||
{
|
||||
if ($sStateAttCode == $sAttCode)
|
||||
@@ -555,7 +556,6 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
}
|
||||
else
|
||||
{
|
||||
$sInputId = $this->m_iFormId.'_'.$sAttCode;
|
||||
if ($iFlags & OPT_ATT_HIDDEN)
|
||||
{
|
||||
// Attribute is hidden, add a hidden input
|
||||
@@ -604,7 +604,8 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
||||
}
|
||||
else
|
||||
{
|
||||
$val = array('label' => '<span title="'.$oAttDef->GetDescription().'">'.$oAttDef->GetLabel().'</span>', 'value' => $this->GetAsHTML($sAttCode), 'comments' => $sComments, 'infos' => $sInfos);
|
||||
$val = array('label' => '<span title="'.$oAttDef->GetDescription().'">'.$oAttDef->GetLabel().'</span>', 'value' => "<span id=\"field_{$sInputId}\">".$this->GetAsHTML($sAttCode)."</span>", 'comments' => $sComments, 'infos' => $sInfos);
|
||||
$aFieldsMap[$sAttCode] = $sInputId;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -3251,6 +3251,12 @@ class AttributeExternalField extends AttributeDefinition
|
||||
throw new CoreException("Unexpected value for argument iType: '$iType'");
|
||||
}
|
||||
}
|
||||
|
||||
public function GetPrerequisiteAttributes()
|
||||
{
|
||||
return array($this->Get("extkey_attcode"));
|
||||
}
|
||||
|
||||
|
||||
public function GetExtAttDef()
|
||||
{
|
||||
|
||||
@@ -593,15 +593,10 @@ abstract class MetaModel
|
||||
$oAtt = self::GetAttributeDef($sClass, $sAttCode);
|
||||
// Temporary implementation: later, we might be able to compute
|
||||
// the dependencies, based on the attributes definition
|
||||
// (allowed values and default values)
|
||||
if ($oAtt->IsWritable())
|
||||
{
|
||||
return $oAtt->GetPrerequisiteAttributes();
|
||||
}
|
||||
else
|
||||
{
|
||||
return array();
|
||||
}
|
||||
// (allowed values and default values)
|
||||
|
||||
// Even non-writable attributes (like ExternalFields) can now have Prerequisites
|
||||
return $oAtt->GetPrerequisiteAttributes();
|
||||
}
|
||||
/**
|
||||
* Find all attributes that depend on the specified one (reverse of GetPrequisiteAttributes)
|
||||
|
||||
@@ -593,10 +593,18 @@ try
|
||||
$value = $oObj->Get($sAttCode);
|
||||
$displayValue = $oObj->GetEditValue($sAttCode);
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
||||
$iFlags = MetaModel::GetAttributeFlags($sClass, $oObj->GetState(), $sAttCode);
|
||||
$sHTMLValue = cmdbAbstractObject::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value, $displayValue, $sId, '', $iFlags, array('this' => $oObj, 'formPrefix' => $sFormPrefix));
|
||||
// Make sure that we immediately validate the field when we reload it
|
||||
$oPage->add_ready_script("$('#$sId').trigger('validate');");
|
||||
if (!$oAttDef->IsWritable())
|
||||
{
|
||||
// Even non-writable fields (like AttributeExternal) can be refreshed
|
||||
$sHTMLValue = $oObj->GetAsHTML($sAttCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
$iFlags = MetaModel::GetAttributeFlags($sClass, $oObj->GetState(), $sAttCode);
|
||||
$sHTMLValue = cmdbAbstractObject::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value, $displayValue, $sId, '', $iFlags, array('this' => $oObj, 'formPrefix' => $sFormPrefix));
|
||||
// Make sure that we immediately validate the field when we reload it
|
||||
$oPage->add_ready_script("$('#$sId').trigger('validate');");
|
||||
}
|
||||
$oWizardHelper->SetAllowedValuesHtml($sAttCode, $sHTMLValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user