mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
N°3198 n:n relations in edit mode : extkey to remote class is now editable
This commit is contained in:
@@ -39,6 +39,7 @@ class UILinksWidget
|
|||||||
protected $m_sLinkedClass;
|
protected $m_sLinkedClass;
|
||||||
protected $m_sRemoteClass;
|
protected $m_sRemoteClass;
|
||||||
protected $m_bDuplicatesAllowed;
|
protected $m_bDuplicatesAllowed;
|
||||||
|
/** @var string[] list of editables attcodes */
|
||||||
protected $m_aEditableFields;
|
protected $m_aEditableFields;
|
||||||
protected $m_aTableConfig;
|
protected $m_aTableConfig;
|
||||||
|
|
||||||
@@ -93,6 +94,7 @@ class UILinksWidget
|
|||||||
'label' => MetaModel::GetName($this->m_sRemoteClass),
|
'label' => MetaModel::GetName($this->m_sRemoteClass),
|
||||||
'description' => MetaModel::GetClassDescription($this->m_sRemoteClass),
|
'description' => MetaModel::GetClassDescription($this->m_sRemoteClass),
|
||||||
);
|
);
|
||||||
|
$this->m_aEditableFields[] = $this->m_sExtKeyToRemote;
|
||||||
|
|
||||||
$aRemoteAttDefsToDisplay = MetaModel::GetZListAttDefsFilteredForIndirectRemoteClass($this->m_sRemoteClass);
|
$aRemoteAttDefsToDisplay = MetaModel::GetZListAttDefsFilteredForIndirectRemoteClass($this->m_sRemoteClass);
|
||||||
foreach ($aRemoteAttDefsToDisplay as $oRemoteAttDef)
|
foreach ($aRemoteAttDefsToDisplay as $oRemoteAttDef)
|
||||||
@@ -110,7 +112,7 @@ class UILinksWidget
|
|||||||
*
|
*
|
||||||
* @param WebPage $oP Web page used for the ouput
|
* @param WebPage $oP Web page used for the ouput
|
||||||
* @param DBObject $oLinkedObj Remote object
|
* @param DBObject $oLinkedObj Remote object
|
||||||
* @param mixed $linkObjOrId Either the object linked or a unique number for new link records to add
|
* @param DBObject|int $linkObjOrId Either the lnk object or a unique number for new link records to add
|
||||||
* @param array $aArgs Extra context arguments
|
* @param array $aArgs Extra context arguments
|
||||||
* @param DBObject $oCurrentObj The object to which all the elements of the linked set refer to
|
* @param DBObject $oCurrentObj The object to which all the elements of the linked set refer to
|
||||||
* @param int $iUniqueId A unique identifier of new links
|
* @param int $iUniqueId A unique identifier of new links
|
||||||
@@ -152,13 +154,15 @@ class UILinksWidget
|
|||||||
$aRow['form::checkbox'] = "<input class=\"selection\" data-remote-id=\"$iRemoteObjKey\" data-link-id=\"$iKey\" data-unique-id=\"$iUniqueId\" type=\"checkbox\" onClick=\"oWidget".$this->m_iInputId.".OnSelectChange();\" value=\"$iKey\">";
|
$aRow['form::checkbox'] = "<input class=\"selection\" data-remote-id=\"$iRemoteObjKey\" data-link-id=\"$iKey\" data-unique-id=\"$iUniqueId\" type=\"checkbox\" onClick=\"oWidget".$this->m_iInputId.".OnSelectChange();\" value=\"$iKey\">";
|
||||||
foreach($this->m_aEditableFields as $sFieldCode)
|
foreach($this->m_aEditableFields as $sFieldCode)
|
||||||
{
|
{
|
||||||
|
$sRowFieldCode = ($sFieldCode === $this->m_sExtKeyToRemote) ? 'static::key' : $sFieldCode;
|
||||||
$sFieldId = $this->m_iInputId.'_'.$sFieldCode.'['.$linkObjOrId->GetKey().']';
|
$sFieldId = $this->m_iInputId.'_'.$sFieldCode.'['.$linkObjOrId->GetKey().']';
|
||||||
$sSafeId = utils::GetSafeId($sFieldId);
|
$sSafeId = utils::GetSafeId($sFieldId);
|
||||||
$sValue = $linkObjOrId->Get($sFieldCode);
|
$sValue = $linkObjOrId->Get($sFieldCode);
|
||||||
$sDisplayValue = $linkObjOrId->GetEditValue($sFieldCode);
|
$sDisplayValue = $linkObjOrId->GetEditValue($sFieldCode);
|
||||||
$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
|
$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
|
||||||
$aRow[$sFieldCode] = '<div class="field_container" style="border:none;"><div class="field_data"><div class="field_value">'.
|
$aRow[$sRowFieldCode] = '<div class="field_container" style="border:none;"><div class="field_data"><div class="field_value">'.
|
||||||
cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $sValue, $sDisplayValue, $sSafeId, $sNameSuffix, 0, $aArgs).
|
cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $sValue,
|
||||||
|
$sDisplayValue, $sSafeId, $sNameSuffix, 0, $aArgs).
|
||||||
'</div></div></div>';
|
'</div></div></div>';
|
||||||
$aFieldsMap[$sFieldCode] = $sSafeId;
|
$aFieldsMap[$sFieldCode] = $sSafeId;
|
||||||
}
|
}
|
||||||
@@ -216,13 +220,15 @@ EOF
|
|||||||
|
|
||||||
foreach($this->m_aEditableFields as $sFieldCode)
|
foreach($this->m_aEditableFields as $sFieldCode)
|
||||||
{
|
{
|
||||||
|
$sRowFieldCode = ($sFieldCode === $this->m_sExtKeyToRemote) ? 'static::key' : $sFieldCode;
|
||||||
$sFieldId = $this->m_iInputId.'_'.$sFieldCode.'['.-$iUniqueId.']';
|
$sFieldId = $this->m_iInputId.'_'.$sFieldCode.'['.-$iUniqueId.']';
|
||||||
$sSafeId = utils::GetSafeId($sFieldId);
|
$sSafeId = utils::GetSafeId($sFieldId);
|
||||||
$sValue = $oNewLinkObj->Get($sFieldCode);
|
$sValue = $oNewLinkObj->Get($sFieldCode);
|
||||||
$sDisplayValue = $oNewLinkObj->GetEditValue($sFieldCode);
|
$sDisplayValue = $oNewLinkObj->GetEditValue($sFieldCode);
|
||||||
$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
|
$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
|
||||||
$aRow[$sFieldCode] = '<div class="field_container" style="border:none;"><div class="field_data"><div class="field_value">'.
|
$aRow[$sRowFieldCode] = '<div class="field_container" style="border:none;"><div class="field_data"><div class="field_value">'.
|
||||||
cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $sValue, $sDisplayValue, $sSafeId /* id */, $sNameSuffix, 0, $aArgs).
|
cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $sValue, $sDisplayValue,
|
||||||
|
$sSafeId /* id */, $sNameSuffix, 0, $aArgs).
|
||||||
'</div></div></div>';
|
'</div></div></div>';
|
||||||
$aFieldsMap[$sFieldCode] = $sSafeId;
|
$aFieldsMap[$sFieldCode] = $sSafeId;
|
||||||
$oP->add_ready_script(<<<EOF
|
$oP->add_ready_script(<<<EOF
|
||||||
@@ -254,7 +260,6 @@ var {$aArgs['wizHelper']} = new WizardHelper('{$this->m_sLinkedClass}', '', '$sS
|
|||||||
{$aArgs['wizHelper']}.SetFieldsCount($iFieldsCount);
|
{$aArgs['wizHelper']}.SetFieldsCount($iFieldsCount);
|
||||||
EOF
|
EOF
|
||||||
);
|
);
|
||||||
$aRow['static::key'] = $oLinkedObj->GetHyperLink();
|
|
||||||
foreach(MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode)
|
foreach(MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode)
|
||||||
{
|
{
|
||||||
$aRow['static::'.$sFieldCode] = $oLinkedObj->GetAsHTML($sFieldCode);
|
$aRow['static::'.$sFieldCode] = $oLinkedObj->GetAsHTML($sFieldCode);
|
||||||
@@ -312,7 +317,7 @@ EOF
|
|||||||
$sEmptyRowStyle = 'style="display:none;"';
|
$sEmptyRowStyle = 'style="display:none;"';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($aData as $iRowId => $aRow)
|
foreach ($aData as $iRowId => $aRow)
|
||||||
{
|
{
|
||||||
$sHtml .= $this->DisplayFormRow($oP, $aConfig, $aRow, $iRowId);
|
$sHtml .= $this->DisplayFormRow($oP, $aConfig, $aRow, $iRowId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user