diff --git a/app/components/documents/fields_component.html.erb b/app/components/documents/fields_component.html.erb index c5dabe5c2..4dc0c42ff 100644 --- a/app/components/documents/fields_component.html.erb +++ b/app/components/documents/fields_component.html.erb @@ -9,15 +9,15 @@
- <%= render_attachment %> + <%= file_field %>
- <%= render_destroy_document_link %> + <%= destroy_link %>
-

<%= document_attachment_file_name %>

+

<%= file_name %>

diff --git a/app/components/documents/fields_component.rb b/app/components/documents/fields_component.rb index 3e285ccf7..4d503d912 100644 --- a/app/components/documents/fields_component.rb +++ b/app/components/documents/fields_component.rb @@ -12,11 +12,11 @@ class Documents::FieldsComponent < ApplicationComponent f.object end - def document_attachment_file_name + def file_name document.attachment_file_name end - def render_destroy_document_link + def destroy_link if !document.persisted? && document.cached_attachment.present? link_to t("documents.form.delete_button"), direct_upload_destroy_path( @@ -33,19 +33,19 @@ class Documents::FieldsComponent < ApplicationComponent end end - def render_attachment + def file_field klass = document.persisted? || document.cached_attachment.present? ? " hide" : "" f.file_field :attachment, label_options: { class: "button hollow #{klass}" }, accept: accepted_content_types_extensions, class: "js-document-attachment", data: { - url: document_direct_upload_path, + url: direct_upload_path, nested_document: true } end - def document_direct_upload_path + def direct_upload_path direct_uploads_path("direct_upload[resource_type]": document.documentable_type, "direct_upload[resource_id]": document.documentable_id, "direct_upload[resource_relation]": "documents") diff --git a/app/components/images/fields_component.html.erb b/app/components/images/fields_component.html.erb index 5681bca1a..bff9555f1 100644 --- a/app/components/images/fields_component.html.erb +++ b/app/components/images/fields_component.html.erb @@ -11,15 +11,15 @@
- <%= render_image_attachment %> + <%= file_field %>
- <%= render_destroy_image_link %> + <%= destroy_link %>
-

<%= image_attachment_file_name %>

+

<%= file_name %>

diff --git a/app/components/images/fields_component.rb b/app/components/images/fields_component.rb index 088b1e585..0cc91d28c 100644 --- a/app/components/images/fields_component.rb +++ b/app/components/images/fields_component.rb @@ -13,11 +13,11 @@ class Images::FieldsComponent < ApplicationComponent f.object end - def image_attachment_file_name + def file_name image.attachment_file_name end - def render_destroy_image_link + def destroy_link if !image.persisted? && image.cached_attachment.present? link_to t("images.form.delete_button"), direct_upload_destroy_path( @@ -34,25 +34,25 @@ class Images::FieldsComponent < ApplicationComponent end end - def render_image_attachment + def file_field klass = image.persisted? || image.cached_attachment.present? ? " hide" : "" f.file_field :attachment, label_options: { class: "button hollow #{klass}" }, - accept: imageable_accepted_content_types_extensions, + accept: accepted_content_types_extensions, class: "js-image-attachment", data: { - url: image_direct_upload_path, + url: direct_upload_path, nested_image: true } end - def image_direct_upload_path + def direct_upload_path direct_uploads_path("direct_upload[resource_type]": imageable.class.name, "direct_upload[resource_id]": imageable.id, "direct_upload[resource_relation]": "image") end - def imageable_accepted_content_types_extensions + def accepted_content_types_extensions Setting.accepted_content_types_for("images").map do |content_type| if content_type == "jpg" ".jpg,.jpeg"