From 7a2bfc12ce19b2bb85bf3d4f04cb74752c2bb748 Mon Sep 17 00:00:00 2001 From: Urban Rotnik Date: Tue, 23 Apr 2019 13:35:10 +0200 Subject: [PATCH] Remove form_asset partial --- app/assets/stylesheets/steps.scss | 2 +- app/views/steps/_empty_step.html.erb | 5 +++-- app/views/steps/attachments/_item.html.erb | 19 ++---------------- .../_placeholder.html.erb} | 20 ++++++++++--------- 4 files changed, 17 insertions(+), 29 deletions(-) rename app/views/steps/{_form_assets.html.erb => attachments/_placeholder.html.erb} (54%) diff --git a/app/assets/stylesheets/steps.scss b/app/assets/stylesheets/steps.scss index bdc04c3b2..70f6b5196 100644 --- a/app/assets/stylesheets/steps.scss +++ b/app/assets/stylesheets/steps.scss @@ -86,7 +86,7 @@ .attacments { display: flex; flex-wrap: wrap; - justify-content: space-between; + justify-content: space-evenly; } .attachment-placeholder { diff --git a/app/views/steps/_empty_step.html.erb b/app/views/steps/_empty_step.html.erb index 9693e7ca6..490acd5aa 100644 --- a/app/views/steps/_empty_step.html.erb +++ b/app/views/steps/_empty_step.html.erb @@ -62,8 +62,9 @@
<%= f.nested_fields_for :assets do |ff| %> - <%= render "form_assets.html.erb", ff: ff, step: step %> - <% end %> + <%= render partial: 'steps/attachments/placeholder.html.erb', + locals: { edit_page: true, asset: ff.object, ff: ff } %> + <% end %>
diff --git a/app/views/steps/attachments/_item.html.erb b/app/views/steps/attachments/_item.html.erb index c1dc45310..c86de2fed 100644 --- a/app/views/steps/attachments/_item.html.erb +++ b/app/views/steps/attachments/_item.html.erb @@ -1,5 +1,3 @@ -<% image_preview = asset.is_image? ? asset.url(:medium) : nil %> - <%= link_to download_asset_path(asset), class: 'file-preview-link', id: "modal_link#{asset.id}", @@ -12,19 +10,6 @@ 'order-new': assets_count - i, } do %> -
-
- <% if image_preview %> - <%= image_tag image_preview %> - <% else %> - - <% end %> -
-
<%= truncate(asset.file_file_name, - length: Constants::FILENAME_TRUNCATION_LENGTH) %>
-
- <%= t('protocols.steps.attachments.modified_label') %> <%= l(asset.updated_at, format: :full_date) %>
- <%= number_to_human_size(asset.file.size) %> -
-
+ <%= render partial: 'steps/attachments/placeholder.html.erb', + locals: { edit_page: false, asset: asset } %> <% end %> diff --git a/app/views/steps/_form_assets.html.erb b/app/views/steps/attachments/_placeholder.html.erb similarity index 54% rename from app/views/steps/_form_assets.html.erb rename to app/views/steps/attachments/_placeholder.html.erb index d3eb67563..88ffac1cb 100644 --- a/app/views/steps/_form_assets.html.erb +++ b/app/views/steps/attachments/_placeholder.html.erb @@ -1,4 +1,3 @@ -<% asset = ff.object %> <% image_preview = asset.is_image? ? asset.url(:medium) : nil %>
@@ -6,20 +5,23 @@ <% if image_preview %> <%= image_tag image_preview %> <% else %> - + <% end %>
<%= truncate(asset.file_file_name, length: Constants::FILENAME_TRUNCATION_LENGTH) %>
- Modified: <%= l(asset.updated_at, format: :full_date) if asset.updated_at %>
+ <%= t('protocols.steps.attachments.modified_label') %> <%= l(asset.updated_at, format: :full_date) if asset.updated_at %>
<%= number_to_human_size(asset.file.size) %>
-
- <% unless ff.object.file.exists? && ff.object.locked? %> - <%= ff.remove_nested_fields_link do %> - + + <% if edit_page %> +
+ <% unless ff.object.file.exists? && ff.object.locked? %> + <%= ff.remove_nested_fields_link do %> + + <% end %> <% end %> - <% end %> -
+
+<% end %>