From e0482febbfa7ee110be745801f1082c5b36cfe11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Fri, 18 Oct 2024 12:43:51 +0200 Subject: [PATCH] Wrong file size when uploading documents #1556 --- app/views/dmsf_upload/_upload_file.html.erb | 5 +++-- app/views/dmsf_upload/_upload_file_locked.html.erb | 4 ++-- assets/javascripts/attachments_dmsf.js | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/views/dmsf_upload/_upload_file.html.erb b/app/views/dmsf_upload/_upload_file.html.erb index 752be596..2d12f148 100644 --- a/app/views/dmsf_upload/_upload_file.html.erb +++ b/app/views/dmsf_upload/_upload_file.html.erb @@ -22,6 +22,7 @@ <%= hidden_field_tag "committed_files[#{i}][disk_filename]", upload.disk_filename %> <%= hidden_field_tag "committed_files[#{i}][token]", upload.token %> <%= hidden_field_tag "committed_files[#{i}][digest]", upload.digest %> + <%= hidden_field_tag "committed_files[#{i}][size]", upload.size %>

@@ -56,8 +57,8 @@ <%= text_field_tag "committed_files[#{i}][mime_type]", h(upload.mime_type), readonly: true %>

- <%= label_tag "committed_files[#{i}][size]", l(:label_size) %> - <%= text_field_tag "committed_files[#{i}][size]", number_to_human_size(upload.size), readonly: true %> + <%= label_tag "committed_files[#{i}][human_size]", l(:label_size) %> + <%= text_field_tag "committed_files[#{i}][human_size]", number_to_human_size(upload.size), readonly: true %>

diff --git a/app/views/dmsf_upload/_upload_file_locked.html.erb b/app/views/dmsf_upload/_upload_file_locked.html.erb index 49fef6e9..abd01f67 100644 --- a/app/views/dmsf_upload/_upload_file_locked.html.erb +++ b/app/views/dmsf_upload/_upload_file_locked.html.erb @@ -47,8 +47,8 @@ <%= text_field_tag "committed_files[#{i}][mime_type]", upload.mime_type, readonly: true %>

- <%= label_tag "committed_files[#{i}][size]", l(:label_size) %> - <%= text_field_tag "committed_files[#{i}][size]", number_to_human_size(upload.size), readonly: true %> + <%= label_tag "committed_files[#{i}][human_size]", l(:label_size) %> + <%= text_field_tag "committed_files[#{i}][human_size]", number_to_human_size(upload.size), readonly: true %>

diff --git a/assets/javascripts/attachments_dmsf.js b/assets/javascripts/attachments_dmsf.js index 357ed155..9a6b885a 100644 --- a/assets/javascripts/attachments_dmsf.js +++ b/assets/javascripts/attachments_dmsf.js @@ -207,8 +207,10 @@ function dmsfAddFile(inputEl, file, eagerUpload) { detailsForm = detailsForm.replace('id="committed_files_' + attachmentId + '_title"', 'id="committed_files_' + attachmentId + '_title" value = "' + filenameToTitle(file.name) + '"'); // Size - detailsForm = detailsForm.replace('id="committed_files_' + attachmentId + '_size"', - 'id="committed_files_' + attachmentId + '_size" value = "' + humanFileSize(file.size) + '"'); + detailsForm = detailsForm.replace('id="committed_files_' + attachmentId + '_human_size"', + 'id="committed_files_' + attachmentId + '_human_size" value = "' + humanFileSize(file.size) + '"'); + detailsForm = detailsForm.replace('id="committed_files_' + attachmentId + '_size" value="0"', + 'id="committed_files_' + attachmentId + '_size" value = "' + file.size + '"'); // Mime type detailsForm = detailsForm.replace('id="committed_files_' + attachmentId + '_mime_type"', 'id="committed_files_' + attachmentId + '_mime_type" value = "' + file.type + '"');