diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 95cdf7bb8..3d6bbbb78 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -4231,13 +4231,20 @@ HTML; if (!is_null($oImage->GetData())) { $aSize = utils::GetImageSize($oImage->GetData()); - $oImage = utils::ResizeImageToFit( - $oImage, - $aSize[0], - $aSize[1], - $oAttDef->Get('storage_max_width'), - $oAttDef->Get('storage_max_height') - ); + if (is_array($aSize) && $aSize[0] > 0 && $aSize[1] > 0) + { + $oImage = utils::ResizeImageToFit( + $oImage, + $aSize[0], + $aSize[1], + $oAttDef->Get('storage_max_width'), + $oAttDef->Get('storage_max_height') + ); + } + else + { + IssueLog::Warning($sClass . ':' . $this->GetKey() . '/' . $sAttCode . ': Image could not be resized. Mimetype: ' . $oImage->GetMimeType() . ', filename: ' . $oImage->GetFileName()); + } } $aOtherData = utils::ReadPostedParam("attr_{$sFormPrefix}{$sAttCode}", null, 'raw_data'); if (is_array($aOtherData)) diff --git a/core/csvbulkexport.class.inc.php b/core/csvbulkexport.class.inc.php index 36eb3cf71..50a92f8f0 100644 --- a/core/csvbulkexport.class.inc.php +++ b/core/csvbulkexport.class.inc.php @@ -220,16 +220,15 @@ class CSVBulkExport extends TabularBulkExport $sFormatInput = ''; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "csv_date_format_radio", "custom", "csv_date_time_format_custom", "radio"); + $oRadioCustom->SetDescription(Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip')); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); $oRadioCustom->SetBeforeInput(false); $oRadioCustom->GetInput()->AddCSSClass('ibo-input-checkbox'); $oFieldSetDate->AddSubBlock($oRadioCustom); - $sJSTooltip = json_encode('
'.Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip').'
'); $oP->add_ready_script( <<'; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "excel_date_format_radio", "custom", "excel_date_time_format_custom", "radio"); + $oRadioCustom->SetDescription(Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip')); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); $oRadioCustom->SetBeforeInput(false); $oRadioCustom->GetInput()->AddCSSClass('ibo-input-checkbox'); $oFieldSetDate->AddSubBlock($oRadioCustom); - $sJSTooltip = json_encode('
'.Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip').'
'); $oP->add_ready_script( <<'; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "pdf_date_format_radio", "custom", "pdf_date_time_format_custom", "radio"); + $oRadioCustom->SetDescription(Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip')); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); $oRadioCustom->SetBeforeInput(false); $oRadioCustom->GetInput()->AddCSSClass('ibo-input-checkbox'); $oFieldSetDate->AddSubBlock($oRadioCustom); - $sJSTooltip = json_encode('
'.Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip').'
'); $oP->add_ready_script( <<'; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "spreadsheet_date_format_radio", "custom", "spreadsheet_date_time_format_custom", "radio"); + $oRadioCustom->SetDescription(Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip')); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); $oRadioCustom->GetInput()->AddCSSClass('ibo-input-checkbox'); $oRadioCustom->SetBeforeInput(false); $oFieldSetDate->AddSubBlock($oRadioCustom); - $sJSTooltip = json_encode('
'.Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip').'
'); $oP->add_ready_script( << select, input + label, label + input, label > input { margin-left: $ibo-input--spacing-left--with-label; +} + +label.ibo-has-description { + &::after { + content: $ibo-field--label--description--content; + padding-left: $ibo-field--label--description--padding-left; + vertical-align: top; + + cursor: pointer; + color: $ibo-field--label--description--color; + @extend %ibo-font-ral-bol-50; + } } \ No newline at end of file diff --git a/js/searchformforeignkeys.js b/js/searchformforeignkeys.js index 356ee6cda..724e7e70a 100644 --- a/js/searchformforeignkeys.js +++ b/js/searchformforeignkeys.js @@ -260,7 +260,7 @@ function SearchFormForeignKeys(id, sTargetClass, sAttCode, oSearchWidgetElmt, sF $(this).parents('tr:first').remove(); // Remove the whole line, so that, next time the dialog gets displayed it's no longer there } ); - theMap["sFilter"] = $('#datatable_ResultsToAdd_'+me.id).DataTable().ajax.params().filter; + theMap["sFilter"] = $('#datatable_ResultsToAdd_'+me.id+' [name="filter"]').val(); theMap["class"] = me.sTargetClass; theMap['operation'] = 'GetFullListForeignKeysFromSelection'; $('#busy_'+me.iInputId).html(' '); diff --git a/pages/csvimport.php b/pages/csvimport.php index 70c2ba262..886c16352 100644 --- a/pages/csvimport.php +++ b/pages/csvimport.php @@ -1328,6 +1328,7 @@ EOF $sFormatInput = ''; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('UI:CSVImport:CustomDateTimeFormat', $sFormatInput), "date_time_format", "custom", "radio_date_time_custom", "radio"); + $oRadioCustom->SetDescription(Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip')); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); $oRadioCustom->SetBeforeInput(false); $oRadioCustom->GetInput()->AddCSSClass('ibo-input-checkbox'); @@ -1424,11 +1425,9 @@ EOF } EOF ); - $sJSTooltip = json_encode('
'.Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip').'
'); $oPage->add_ready_script( <<getAttribute('_alteration') != 'removed') { $sPath = MFDocument::GetItopNodePath($oNode); $iLine = $oNode->getLineNo(); - throw new MFException($sPath.' at line '.$iLine.": could not be added (already exists)", MFException::COULD_NOT_BE_ADDED, - $iLine, $sPath); + $sExistingPath = MFDocument::GetItopNodePath($oExisting); + $iExistingLine = $oExisting->getLineNo(); + + $sExceptionMessage = <<ReplaceWithSingleNode($oNode); $sFlag = 'replaced'; diff --git a/sources/Application/UI/Base/Component/Input/InputWithLabel.php b/sources/Application/UI/Base/Component/Input/InputWithLabel.php index 1fc10ef7a..933315681 100644 --- a/sources/Application/UI/Base/Component/Input/InputWithLabel.php +++ b/sources/Application/UI/Base/Component/Input/InputWithLabel.php @@ -25,6 +25,11 @@ class InputWithLabel extends UIBlock protected $oInput; /** @var bool Label before input ? */ protected $bBeforeInput; + /** + * @var string $sDescription for tooltip + * @since 3.0.1 + */ + protected $sDescription; /** * @param string $sLabel @@ -102,4 +107,32 @@ class InputWithLabel extends UIBlock $this->sLabel = $sLabel; return $this; } + + /** + * @since 3.0.1 + * @return mixed + */ + public function GetDescription() + { + return $this->sDescription; + } + + /** + * @since 3.0.1 + * @param mixed $sDescription + */ + public function SetDescription($sDescription) + { + $this->sDescription = $sDescription; + return $this; + } + /** + * @since 3.0.1 + * @return bool + */ + public function HasDescription(): bool + { + return strlen($this->sDescription) > 0; + } + } \ No newline at end of file diff --git a/sources/Application/UI/Base/Component/Input/tInputLabel.php b/sources/Application/UI/Base/Component/Input/tInputLabel.php index 7e92bcdff..0038ff89c 100644 --- a/sources/Application/UI/Base/Component/Input/tInputLabel.php +++ b/sources/Application/UI/Base/Component/Input/tInputLabel.php @@ -18,6 +18,11 @@ trait tInputLabel protected $bIsLabelBefore = true; /** @var string|null Label to display with the input (null for no label) */ protected $sLabel = null; + /** + * @var string $sDescription for tooltip + * @since 3.0.1 + */ + protected $sDescription; /** * @return bool @@ -85,4 +90,27 @@ trait tInputLabel { return $this->sLabel != null; } + /** + * @return mixed + */ + public function GetDescription() + { + return $this->sDescription; + } + + /** + * @param mixed $sDescription + */ + public function SetDescription($sDescription) + { + $this->sDescription = $sDescription; + return $this; + } + /** + * @return bool + */ + public function HasDescription(): bool + { + return $this->sDescription != null; + } } \ No newline at end of file diff --git a/templates/base/components/input/inputlabel.html.twig b/templates/base/components/input/inputlabel.html.twig index 6045bc7f2..b9d557ed2 100644 --- a/templates/base/components/input/inputlabel.html.twig +++ b/templates/base/components/input/inputlabel.html.twig @@ -1,3 +1,3 @@ {# @copyright Copyright (C) 2010-2021 Combodo SARL #} {# @license http://opensource.org/licenses/AGPL-3.0 #} - \ No newline at end of file + \ No newline at end of file diff --git a/templates/base/components/input/inputwithlabel.html.twig b/templates/base/components/input/inputwithlabel.html.twig index de770a7ef..147ab1cba 100644 --- a/templates/base/components/input/inputwithlabel.html.twig +++ b/templates/base/components/input/inputwithlabel.html.twig @@ -1,10 +1,10 @@ {% block iboInputLabel %} {% if oUIBlock.IsLabelBefore() %} - + {{ render_block(oUIBlock.GetInput()) }} {% else %} {{ render_block(oUIBlock.GetInput()) }} - + {% endif %} {% endblock %} diff --git a/test/phpunit.xml.dist b/test/phpunit.xml.dist index 62e9da8be..fec60578f 100644 --- a/test/phpunit.xml.dist +++ b/test/phpunit.xml.dist @@ -40,55 +40,56 @@ timeoutForLargeTests="60" verbose="false"> - - - ../env-production/*/test - - - core - - - webservices - - - itop-tickets - - - itop-config - - - application - - - - sources - - - status - - - synchro - - - setup - - - integration - - - coreExtensions - - + + + ../env-production/*/test + + + core + + + webservices + + + itop-tickets + + + itop-config + + + application + + + + + sources + + + status + + + synchro + + + setup + + + integration + + + coreExtensions + + - - - - ../core/apc-emulation.php - ../core/ormlinkset.class.inc.php - ../datamodels/2.x/itop-tickets/main.itop-tickets.php - - + + + + ../core/apc-emulation.php + ../core/ormlinkset.class.inc.php + ../datamodels/2.x/itop-tickets/main.itop-tickets.php + + diff --git a/webservices/export-v2.php b/webservices/export-v2.php index c63629714..9f9df1a6b 100644 --- a/webservices/export-v2.php +++ b/webservices/export-v2.php @@ -13,6 +13,7 @@ use Combodo\iTop\Application\UI\Base\Component\Input\InputUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOptionUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Input\SelectUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Input\TextArea; +use Combodo\iTop\Application\UI\Base\Component\Panel\PanelUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Title\TitleUIBlockFactory; use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory; @@ -122,10 +123,11 @@ function Usage(Page $oP) function DisplayExpressionForm(WebPage $oP, $sAction, $sExpression = '', $sExceptionMessage = '') { - $oP->AddSubBlock(TitleUIBlockFactory::MakeForPage(Dict::S('Core:BulkExport:ScopeDefinition'))); + $oPanel = PanelUIBlockFactory::MakeNeutral(Dict::S('Core:BulkExport:ScopeDefinition')); + $oP->AddSubBlock($oPanel); $oForm = FormUIBlockFactory::MakeStandard('form'); $oForm->SetAction($sAction); - $oP->AddSubBlock($oForm); + $oPanel->AddSubBlock($oForm); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('interactive', '1')); @@ -149,26 +151,11 @@ function DisplayExpressionForm(WebPage $oP, $sAction, $sExpression = '', $sExcep $oSearch->UpdateContextFromUser(); $oQueries = new DBObjectSet($oSearch); while ($oQuery = $oQueries->Fetch()) { - $oSelect->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($oQuery->GetKey(), htmlentities($oQuery->Get('name'), ENT_QUOTES, 'UTF-8'), false)); + $oSelect->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($oQuery->GetKey(), $oQuery->Get('name'), false)); } $oFieldPhraseBook->AddSubBlock($oSelect); $oForm->AddSubBlock($oFieldPhraseBook); - /*oP->add(''); - $sExpressionHint = empty($sExceptionMessage) ? '' : ''; - $oP->add(''); - $oP->add(''); - $oP->add($sExpressionHint); - $oP->add(''); - $oP->add('');*/ $oForm->AddSubBlock(ButtonUIBlockFactory::MakeForPrimaryAction(Dict::S('UI:Button:Next'), "", "", true, "next-btn")); $oP->p(''.Dict::S('Core:BulkExportCanRunNonInteractive').''); $oP->p(''.Dict::S('Core:BulkExportLegacyExport').'');
'.htmlentities($sExceptionMessage, ENT_QUOTES, 'UTF-8').'