diff --git a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php index bc3373534..70ef16cb0 100644 --- a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php +++ b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php @@ -24,6 +24,7 @@ */ +use Combodo\iTop\Application\UI\Base\Component\Button\Button; use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Input\FileSelect\FileSelectUIBlockFactory; @@ -358,13 +359,14 @@ JS protected function GetDeleteAttachmentButton($iAttId) { - $oButton = ButtonUIBlockFactory::MakeDestructiveIconLink('fas fa-trash', Dict::S('Attachments:DeleteBtn'), + $oButton = ButtonUIBlockFactory::MakeIconAction('fas fa-trash', Dict::S('Attachments:DeleteBtn'), '', Dict::S('Attachments:DeleteBtn'), - null, + false, "btn_remove_".$iAttId); $oButton->AddCSSClass('btn_hidden') - ->SetOnClickJsCode("RemoveAttachment(".$iAttId.");"); + ->SetOnClickJsCode("RemoveAttachment(".$iAttId.");") + ->SetColor(Button::ENUM_COLOR_DESTRUCTIVE); return $oButton; } @@ -452,6 +454,18 @@ class TableDetailsAttachmentsRenderer extends AbstractAttachmentsRenderer $this->oPage->AddUiBlock($oAttachmentTableBlock); $sTableId = $oAttachmentTableBlock->GetId(); + + foreach ($aData as $aAtt){ + $sJS = $aAtt['js']; + $this->oPage->add_ready_script( + << $sAttachmentDateFormatted, 'uploader' => $sAttachmentUploader, 'type' => $sFileType, + 'js' => '', ); if ($bWithDeleteButton) @@ -547,7 +562,7 @@ class TableDetailsAttachmentsRenderer extends AbstractAttachmentsRenderer $sDeleteButton = $this->GetDeleteAttachmentButton($iAttachmentId); $oBlockRenderer = new BlockRenderer($sDeleteButton); - $this->oPage->add_ready_script($oBlockRenderer->RenderJsInline($sDeleteButton::ENUM_JS_TYPE_ON_INIT)); + $aAttachmentLine['js'] .= $oBlockRenderer->RenderJsInline($sDeleteButton::ENUM_JS_TYPE_ON_INIT); $aAttachmentLine['delete'] = $oBlockRenderer->RenderHtml(); }