From 499d429a0ea1c84e9b02486fbed1ce5f71479838 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Wed, 2 Jun 2021 10:01:06 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B03927=20Fix=20Attachments=20delete=20butt?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../renderers.itop-attachments.php | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) 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(); }