mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°583 CSV Import now supports friendlynames as reconciliation keys. More over, read-only attributes (friendlyname, obsolescence flag, ...) are forced to reconciliation scheme.
SVN:trunk[4861]
This commit is contained in:
@@ -470,6 +470,8 @@ class BulkChange
|
||||
{
|
||||
// skip the private key, if any
|
||||
if ($sAttCode == 'id') continue;
|
||||
// skip reconciliation keys
|
||||
if (in_array($sAttCode, $this->m_aReconcilKeys)) continue;
|
||||
|
||||
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
|
||||
$aReasons = array();
|
||||
|
||||
@@ -149,7 +149,8 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo
|
||||
$sTargetClass = $oAttDef->GetTargetClass();
|
||||
foreach(MetaModel::ListAttributeDefs($sTargetClass) as $sTargetAttCode => $oTargetAttDef)
|
||||
{
|
||||
if (MetaModel::IsReconcKey($sTargetClass, $sTargetAttCode))
|
||||
// Note: Could not use "MetaModel::GetFriendlyNameAttributeCode($sTargetClass) === $sTargetAttCode" as it would return empty because the friendlyname is composite.
|
||||
if (MetaModel::IsReconcKey($sTargetClass, $sTargetAttCode) || ($oTargetAttDef instanceof AttributeFriendlyName))
|
||||
{
|
||||
$bExtKey = $oTargetAttDef->IsExternalKey();
|
||||
$aSignatures = array();
|
||||
@@ -176,14 +177,17 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($oAttDef->IsWritable() && (!$oAttDef->IsLinkset() || ($bAdvancedMode && $oAttDef->IsIndirect())))
|
||||
else if (
|
||||
($oAttDef->IsWritable() && (!$oAttDef->IsLinkset() || ($bAdvancedMode && $oAttDef->IsIndirect())))
|
||||
|| ($oAttDef instanceof AttributeFriendlyName)
|
||||
)
|
||||
{
|
||||
$aChoices[$sAttCode] = MetaModel::GetLabel($sClassName, $sAttCode, true);
|
||||
if ( ($sFieldName == $oAttDef->GetLabel()) || ($sFieldName == $sAttCode))
|
||||
{
|
||||
$sFieldCode = $sAttCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
asort($aChoices);
|
||||
|
||||
@@ -412,10 +416,23 @@ try
|
||||
}
|
||||
$sDefaultKeys = '"'.implode('", "', $aDefaultKeys).'"';
|
||||
}
|
||||
|
||||
// Read only attributes (will be forced to "search")
|
||||
$aReadOnlyKeys = array();
|
||||
foreach(MetaModel::ListAttributeDefs($sClassName) as $sAttCode => $oAttDef)
|
||||
{
|
||||
if(!$oAttDef->IsWritable())
|
||||
{
|
||||
$aReadOnlyKeys[] = $sAttCode;
|
||||
}
|
||||
}
|
||||
$sReadOnlyKeys = '"'.implode('", "', $aReadOnlyKeys).'"';
|
||||
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
$('select[name^=field]').change( DoCheckMapping );
|
||||
aDefaultKeys = new Array($sDefaultKeys);
|
||||
aReadOnlyKeys = new Array($sReadOnlyKeys);
|
||||
DoCheckMapping();
|
||||
EOF
|
||||
);
|
||||
|
||||
@@ -835,6 +835,7 @@ EOF
|
||||
$oPage->add_script(
|
||||
<<<EOF
|
||||
var aDefaultKeys = new Array();
|
||||
var aReadOnlyKeys = new Array();
|
||||
|
||||
function CSVGoBack()
|
||||
{
|
||||
@@ -1005,6 +1006,12 @@ EOF
|
||||
$('#search_'+index).attr('checked', false);
|
||||
$('#search_'+index).attr('disabled', true);
|
||||
}
|
||||
else if (aReadOnlyKeys.indexOf(sMappingValue) >= 0)
|
||||
{
|
||||
// Read-only attribute forced to reconciliation key
|
||||
$('#search_'+index).attr('checked', true);
|
||||
$('#search_'+index).attr('disabled', true);
|
||||
}
|
||||
else if (index == idSelected)
|
||||
{
|
||||
// The 'id' field was mapped, it's the only possible reconciliation key
|
||||
|
||||
Reference in New Issue
Block a user