N°330 - Attachments: Fix empty "Delete" column displayed all the time

This commit is contained in:
Molkobain
2020-01-24 16:17:26 +01:00
parent c48bbfd32a
commit cca79735fc

View File

@@ -112,6 +112,7 @@ class BsFileUploadFieldRenderer extends BsFieldRenderer
$sAttachmentTableId = $this->GetAttachmentsTableId();
$sNoAttachmentLabel = json_encode(Dict::S('Attachments:NoAttachment'));
$sDeleteColumnDef = $bIsDeleteAllowed ? '{ targets: [4], orderable: false},' : '';
$oOutput->AddJs(
<<<JS
// Collapse handlers
@@ -144,8 +145,8 @@ var buildTable_{$this->oField->GetGlobalId()} = function()
"dom": "t",
"order": [[3, "asc"]],
"columnDefs": [
{ targets: [4], orderable: false},
{ targets: '_all', orderable: true }
$sDeleteColumnDef
{ targets: '_all', orderable: true },
],
"language": {
"infoEmpty": $sNoAttachmentLabel,
@@ -390,7 +391,7 @@ JS
}
else
{
$sTableHead = self::GetAttachmentTableHeader();
$sTableHead = self::GetAttachmentTableHeader($bIsDeleteAllowed);
$oOutput->Addhtml(<<<HTML
<table id="$sAttachmentTableId" class="attachments-list table table-striped responsive">
$sTableHead
@@ -470,6 +471,9 @@ HTML
$sTitleFileSize = Dict::S('Attachments:File:Size');
$sTitleFileDate = Dict::S('Attachments:File:Date');
// Optional column
$sDeleteHeaderAsHtml = ($bIsDeleteAllowed) ? '<th role="delete" data-priority="1"></th>' : '';
return <<<HTML
<thead>
<th role="icon">$sTitleThumbnail</th>