N°5305 - CSV import ergonomy for SaaS

- Change checkbox error ugly font
- Improve errors messages (ambiguous, mismatch)
This commit is contained in:
Benjamin Dalsass
2023-06-20 17:21:39 +02:00
parent 9b9ba3c440
commit 85a879b587
4 changed files with 52 additions and 20 deletions

View File

@@ -136,6 +136,12 @@ class CellStatus_SearchIssue extends CellStatus_Issue
/** @var string|null $m_sTargetClass */ /** @var string|null $m_sTargetClass */
private $m_sTargetClass; private $m_sTargetClass;
/**
* @since 3.1.0 N°5305
* @var string $sAllowedValuesSearch
*/
private $sAllowedValuesSearch;
/** /**
* CellStatus_SearchIssue constructor. * CellStatus_SearchIssue constructor.
* @since 3.1.0 N°5305 * @since 3.1.0 N°5305
@@ -144,13 +150,15 @@ class CellStatus_SearchIssue extends CellStatus_Issue
* @param string $sReason : main message * @param string $sReason : main message
* @param null $sClass : used for additional message that provides allowed values for current class $sClass * @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 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); parent::__construct(null, null, $sReason);
$this->sSerializedSearch = $sSerializedSearch; $this->sSerializedSearch = $sSerializedSearch;
$this->m_sAllowedValues = $sAllowedValues; $this->m_sAllowedValues = $sAllowedValues;
$this->m_sTargetClass = $sClass; $this->m_sTargetClass = $sClass;
$this->sAllowedValuesSearch = $sAllowedValuesSearch;
} }
public function GetDisplayableValue() public function GetDisplayableValue()
@@ -182,6 +190,17 @@ class CellStatus_SearchIssue extends CellStatus_Issue
rawurlencode($this->sSerializedSearch) 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 class CellStatus_NullIssue extends CellStatus_Issue
@@ -745,6 +764,7 @@ class BulkChange
$oDbSearchWithoutAnyCondition->AllowAllData(false); $oDbSearchWithoutAnyCondition->AllowAllData(false);
$oExtObjectSetWithCurrentUserPermissions = new CMDBObjectSet($oDbSearchWithoutAnyCondition); $oExtObjectSetWithCurrentUserPermissions = new CMDBObjectSet($oDbSearchWithoutAnyCondition);
$iCurrentUserRightsObjectCount = $oExtObjectSetWithCurrentUserPermissions->Count(); $iCurrentUserRightsObjectCount = $oExtObjectSetWithCurrentUserPermissions->Count();
$sAllowedValuesOql = $oDbSearchWithoutAnyCondition->serialize();
if ($iCurrentUserRightsObjectCount === 0){ if ($iCurrentUserRightsObjectCount === 0){
// No objects visible by current user // No objects visible by current user
@@ -785,7 +805,7 @@ class BulkChange
if ($iAllowAllDataObjectCount != $iCurrentUserRightsObjectCount) { if ($iAllowAllDataObjectCount != $iCurrentUserRightsObjectCount) {
// No match and some objects NOT visible by current user. including current search maybe... // No match and some objects NOT visible by current user. including current search maybe...
$sReason = Dict::Format('UI:CSVReport-Value-NoMatch-SomeObjectNotVisibleForCurrentUser', $oDbSearchWithConditions->GetClass()); $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 // No match. This is not linked to any right issue
@@ -796,7 +816,7 @@ class BulkChange
} }
$value =implode(" ", $aCurrentValueFields); $value =implode(" ", $aCurrentValueFields);
$sReason = Dict::Format('UI:CSVReport-Value-NoMatch', $value); $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) protected function PrepareMissingObject(&$oTargetObj, &$aErrors)

View File

@@ -722,6 +722,8 @@ We hope youll 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:AlertMultipleMapping' => 'Please make sure that a target field is mapped only once.',
'UI:CSVImport:AlertNoSearchCriteria' => 'Please select at least one search criteria', 'UI:CSVImport:AlertNoSearchCriteria' => 'Please select at least one search criteria',
'UI:CSVImport:Encoding' => 'Character encoding', '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:UniversalSearchTitle' => ITOP_APPLICATION_SHORT.' - Universal Search',
'UI:UniversalSearch:Error' => 'Error: %1$s', 'UI:UniversalSearch:Error' => 'Error: %1$s',
'UI:UniversalSearch:LabelSelectTheClass' => 'Select the class to search: ', 'UI:UniversalSearch:LabelSelectTheClass' => 'Select the class to search: ',

View File

@@ -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: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:AlertNoSearchCriteria' => 'Veuillez choisir au moins une clef de recherche.',
'UI:CSVImport:Encoding' => 'Encodage des caractères', '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:UniversalSearchTitle' => ITOP_APPLICATION_SHORT.' - Recherche universelle',
'UI:UniversalSearch:Error' => 'Erreur : %1$s', 'UI:UniversalSearch:Error' => 'Erreur : %1$s',
'UI:UniversalSearch:LabelSelectTheClass' => 'Sélectionnez le type d\'objets à rechercher : ', 'UI:UniversalSearch:LabelSelectTheClass' => 'Sélectionnez le type d\'objets à rechercher : ',

View File

@@ -485,25 +485,33 @@ try {
break; break;
case 'CellStatus_SearchIssue': case 'CellStatus_SearchIssue':
$aTableRow[$sClassName.'/'.$sAttCode] = sprintf("%s%s%s%s%s%s", $sMessage = Dict::Format('UI:CSVReport-Object-Error', $sHtmlValue);
'<a href="', $sDivAlert = GetDivAlert($oCellStatus->GetDescription());
$oCellStatus->GetSearchLinkUrl(), $sAllowedValuesLinkUrl = $oCellStatus->GetAllowedValuesLinkUrl();
'"><div class="ibo-csv-import--cell-error">', $sAllowedValuesLinkLabel = Dict::S('UI:CSVImport:ViewAllPossibleValues');
Dict::Format('UI:CSVReport-Object-Error', $sHtmlValue), $aTableRow[$sClassName.'/'.$sAttCode] =
GetDivAlert($oCellStatus->GetDescription()), <<<HTML
'<i class="fas fa-search"></i></div><a/>' <div class="ibo-csv-import--cell-error">
); $sMessage
$sDivAlert
<a class="ibo-button ibo-is-regular ibo-is-neutral" target="_blank" href="$sAllowedValuesLinkUrl"><i class="fas fa-search"></i>&nbsp;$sAllowedValuesLinkLabel</a>
</div>
HTML;
break; break;
case 'CellStatus_Ambiguous': case 'CellStatus_Ambiguous':
$aTableRow[$sClassName.'/'.$sAttCode] = sprintf("%s%s%s%s%s%s", $sMessage = Dict::Format('UI:CSVReport-Object-Ambiguous', $sHtmlValue);
'<a href="', $sDivAlert = GetDivAlert($oCellStatus->GetDescription());
$oCellStatus->GetSearchLinkUrl(), $sSearchLinkUrl = $oCellStatus->GetSearchLinkUrl();
'"><i class="fas fa-search"/><div class="ibo-csv-import--cell-error">', $sSearchLinkLabel = Dict::S('UI:CSVImport:ViewAllAmbiguousValues');
Dict::Format('UI:CSVReport-Object-Ambiguous', $sHtmlValue), $aTableRow[$sClassName.'/'.$sAttCode] =
GetDivAlert($oCellStatus->GetDescription()), <<<HTML
'<i class="fas fa-search"></i></div><a/>' <div class="ibo-csv-import--cell-error">
); $sMessage
$sDivAlert
<a class="ibo-button ibo-is-regular ibo-is-neutral" target="_blank" href="$sSearchLinkUrl"><i class="fas fa-search"></i>&nbsp;$sSearchLinkLabel</a>
</div>
HTML;
break; break;
case 'CellStatus_Modify': case 'CellStatus_Modify':
@@ -592,7 +600,7 @@ try {
$oMulticolumn->AddColumn(ColumnUIBlockFactory::MakeForBlock($oCheckBoxUnchanged)); $oMulticolumn->AddColumn(ColumnUIBlockFactory::MakeForBlock($oCheckBoxUnchanged));
$oPage->add_ready_script("$('#show_created').on('click', function(){ToggleRows('ibo-csv-import--row-added')})"); $oPage->add_ready_script("$('#show_created').on('click', function(){ToggleRows('ibo-csv-import--row-added')})");
$oCheckBoxUnchanged = InputUIBlockFactory::MakeForInputWithLabel('<i class="fas fa-exclamation-triangle" style="color:#A33; background-color: #FFF0F0;">&nbsp;'.sprintf($aDisplayFilters['errors'], $iErrors).'</i></i>', '', "1", "show_errors", "checkbox"); $oCheckBoxUnchanged = InputUIBlockFactory::MakeForInputWithLabel('<span style="color:#A33; background-color: #FFF0F0;"><i class="fas fa-exclamation-triangle"></i>&nbsp;'.sprintf($aDisplayFilters['errors'], $iErrors) . '</span>', '', "1", "show_errors", "checkbox");
$oCheckBoxUnchanged->GetInput()->SetIsChecked(true); $oCheckBoxUnchanged->GetInput()->SetIsChecked(true);
$oCheckBoxUnchanged->SetBeforeInput(false); $oCheckBoxUnchanged->SetBeforeInput(false);
$oCheckBoxUnchanged->GetInput()->AddCSSClass('ibo-input-checkbox'); $oCheckBoxUnchanged->GetInput()->AddCSSClass('ibo-input-checkbox');