diff --git a/css/light-grey.css b/css/light-grey.css index 8975ea937..77ea1a54d 100644 --- a/css/light-grey.css +++ b/css/light-grey.css @@ -699,4 +699,7 @@ td.dashboard { -moz-border-radius: 10px; padding: 10px; width: 50%; +} +.white { + background-color: #fff; } \ No newline at end of file diff --git a/dictionaries/dictionary.itop.ui.php b/dictionaries/dictionary.itop.ui.php index 30f30b20b..7a1c33411 100644 --- a/dictionaries/dictionary.itop.ui.php +++ b/dictionaries/dictionary.itop.ui.php @@ -436,7 +436,7 @@ Dict::Add('EN US', 'English', 'English', array( 'UI:Button:Login' => 'Enter iTop', 'UI:Login:Error:AccessRestricted' => 'iTop access is restricted. Please, contact an iTop administrator.', 'UI:CSVImport:MappingSelectOne' => '-- select one --', - 'UI:CSVImport:MappingNotApplicable' => '------ n/a ------', + 'UI:CSVImport:MappingNotApplicable' => '-- ignore this field --', 'UI:CSVImport:NoData' => 'Empty data set..., please provide some data!', 'UI:Title:DataPreview' => 'Data Preview', 'UI:CSVImport:ErrorOnlyOneColumn' => 'Error: The data contains only one column. Did you select the appropriate separator character?', diff --git a/dictionaries/fr.dictionary.itop.ui.php b/dictionaries/fr.dictionary.itop.ui.php index cdf04452a..41b52e165 100644 --- a/dictionaries/fr.dictionary.itop.ui.php +++ b/dictionaries/fr.dictionary.itop.ui.php @@ -431,7 +431,7 @@ Dict::Add('FR FR', 'French', 'Français', array( 'UI:Button:Login' => 'Entrer dans iTop', 'UI:Login:Error:AccessRestricted' => 'L\'accès à iTop est soumis à autorisation. Merci de contacter votre administrateur iTop.', 'UI:CSVImport:MappingSelectOne' => '-- choisir une valeur --', - 'UI:CSVImport:MappingNotApplicable' => '------ n/a ------', + 'UI:CSVImport:MappingNotApplicable' => '-- ignorer ce champ --', 'UI:CSVImport:NoData' => 'Aucune donnée... merci de fournir des données !', 'UI:Title:DataPreview' => 'Aperçu des données', 'UI:CSVImport:ErrorOnlyOneColumn' => 'Erreur: Les données semblent ne contenir qu\'une seule colonne. Avez-vous choisi le bon séparateur ?', diff --git a/pages/ajax.csvimport.php b/pages/ajax.csvimport.php index 491e3f8df..f519ab3f9 100644 --- a/pages/ajax.csvimport.php +++ b/pages/ajax.csvimport.php @@ -30,13 +30,53 @@ require_once('../application/wizardhelper.class.inc.php'); require_once('../application/ui.linkswidget.class.inc.php'); require_once('../application/csvpage.class.inc.php'); +/** + * Determines if the name of the field to be mapped correspond + * to the name of an external key or an Id of the given class + * @param string $sClassName The name of the class + * @param string $sFieldCode The attribute code of the field , or empty if no match + * @return bool true if the field corresponds to an id/External key, false otherwise + */ +function IsIdField($sClassName, $sFieldCode) +{ + $bResult = false; + if (!empty($sFieldCode)) + { + if ($sFieldCode == 'id') + { + $bResult = true; + } + else if (strpos($sFieldCode, '->') === false) + { + $oAttDef = MetaModel::GetAttributeDef($sClassName, $sFieldCode); + $bResult = $oAttDef->IsExternalKey(); + } + } + return $bResult; +} + /** * Helper function to build the mapping drop-down list for a field + * Spec: Possible choices are "writable" fields in this class plus external fields that are listed as reconciliation keys + * for any class pointed to by an external key in the current class. + * If not in advanced mode, all "id" fields (id and external keys) must be mapped to ":none:" (i.e -- ignore this field --) + * External fields that do not correspond to a reconciliation key must be mapped to ":none:" + * Otherwise, if a field equals either the 'code' or the 'label' (translated) of a field, then it's mapped automatically + * @param string $sClassName Name of the class used for the mapping + * @param string $sFieldName Name of the field, as it comes from the data file (header line) + * @param integer $iFieldIndex Number of the field in the sequence + * @param bool $bAdvancedMode Whether or not advanced mode was chosen + * @return string The HTML code corresponding to the drop-down list for this field */ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMode = false) { $aChoices = array('' => Dict::S('UI:CSVImport:MappingSelectOne')); $aChoices[':none:'] = Dict::S('UI:CSVImport:MappingNotApplicable'); + $sFieldCode = ''; // Code of the attribute, if there is a match + if ($sFieldName == 'id') + { + $sFieldCode = 'id'; + } if ($bAdvancedMode) { $aChoices['id'] = Dict::S('UI:CSVImport:idField'); @@ -45,7 +85,14 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo { if ($oAttDef->IsExternalKey()) { - $aChoices[$sAttCode] = $oAttDef->GetLabel(); + if ( ($sFieldName == $oAttDef->GetLabel()) || ($sFieldName == $sAttCode)) + { + $sFieldCode = $sAttCode; + } + if ($bAdvancedMode) + { + $aChoices[$sAttCode] = $oAttDef->GetLabel(); + } // Get fields of the external class that are considered as reconciliation keys $sTargetClass = $oAttDef->GetTargetClass(); foreach(MetaModel::ListAttributeDefs($sTargetClass) as $sTargetAttCode => $oTargetAttDef) @@ -53,28 +100,48 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo if (MetaModel::IsReconcKey($sTargetClass, $sTargetAttCode)) { $aChoices[$sAttCode.'->'.$sTargetAttCode] = $oAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel(); + if (($sFieldName == $aChoices[$sAttCode.'->'.$sTargetAttCode]) || ($sFieldName == ($sAttCode.'->'.$sTargetAttCode)) ) + { + $sFieldCode = $sAttCode.'->'.$sTargetAttCode; + } } } } else if ($oAttDef->IsWritable()) { $aChoices[$sAttCode] = $oAttDef->GetLabel(); - } + if ( ($sFieldName == $oAttDef->GetLabel()) || ($sFieldName == $sAttCode)) + { + $sFieldCode = $sAttCode; + } + } } asort($aChoices); $sHtml = "\n"; @@ -123,7 +190,7 @@ switch($sOperation) $sMaxLen = (strlen(''.$iTarget) < 3) ? 3 : strlen(''.$iTarget); // Pad line numbers to the appropriate number of chars, but at least 3 $sFormat = '%0'.$sMaxLen.'d'; $oPage->p("
| '.Dict::S('UI:CSVImport:AdvancedMode').' |
'.Dict::S('UI:CSVImport:SelectAClassFirst').'
'.Dict::S('UI:CSVImport:SelectAClassFirst').'