From 85a879b58706c1e778d9bf8e28b7137ebac7c1c5 Mon Sep 17 00:00:00 2001 From: Benjamin Dalsass Date: Tue, 20 Jun 2023 17:21:39 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B05305=20-=20CSV=20import=20ergonomy=20for?= =?UTF-8?q?=20SaaS=20-=20Change=20checkbox=20error=20ugly=20font=20-=20Imp?= =?UTF-8?q?rove=20errors=20messages=20(ambiguous,=20mismatch)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bulkchange.class.inc.php | 26 ++++++++++++++-- dictionaries/en.dictionary.itop.ui.php | 2 ++ dictionaries/fr.dictionary.itop.ui.php | 2 ++ pages/csvimport.php | 42 +++++++++++++++----------- 4 files changed, 52 insertions(+), 20 deletions(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index cdc14a052..232a4c0a1 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -136,6 +136,12 @@ class CellStatus_SearchIssue extends CellStatus_Issue /** @var string|null $m_sTargetClass */ private $m_sTargetClass; + /** + * @since 3.1.0 N°5305 + * @var string $sAllowedValuesSearch + */ + private $sAllowedValuesSearch; + /** * CellStatus_SearchIssue constructor. * @since 3.1.0 N°5305 @@ -144,13 +150,15 @@ class CellStatus_SearchIssue extends CellStatus_Issue * @param string $sReason : main message * @param null $sClass : used for additional message that provides allowed values for current class $sClass * @param null $sAllowedValues : used for additional message that provides allowed values $sAllowedValues for current class + * @param string|null $sAllowedValuesSearch : used to search all allowed values */ - public function __construct($sSerializedSearch, $sReason, $sClass=null, $sAllowedValues=null) + public function __construct($sSerializedSearch, $sReason, $sClass=null, $sAllowedValues=null, string $sAllowedValuesSearch=null) { parent::__construct(null, null, $sReason); $this->sSerializedSearch = $sSerializedSearch; $this->m_sAllowedValues = $sAllowedValues; $this->m_sTargetClass = $sClass; + $this->sAllowedValuesSearch = $sAllowedValuesSearch; } public function GetDisplayableValue() @@ -182,6 +190,17 @@ class CellStatus_SearchIssue extends CellStatus_Issue rawurlencode($this->sSerializedSearch) ); } + + /** + * @since 3.1.0 N°5305 + * @return null|string + */ + public function GetAllowedValuesLinkUrl(): ?string + { + return sprintf("UI.php?operation=search&filter=%s", + rawurlencode($this->sAllowedValuesSearch) + ); + } } class CellStatus_NullIssue extends CellStatus_Issue @@ -745,6 +764,7 @@ class BulkChange $oDbSearchWithoutAnyCondition->AllowAllData(false); $oExtObjectSetWithCurrentUserPermissions = new CMDBObjectSet($oDbSearchWithoutAnyCondition); $iCurrentUserRightsObjectCount = $oExtObjectSetWithCurrentUserPermissions->Count(); + $sAllowedValuesOql = $oDbSearchWithoutAnyCondition->serialize(); if ($iCurrentUserRightsObjectCount === 0){ // No objects visible by current user @@ -785,7 +805,7 @@ class BulkChange if ($iAllowAllDataObjectCount != $iCurrentUserRightsObjectCount) { // No match and some objects NOT visible by current user. including current search maybe... $sReason = Dict::Format('UI:CSVReport-Value-NoMatch-SomeObjectNotVisibleForCurrentUser', $oDbSearchWithConditions->GetClass()); - return new CellStatus_SearchIssue($sSerializedSearch, $sReason, $oDbSearchWithConditions->GetClass(), $allowedValues); + return new CellStatus_SearchIssue($sSerializedSearch, $sReason, $oDbSearchWithConditions->GetClass(), $allowedValues, $sAllowedValuesOql); } // No match. This is not linked to any right issue @@ -796,7 +816,7 @@ class BulkChange } $value =implode(" ", $aCurrentValueFields); $sReason = Dict::Format('UI:CSVReport-Value-NoMatch', $value); - return new CellStatus_SearchIssue($sSerializedSearch, $sReason, $oDbSearchWithConditions->GetClass(), $allowedValues); + return new CellStatus_SearchIssue($sSerializedSearch, $sReason, $oDbSearchWithConditions->GetClass(), $allowedValues, $sAllowedValuesOql); } protected function PrepareMissingObject(&$oTargetObj, &$aErrors) diff --git a/dictionaries/en.dictionary.itop.ui.php b/dictionaries/en.dictionary.itop.ui.php index 204fecaa1..8e05bd527 100644 --- a/dictionaries/en.dictionary.itop.ui.php +++ b/dictionaries/en.dictionary.itop.ui.php @@ -722,6 +722,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:CSVImport:AlertMultipleMapping' => 'Please make sure that a target field is mapped only once.', 'UI:CSVImport:AlertNoSearchCriteria' => 'Please select at least one search criteria', 'UI:CSVImport:Encoding' => 'Character encoding', + 'UI:CSVImport:ViewAllPossibleValues' => 'View all possible values', + 'UI:CSVImport:ViewAllAmbiguousValues' => 'View all ambiguous values', 'UI:UniversalSearchTitle' => ITOP_APPLICATION_SHORT.' - Universal Search', 'UI:UniversalSearch:Error' => 'Error: %1$s', 'UI:UniversalSearch:LabelSelectTheClass' => 'Select the class to search: ', diff --git a/dictionaries/fr.dictionary.itop.ui.php b/dictionaries/fr.dictionary.itop.ui.php index dfb55f530..664deeb07 100644 --- a/dictionaries/fr.dictionary.itop.ui.php +++ b/dictionaries/fr.dictionary.itop.ui.php @@ -695,6 +695,8 @@ Nous espérons que vous aimerez cette version autant que nous avons eu du plaisi 'UI:CSVImport:AlertMultipleMapping' => 'Veuillez vous assurer que chaque champ cible est sélectionné une seule fois.', 'UI:CSVImport:AlertNoSearchCriteria' => 'Veuillez choisir au moins une clef de recherche.', 'UI:CSVImport:Encoding' => 'Encodage des caractères', + 'UI:CSVImport:ViewAllPossibleValues' => 'Voir toutes les valeurs possibles', + 'UI:CSVImport:ViewAllAmbiguousValues' => 'Voir toutes les valeurs ambigues', 'UI:UniversalSearchTitle' => ITOP_APPLICATION_SHORT.' - Recherche universelle', 'UI:UniversalSearch:Error' => 'Erreur : %1$s', 'UI:UniversalSearch:LabelSelectTheClass' => 'Sélectionnez le type d\'objets à rechercher : ', diff --git a/pages/csvimport.php b/pages/csvimport.php index f778ac318..ddc2b86ce 100644 --- a/pages/csvimport.php +++ b/pages/csvimport.php @@ -485,25 +485,33 @@ try { break; case 'CellStatus_SearchIssue': - $aTableRow[$sClassName.'/'.$sAttCode] = sprintf("%s%s%s%s%s%s", - '
', - Dict::Format('UI:CSVReport-Object-Error', $sHtmlValue), - GetDivAlert($oCellStatus->GetDescription()), - '
' - ); + $sMessage = Dict::Format('UI:CSVReport-Object-Error', $sHtmlValue); + $sDivAlert = GetDivAlert($oCellStatus->GetDescription()); + $sAllowedValuesLinkUrl = $oCellStatus->GetAllowedValuesLinkUrl(); + $sAllowedValuesLinkLabel = Dict::S('UI:CSVImport:ViewAllPossibleValues'); + $aTableRow[$sClassName.'/'.$sAttCode] = + << + $sMessage + $sDivAlert +  $sAllowedValuesLinkLabel + +HTML; break; case 'CellStatus_Ambiguous': - $aTableRow[$sClassName.'/'.$sAttCode] = sprintf("%s%s%s%s%s%s", - '
', - Dict::Format('UI:CSVReport-Object-Ambiguous', $sHtmlValue), - GetDivAlert($oCellStatus->GetDescription()), - '
' - ); + $sMessage = Dict::Format('UI:CSVReport-Object-Ambiguous', $sHtmlValue); + $sDivAlert = GetDivAlert($oCellStatus->GetDescription()); + $sSearchLinkUrl = $oCellStatus->GetSearchLinkUrl(); + $sSearchLinkLabel = Dict::S('UI:CSVImport:ViewAllAmbiguousValues'); + $aTableRow[$sClassName.'/'.$sAttCode] = + << + $sMessage + $sDivAlert +  $sSearchLinkLabel + +HTML; break; case 'CellStatus_Modify': @@ -592,7 +600,7 @@ try { $oMulticolumn->AddColumn(ColumnUIBlockFactory::MakeForBlock($oCheckBoxUnchanged)); $oPage->add_ready_script("$('#show_created').on('click', function(){ToggleRows('ibo-csv-import--row-added')})"); - $oCheckBoxUnchanged = InputUIBlockFactory::MakeForInputWithLabel(' '.sprintf($aDisplayFilters['errors'], $iErrors).'', '', "1", "show_errors", "checkbox"); + $oCheckBoxUnchanged = InputUIBlockFactory::MakeForInputWithLabel(' '.sprintf($aDisplayFilters['errors'], $iErrors) . '', '', "1", "show_errors", "checkbox"); $oCheckBoxUnchanged->GetInput()->SetIsChecked(true); $oCheckBoxUnchanged->SetBeforeInput(false); $oCheckBoxUnchanged->GetInput()->AddCSSClass('ibo-input-checkbox');