mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 01:58:47 +02:00
- Renamed the method 'UpdateObject' into 'UpdateObjectFromPostedForm' to avoid misunderstandings.
- Fixed (again !) Trac #427: unable to empty a linkset when editing an object. SVN:trunk[1370]
This commit is contained in:
@@ -2325,7 +2325,7 @@ EOF
|
||||
/**
|
||||
* Updates the object from the POSTed parameters (form)
|
||||
*/
|
||||
public function UpdateObject($sFormPrefix = '', $aAttList = null)
|
||||
public function UpdateObjectFromPostedForm($sFormPrefix = '', $aAttList = null)
|
||||
{
|
||||
$aErrors = array();
|
||||
$aValues = array();
|
||||
|
||||
@@ -610,7 +610,7 @@ EOF
|
||||
|
||||
$sClass = get_class($oObj);
|
||||
|
||||
$oObj->UpdateObject('' /* form prefix */, $aAttList);
|
||||
$oObj->UpdateObjectFromPostedForm('' /* form prefix */, $aAttList);
|
||||
|
||||
// Optional: apply a stimulus
|
||||
//
|
||||
|
||||
@@ -377,7 +377,7 @@ EOF
|
||||
public function DoCreateObject($oPage)
|
||||
{
|
||||
$oObj = MetaModel::NewObject($this->sTargetClass);
|
||||
$aErrors = $oObj->UpdateObject($this->iId);
|
||||
$aErrors = $oObj->UpdateObjectFromPostedForm($this->iId);
|
||||
if (count($aErrors) == 0)
|
||||
{
|
||||
$oMyChange = MetaModel::NewObject("CMDBChange");
|
||||
|
||||
@@ -182,17 +182,17 @@ class UILinksWidget
|
||||
|
||||
// Content
|
||||
$sHtml .= "</tbody>\n";
|
||||
if (count($aData) == 0)
|
||||
$sEmptyRowStyle = '';
|
||||
if (count($aData) != 0)
|
||||
{
|
||||
$sHtml .= "<tr id=\"{$this->m_sAttCode}{$this->m_sNameSuffix}_empty_row\"><td colspan=\"".count($aConfig)."\" style=\"text-align:center;\">".Dict::S('UI:Message:EmptyList:UseAdd')."<input type=\"hidden\" name=\"attr_{$this->m_sAttCode}{$this->m_sNameSuffix}\" value=\"\"></td></td>";
|
||||
$sEmptyRowStyle = 'style="display:none;"';
|
||||
}
|
||||
else
|
||||
|
||||
$sHtml .= "<tr $sEmptyRowStyle id=\"{$this->m_sAttCode}{$this->m_sNameSuffix}_empty_row\"><td colspan=\"".count($aConfig)."\" style=\"text-align:center;\">".Dict::S('UI:Message:EmptyList:UseAdd')."<input type=\"hidden\" name=\"attr_{$this->m_sAttCode}{$this->m_sNameSuffix}\" value=\"\"></td></td>";
|
||||
foreach($aData as $iRowId => $aRow)
|
||||
{
|
||||
foreach($aData as $iRowId => $aRow)
|
||||
{
|
||||
$sHtml .= $this->DisplayFormRow($oP, $aConfig, $aRow, $iRowId);
|
||||
}
|
||||
}
|
||||
$sHtml .= $this->DisplayFormRow($oP, $aConfig, $aRow, $iRowId);
|
||||
}
|
||||
$sHtml .= "</tbody>\n";
|
||||
|
||||
// Footer
|
||||
|
||||
@@ -40,6 +40,12 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates)
|
||||
// Re-run the zebra plugin to properly highlight the remaining lines & and take into account the removed ones
|
||||
$('#linkedset_'+this.id+' .listResults').trigger('update').trigger("applyWidgets");
|
||||
|
||||
if ($('$linkedset_'+this.id+' .selection').length == 0)
|
||||
{
|
||||
// All items were removed: add a dummy hidden input to make sure that the linkset will be updated (emptied) when posted
|
||||
$('#'+me.id+'_empty_row').show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.OnSelectChange = function()
|
||||
@@ -204,7 +210,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates)
|
||||
//console.log('Data: ' + data);
|
||||
if (data != '')
|
||||
{
|
||||
$('#'+me.id+'_empty_row').remove();
|
||||
$('#'+me.id+'_empty_row').hide();
|
||||
$('#linkedset_'+me.id+' .listResults tbody').append(data);
|
||||
$('#linkedset_'+me.id+' .listResults').trigger('update');
|
||||
$('#linkedset_'+me.id+' .listResults').tableHover();
|
||||
|
||||
@@ -971,7 +971,7 @@ EOF
|
||||
foreach($aSelectedObj as $iId)
|
||||
{
|
||||
$oObj = MetaModel::GetObject($sClass, $iId);
|
||||
$aErrors = $oObj->UpdateObject('');
|
||||
$aErrors = $oObj->UpdateObjectFromPostedForm('');
|
||||
$bResult = (count($aErrors) == 0);
|
||||
if ($bResult)
|
||||
{
|
||||
@@ -1187,7 +1187,7 @@ EOF
|
||||
}
|
||||
else
|
||||
{
|
||||
$oObj->UpdateObject();
|
||||
$oObj->UpdateObjectFromPostedForm();
|
||||
|
||||
if (!$oObj->IsModified())
|
||||
{
|
||||
@@ -1320,7 +1320,7 @@ EOF
|
||||
else
|
||||
{
|
||||
$oObj = MetaModel::NewObject($sClass);
|
||||
$oObj->UpdateObject();
|
||||
$oObj->UpdateObjectFromPostedForm();
|
||||
}
|
||||
if (isset($oObj) && is_object($oObj))
|
||||
{
|
||||
|
||||
@@ -456,7 +456,7 @@ EOF
|
||||
return parent::GetAttributeFlags($sAttCode, $aReasons);
|
||||
}
|
||||
|
||||
public function UpdateObject($sFormPrefix = '', $sAttList = null)
|
||||
public function UpdateObjectFromPostedForm($sFormPrefix = '', $sAttList = null)
|
||||
{
|
||||
parent::UpdateObject($sFormPrefix, $sAttList);
|
||||
// And now read the other post parameters...
|
||||
|
||||
Reference in New Issue
Block a user