From 9812a9f16091da3e4da47ff4646f909156c74fab Mon Sep 17 00:00:00 2001 From: zmagod Date: Fri, 13 Apr 2018 09:43:14 +0200 Subject: [PATCH 1/2] adds correct preview images to files [fixes SCI-2254] --- app/helpers/file_icons_helper.rb | 6 +++++- app/views/my_modules/archive.html.erb | 5 ++--- app/views/my_modules/archive/_result.html.erb | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/helpers/file_icons_helper.rb b/app/helpers/file_icons_helper.rb index 8c12947e2..1bed35a35 100644 --- a/app/helpers/file_icons_helper.rb +++ b/app/helpers/file_icons_helper.rb @@ -9,10 +9,14 @@ module FileIconsHelper file_ext = asset.file_file_name.split('.').last if %w(doc docm docx dot dotm dotx odt rtf).include?(file_ext) fa_class = 'fa-file-word' - elsif %w(csv ods xls xlsb xlsm xlsx).include?(file_ext) + elsif %w(ods xls xlsb xlsm xlsx).include?(file_ext) fa_class = 'fa-file-excel' elsif %w(odp pot potm potx pps ppsm ppsx ppt pptm pptx).include?(file_ext) fa_class = 'fa-file-powerpoint' + elsif %w(pdf).include?(file_ext) + fa_class = 'fa-file-pdf' + elsif %w(txt csv tab tex).include?(file_ext) + fa_class = 'fa-file-alt' end # Now check for custom mappings or possible overrides diff --git a/app/views/my_modules/archive.html.erb b/app/views/my_modules/archive.html.erb index 6e9871e84..cd698b95f 100644 --- a/app/views/my_modules/archive.html.erb +++ b/app/views/my_modules/archive.html.erb @@ -6,14 +6,13 @@
<% i = 0 %> <% @archived_results.each do |result| %> - <%= render partial: "my_modules/archive/result.html.erb", locals: { result: result } %> - <% i = i + 1 %> <% end %> - <% if i == 0 %> <%=t "my_modules.module_archive.no_archived_results" %> <% end %>
+ + diff --git a/app/views/my_modules/archive/_result.html.erb b/app/views/my_modules/archive/_result.html.erb index f0f0c25c1..64cd5a73b 100644 --- a/app/views/my_modules/archive/_result.html.erb +++ b/app/views/my_modules/archive/_result.html.erb @@ -9,7 +9,10 @@
  • <% option_text = t("my_modules.module_archive.option_download") %> <% if result.is_asset %> - <%= link_to option_text, download_asset_path(result.asset), data: {no_turbolink: true} %> + <%= link_to 'View', download_asset_path(result.asset), + class: 'file-preview-link', + id: "modal_link#{result.asset.id}", + data: { no_turbolink: true, id: true, status: 'asset-present', 'preview-url': asset_file_preview_path(result.asset) } %> <% elsif result.is_text %> <%= link_to option_text, result_text_download_path(result.result_text_id), data: {no_turbolink: true} %> <% elsif result.is_table %> From 66cc76f640581ba64865e7b371c3a661dc4541bd Mon Sep 17 00:00:00 2001 From: zmagod Date: Thu, 19 Apr 2018 12:49:32 +0200 Subject: [PATCH 2/2] add view label in locales --- app/views/my_modules/archive/_result.html.erb | 2 +- config/locales/en.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/my_modules/archive/_result.html.erb b/app/views/my_modules/archive/_result.html.erb index 64cd5a73b..2c5a9cee3 100644 --- a/app/views/my_modules/archive/_result.html.erb +++ b/app/views/my_modules/archive/_result.html.erb @@ -9,7 +9,7 @@
  • <% option_text = t("my_modules.module_archive.option_download") %> <% if result.is_asset %> - <%= link_to 'View', download_asset_path(result.asset), + <%= link_to t('protocols.index.archive_results.preview'), download_asset_path(result.asset), class: 'file-preview-link', id: "modal_link#{result.asset.id}", data: { no_turbolink: true, id: true, status: 'asset-present', 'preview-url': asset_file_preview_path(result.asset) } %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 2621e0a95..479b7b89c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1654,6 +1654,7 @@ en: row_success: "Archived" row_renamed: "Archived & renamed" row_failed: "Failed" + preview: "View" restore_results: title: "Restore results" message_failed: "Failed to restore %{nr} protocols."