Simplify method names in image/document fields
We were using long, unique names because these methods used to be helper methods. Helper methods should have unique names because otherwise one method would overwrite the other. Now that we're using components, we can omit the `image_` and `document_` prefixes.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user