N°659 use header message to display uniqueness errors on object creation / modification

This commit is contained in:
Pierre Goiffon
2018-10-19 15:08:33 +02:00
parent fc0cb44a84
commit 027b0fcff7
16 changed files with 59 additions and 6 deletions

View File

@@ -1581,6 +1581,47 @@ EOD
}
}
/**
* @param string $sTitle
* @param string[] $aIssues
*
* @see AddHeaderMessage
*/
public function AddHeaderMessageForErrors($sTitle, $aIssues)
{
$sContent = "<span><strong>$sTitle</strong></span>";
if (count($aIssues) == 1)
{
$sContent .= " <span>{$aIssues[0]}</span>";
}
else
{
$sContent .= '\n<ul>';
foreach ($aIssues as $sError)
{
$sContent .= "\n<li>$sError";
}
$sContent .= '</ul>';
}
$this->AddHeaderMessage($sContent, 'message_error');
}
/**
* Adds in the page a container with the header_message CSS class
*
* @param string $sContent
* @param string $sCssClasses CSS classes to add to the container
*/
public function AddHeaderMessage($sContent, $sCssClasses = 'message_info')
{
$this->add(<<<EOF
<div class="header_message $sCssClasses">$sContent</div>
EOF
);
}
/**
* Adds a script to be executed when the DOM is ready (typical JQuery use), right before add_ready_script
*

View File

@@ -393,6 +393,7 @@ Dict::Add('CS CZ', 'Czech', 'Čeština', array(
'UI:ClickToCreateNew' => 'Nový objekt (%1$s)',
'UI:SearchFor_Class' => 'Hledat objekty třídy %1$s',
'UI:NoObjectToDisplay' => 'Žádný objekt k zobrazení.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'Parametr object_id je povinný, pokud je uveden parametr link_attr. Zkontrolujte definici šablony zobrazení.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parametr target_attr je povinný, pokud je uveden parametr link_attr. Zkontrolujte definici šablony zobrazení.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'Parametr group_by je povinný. Zkontrolujte definici šablony zobrazení.',

View File

@@ -270,6 +270,7 @@ Dict::Add('DA DA', 'Danish', 'Dansk', array(
'UI:ClickToCreateNew' => 'Opret nyt objekt af typen %1$s ',
'UI:SearchFor_Class' => 'Søg efter objekter af typen %1$s ',
'UI:NoObjectToDisplay' => 'Ingen objekter at vise.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'Parameter objekt_id er obligatorisk når link_attr er specificeret. Tjek definitionen af display skabelonen.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parameter objekt_id er obligatorisk når link_attr er specificeret. Tjek definitionen af display skabelonen.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'Parameter group_by er obligatorisk. Tjek definitionen af display skabelonen.',

View File

@@ -276,6 +276,7 @@ Dict::Add('DE DE', 'German', 'Deutsch', array(
'UI:ClickToCreateNew' => 'Klicken Sie hier, um eine neues Objekt vom Typ %1$s zu erstellen',
'UI:SearchFor_Class' => 'Suche nach Objekten vom Typ "%1$s"',
'UI:NoObjectToDisplay' => 'Kein Objekt zur Anzeige vorhanden.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'Parameter object_id ist erforderlich, wenn link_attr verwendet wird. Überprüfen Sie die Defintion des Display-Templates.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parameter target_attr ist erforderlich, wenn link_attr verwendet wird. Überprüfen Sie die Defintion des Display-Templates.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'Parameter group_by ist erforderlich. Überprüfen Sie die Defintion des Display-Templates.',

View File

@@ -411,6 +411,7 @@ Dict::Add('EN US', 'English', 'English', array(
'UI:ClickToCreateNew' => 'Create a new %1$s',
'UI:SearchFor_Class' => 'Search for %1$s objects',
'UI:NoObjectToDisplay' => 'No object to display.',
'UI:Error:SaveFailed' => 'The object cannot be saved :',
'UI:Error:MandatoryTemplateParameter_object_id' => 'Parameter object_id is mandatory when link_attr is specified. Check the definition of the display template.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parameter target_attr is mandatory when link_attr is specified. Check the definition of the display template.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'Parameter group_by is mandatory. Check the definition of the display template.',

View File

@@ -408,6 +408,7 @@ Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array(
'UI:ClickToCreateNew' => 'Crear %1$s',
'UI:SearchFor_Class' => 'Buscar %1$s',
'UI:NoObjectToDisplay' => 'Ninguna Información por Visualizar.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'El parámetro object_id es obligatorio cuando link_attr es especificado. Verifique la definición de la plantilla de visualización.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'El parámetro target_attr es obligatorio cuando link_attr es especificado. Verifique la definición de la plantilla de visualización.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'El parámetro group_by es obligatorio. Verifique la definición de la plantilla de visualización.',

View File

@@ -279,6 +279,7 @@ Dict::Add('FR FR', 'French', 'Français', array(
'UI:ClickToCreateNew' => 'Créer un nouvel objet de type %1$s',
'UI:SearchFor_Class' => 'Rechercher des objets de type %1$s',
'UI:NoObjectToDisplay' => 'Aucun objet à afficher.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'Le paramètre object_id est obligatoire quand link_attr est spécifié. Vérifiez la définition du modèle.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'Le paramètre taarget_attr est obligatoire quand link_attr est spécifié. Vérifiez la définition du modèle.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'Le paramètre group_by est obligatoire. Vérifiez la définition du modèle.',

View File

@@ -254,6 +254,7 @@ Dict::Add('HU HU', 'Hungarian', 'Magyar', array(
'UI:ClickToCreateNew' => 'Új %1$s létrehozása',
'UI:SearchFor_Class' => '%1$s objektumok keresése',
'UI:NoObjectToDisplay' => 'Nincs megjeleníthető objektum',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'object_id pareméter kötelező a link_attr megadásánál. Ellenőrizze a sablon definíciót.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'target_attr pareméter kötelező a link_attr megadásánál. Ellenőrizze a sablon definíciót.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'group_by paraméter kötelező. Ellenőrizze a sablon definíciót.',

View File

@@ -383,6 +383,7 @@ Dict::Add('IT IT', 'Italian', 'Italiano', array(
'UI:ClickToCreateNew' => 'Crea un nuovo %1$s~~',
'UI:SearchFor_Class' => 'Cerca l\'oggetto %1$s',
'UI:NoObjectToDisplay' => 'Nessun oggetto da mostrare.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'Object_id parametro è obbligatorio quando link_attr è specificato. Verificare la definizione del modello di display.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'Target_attr parametro è obbligatorio quando link_attr è specificato. Verificare la definizione del modello di display.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'Il parametro è group_by obbligatoria. Verificare la definizione del modello di display.',

View File

@@ -270,6 +270,7 @@ Dict::Add('JA JP', 'Japanese', '日本語', array(
'UI:ClickToCreateNew' => '新規 %1$s を作成',
'UI:SearchFor_Class' => '%1$s オブジェクトを検索',
'UI:NoObjectToDisplay' => '表示するオブジェクトはありません。',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'link_attrが指定されている時は、object_idパラメータは必須です。表示テンプレートの定義を確認してください。',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'link_attrを指定する場合は、target_attrパラメータは必須です。表示テンプレートの定義を確認してください。',
'UI:Error:MandatoryTemplateParameter_group_by' => 'group_byパラメータは必須です。表示テンプレートの定義を確認してください。',

View File

@@ -392,6 +392,7 @@ Dict::Add('NL NL', 'Dutch', 'Nederlands', array(
'UI:ClickToCreateNew' => 'Maak een %1$s aan',
'UI:SearchFor_Class' => 'Zoek naar %1$s objecten',
'UI:NoObjectToDisplay' => 'Geen object om weer te geven.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'Parameter object_id is verplicht als link_attr is gespecificeerd. Controleer de definitie van het display template.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parameter target_attr is verplicht als link_attr is gespecificeerd. Controleer de definitie van het display template.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'Parameter group_by is verplicht. Controleer de definitie van het display template.',

View File

@@ -385,6 +385,7 @@ Dict::Add('PT BR', 'Brazilian', 'Brazilian', array(
'UI:ClickToCreateNew' => 'Criar um(a) novo(a) %1$s',
'UI:SearchFor_Class' => 'Pesquisar por objeto(s) %1$s',
'UI:NoObjectToDisplay' => 'Nenhum objeto encontrado.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'Parâmetro Object_id é obrigatório quando link_attr é especificado. Verifique a definição do modelo de exibição.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'Parâmetro Target_attr é obrigatório quando link_attr é especificado. Verifique a definição do modelo de exibição.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'Parâmetro Group_by é obrigatório. Verifique a definição do modelo de exibição.',

View File

@@ -368,6 +368,7 @@ Dict::Add('RU RU', 'Russian', 'Русский', array(
'UI:ClickToCreateNew' => 'Создать: %1$s',
'UI:SearchFor_Class' => 'Поиск: %1$s',
'UI:NoObjectToDisplay' => 'Нет объектов для отображения.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'Параметр object_id является обязательным если указан link_attr. Проверьте определение отображения шаблона.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'Параметр object_id является обязательным если указан link_attr. Проверьте определение отображения шаблона',
'UI:Error:MandatoryTemplateParameter_group_by' => 'Параметр group_by является обязательным. Проверьте определение отображения шаблона.',

View File

@@ -364,6 +364,7 @@ Dict::Add('TR TR', 'Turkish', 'Türkçe', array(
'UI:ClickToCreateNew' => 'Yeni %1$s yarat',
'UI:SearchFor_Class' => '%1$s Arama',
'UI:NoObjectToDisplay' => 'Görüntülenecek nesne bulunamadı.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => 'link_attr tanımlandığında object_id alanı zorunludur. Görüntülme (Display) şablonun tanımlamasını kontrol ediniz.',
'UI:Error:MandatoryTemplateParameter_target_attr' => 'link_attr tanımlandığında target_attr alanı zorunludur. Görüntülme (Display) şablonun tanımlamasını kontrol ediniz.',
'UI:Error:MandatoryTemplateParameter_group_by' => 'group_by alanı zorunludur. Görüntülme (Display) şablonun tanımlamasını kontrol ediniz.',

View File

@@ -363,6 +363,7 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', array(
'UI:ClickToCreateNew' => '创建一个新的 %1$s',
'UI:SearchFor_Class' => '搜索 %1$s 对象',
'UI:NoObjectToDisplay' => '没有对象可显示.',
'UI:Error:SaveFailed' => 'The object cannot be saved :~~',
'UI:Error:MandatoryTemplateParameter_object_id' => '当link_attr被指定时,参数 object_id 是必须的. 检查显示模板的定义.',
'UI:Error:MandatoryTemplateParameter_target_attr' => '当 link_attr被指定时, 参数 target_attr 是必须的. 检查显示模板的定义.',
'UI:Error:MandatoryTemplateParameter_group_by' => '参数 group_by 是必须的. 检查显示模板的定义.',

View File

@@ -920,7 +920,7 @@ EOF
}
else
{
list($bRes, $aIssues) = $oObj->CheckToWrite();
list($bRes, $aIssues) = $oObj->CheckToWrite(); // called also in DBUpdate()
if ($bRes)
{
try
@@ -951,9 +951,8 @@ EOF
$bDisplayDetails = false;
// Found issues, explain and give the user a second chance
//
$oP->AddHeaderMessageForErrors(Dict::S('UI:Error:SaveFailed'), $aIssues);
$oObj->DisplayModifyForm($oP, array('wizard_container' => true)); // wizard_container: display the wizard border and the title
$sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten', implode(', ', $aIssues));
$oP->add_ready_script("alert('".addslashes($sIssueDesc)."');");
}
}
}
@@ -1102,7 +1101,7 @@ EOF
$sClass = get_class($oObj);
$sClassLabel = MetaModel::GetName($sClass);
list($bRes, $aIssues) = $oObj->CheckToWrite();
list($bRes, $aIssues) = $oObj->CheckToWrite(); // called also in DBInsertNoReload()
if ($bRes)
{
$oObj->DBInsertNoReload(); // No need to reload
@@ -1133,10 +1132,9 @@ EOF
$oP->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel));
$oP->add("<h1>".MetaModel::GetClassIcon($sClass)."&nbsp;".Dict::Format('UI:CreationTitle_Class', $sClassLabel)."</h1>\n");
$oP->add("<div class=\"wizContainer\">\n");
$oP->AddHeaderMessageForErrors(Dict::S('UI:Error:SaveFailed'), $aIssues);
cmdbAbstractObject::DisplayCreationForm($oP, $sClass, $oObj);
$oP->add("</div>\n");
$sIssueDesc = Dict::Format('UI:ObjectCouldNotBeWritten', implode(', ', $aIssues));
$oP->add_ready_script("alert('".addslashes($sIssueDesc)."');");
}
}
break;