From 2d3a53e449d79df110c274c8ce6a6538bf58bae3 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 31 Jul 2025 13:20:24 +0100 Subject: [PATCH] Made existing formatters more flexible, removed unused Signed-off-by: snipe --- resources/views/hardware/view.blade.php | 2 +- resources/views/locations/view.blade.php | 2 +- .../views/partials/bootstrap-table.blade.php | 57 ++++++++++++------- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 1530ffd24e..46864398de 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -1390,7 +1390,7 @@ {{ trans('general.created_by') }} {{ trans('general.file_name') }} {{ trans('general.notes') }} - {{ trans('general.download') }} + {{ trans('general.download') }} {{ trans('admin/hardware/table.changed')}} {{ trans('admin/settings/general.login_ip') }} {{ trans('admin/settings/general.login_user_agent') }} diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php index 9f6f2dee9d..377ce91399 100644 --- a/resources/views/locations/view.blade.php +++ b/resources/views/locations/view.blade.php @@ -400,7 +400,7 @@ {{ trans('general.target') }} {{ trans('general.notes') }} {{ trans('general.signature') }} - {{ trans('general.download') }} + {{ trans('general.download') }} {{ trans('admin/hardware/table.changed')}} diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index cf6be7bfbf..382ff648c2 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -910,28 +910,42 @@ } + // This is users in the user accounts section for EULAs function downloadFormatter(value) { if (value) { return ''; } } + // This is used by the UploadedFilesPresenter and the HistoryPresenter + // It handles the download and inline buttons for files that are uploaded to assets, users, etc function fileDownloadButtonsFormatter(row, value) { - if ((value) && (value.url)) { + if (value) { + if (value.url) { + var inlinable = value.inlineable; + var exists_on_disk = value.exists_on_disk; + var download_url = value.url; + } else if (value.file) { + var inlinable = value.file.inlineable; + var exists_on_disk = value.file.exists_on_disk; + var download_url = value.file.url; + } else { + return ''; + } - var download_button = ''; + var download_button = ''; var download_button_disabled = ''; - var inline_button = ''; + var inline_button = ''; var inline_button_disabled = ''; - if (value.exists_on_disk) { - return '' + download_button + ' ' + inline_button + ''; + if (exists_on_disk === true) { + return '' + download_button + ' ' + inline_button + ''; } else { return '' + download_button_disabled + ' ' + inline_button_disabled + ''; } - } + } } @@ -953,13 +967,6 @@ } - function fileUploadFormatter(value) { - if ((value) && (value.url) && (value.inlineable)) { - return ''; - } else if ((value) && (value.url)) { - return ''; - } - } // This is used in the table listings @@ -1019,7 +1026,7 @@ .replace('%FILENAME%', (row.exists_on_disk === true) ? row.filename : ' ' + row.filename + '') .replace('%CREATED_AT%', row.created_at.formatted) .replace('%CREATED_BY%', (row.created_by) ? row.created_by.name : '') - .replace('%NOTE%', row.note) + .replace('%NOTE%', (row.note) ? row.note : '') .replace('%PANEL_CLASS%', (row.exists_on_disk === true) ? 'default' : 'danger') .replace('%FILE_EMBED%', embed_code) .replace('%DOWNLOAD_BUTTON%', (row.exists_on_disk === true) ? ' ' : '') @@ -1035,18 +1042,28 @@ + function fileNameFormatter(row, value) { + if (value) { + if ((value.file) && (value.file.filename) && (value.file.url)) { - function fileUploadNameFormatter(row, value) { - if ((value) && (value.filename) && (value.url)) { - if (value.exists_on_disk) { - return '' + value.filename + ''; + if (value.file.exists_on_disk === true) { + return '' + value.file.filename + ''; + } + + return ' ' + value.file.filename + ''; + + } else if ((value.filename) && (value.url)) { + if (value.exists_on_disk === true) { + return '' + value.filename + ''; + } + return ' ' + value.filename + ''; } - return ' ' + value.filename + ''; } - return '--'; + } + function linkToUserSectionBasedOnCount (count, id, section) { if (count) { return '' + count + '';