diff --git a/css/backoffice/pages/_attachments.scss b/css/backoffice/pages/_attachments.scss
index 06902795e..f91530a38 100644
--- a/css/backoffice/pages/_attachments.scss
+++ b/css/backoffice/pages/_attachments.scss
@@ -5,6 +5,12 @@ $ibo-attachment--datatable--line-height: $ibo-attachment--datatable--icon-previe
$ibo-attachment--datatable--first-column--line-height: 0px !default;
+#ibo-attachment--upload-file{
+ .ibo-input-file-select--container{
+ display: inline-block;
+ }
+}
+
.ibo-attachment--datatable--icon-preview{
max-height: $ibo-attachment--datatable--icon-preview--max-height;
max-width: $ibo-attachment--datatable--icon-preview--max-width;
diff --git a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php
index c124c66fc..579dbd93c 100644
--- a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php
+++ b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php
@@ -26,6 +26,7 @@
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;
use Combodo\iTop\Renderer\BlockRenderer;
define('ATTACHMENT_DOWNLOAD_URL', 'pages/ajax.document.php?operation=download_document&class=Attachment&field=contents&id=');
@@ -178,13 +179,17 @@ abstract class AbstractAttachmentsRenderer
{
$sClass = $this->sObjClass;
$sId = $this->iObjKey;
-
- $this->oPage->add('
');
$iMaxUploadInBytes = AttachmentPlugIn::GetMaxUploadSize();
$sMaxUploadLabel = AttachmentPlugIn::GetMaxUpload();
$sFileTooBigLabel = Dict::Format('Attachments:Error:FileTooLarge', $sMaxUploadLabel);
$sFileTooBigLabelForJS = addslashes($sFileTooBigLabel);
- $this->oPage->p(Dict::S('Attachments:AddAttachment').'
'.$sMaxUploadLabel);
+ $this->oPage->add('');
+ $this->oPage->add(Dict::S('Attachments:AddAttachment'));
+ $oAddButton = FileSelectUIBlockFactory::MakeStandard('file', 'file');
+ $oAddButton->SetShowFilename(false);
+ $this->oPage->AddUiBlock($oAddButton);
+ $this->oPage->add('

'.$sMaxUploadLabel);
+
$this->oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.iframe-transport.js');
$this->oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.fileupload.js');
@@ -318,6 +323,7 @@ abstract class AbstractAttachmentsRenderer
JS
);
$this->oPage->p('
');
+ $this->oPage->add('
');
$this->oPage->add_style(<<sName = $sName;
$this->sFileName = Dict::S('UI:InputFile:NoFileSelected');
$this->sButtonText = Dict::S('UI:InputFile:SelectFile');
+ $this->bShowFilename = true;
}
/**
@@ -80,4 +83,25 @@ class FileSelect extends UIBlock
{
return $this->sName;
}
+
+ /**
+ * @param bool $bShowFilename
+ *
+ * @return $this
+ */
+ public function SetShowFilename(bool $bShowFilename)
+ {
+ $this->bShowFilename = $bShowFilename;
+
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function GetShowFilename(): bool
+ {
+ return $this->bShowFilename;
+ }
+
}
\ No newline at end of file
diff --git a/templates/base/components/input/file-select/layout.js.twig b/templates/base/components/input/file-select/layout.js.twig
index 3c0669a6c..554d1ddf1 100644
--- a/templates/base/components/input/file-select/layout.js.twig
+++ b/templates/base/components/input/file-select/layout.js.twig
@@ -1,7 +1,8 @@
{# @copyright Copyright (C) 2010-2021 Combodo SARL #}
{# @license http://opensource.org/licenses/AGPL-3.0 #}
-
-$('#{{ oUIBlock.GetId() }}').bind('change', function() {
- var fileName = $(this).val().replace(/^.*[\\\/]/, '');
- $('#{{ oUIBlock.GetId() }}-file-name').html(fileName);
-});
\ No newline at end of file
+{% if oUIBlock.GetShowFilename() == true %}
+ $('#{{ oUIBlock.GetId() }}').bind('change', function() {
+ var fileName = $(this).val().replace(/^.*[\\\/]/, '');
+ $('#{{ oUIBlock.GetId() }}-file-name').html(fileName);
+ });
+{% endif %}
\ No newline at end of file