refactor(attachment): remove useless id
arg
This commit is contained in:
parent
0a114270af
commit
df135b080b
4 changed files with 7 additions and 13 deletions
|
@ -9,13 +9,12 @@ class Attachment::EditComponent < ApplicationComponent
|
|||
|
||||
EXTENSIONS_ORDER = ['jpeg', 'png', 'pdf', 'zip'].freeze
|
||||
|
||||
def initialize(champ: nil, auto_attach_url: nil, field_name: nil, attached_file:, direct_upload: true, id: nil, index: 0, as_multiple: false, user_can_download: false, **kwargs)
|
||||
def initialize(champ: nil, auto_attach_url: nil, field_name: nil, attached_file:, direct_upload: true, index: 0, as_multiple: false, user_can_download: false, **kwargs)
|
||||
@as_multiple = as_multiple
|
||||
@attached_file = attached_file
|
||||
@auto_attach_url = auto_attach_url
|
||||
@champ = champ
|
||||
@direct_upload = direct_upload
|
||||
@id = id
|
||||
@index = index
|
||||
@user_can_download = user_can_download
|
||||
|
||||
|
@ -62,7 +61,7 @@ class Attachment::EditComponent < ApplicationComponent
|
|||
{
|
||||
class: "fr-upload attachment-input #{attachment_input_class} #{persisted? ? 'hidden' : ''}",
|
||||
direct_upload: @direct_upload,
|
||||
id: input_id(@id),
|
||||
id: input_id,
|
||||
aria: { describedby: champ&.describedby_id },
|
||||
data: {
|
||||
auto_attach_url:
|
||||
|
@ -144,9 +143,7 @@ class Attachment::EditComponent < ApplicationComponent
|
|||
|
||||
private
|
||||
|
||||
def input_id(given_id)
|
||||
return given_id if given_id.present?
|
||||
|
||||
def input_id
|
||||
if champ.present?
|
||||
# Single or first attachment input must match label "for" attribute. Others must remain unique.
|
||||
return champ.input_id if @index.zero?
|
||||
|
|
|
@ -4,17 +4,15 @@ class Attachment::MultipleComponent < ApplicationComponent
|
|||
|
||||
attr_reader :form
|
||||
attr_reader :attached_file
|
||||
attr_reader :id
|
||||
attr_reader :user_can_destroy
|
||||
attr_reader :max
|
||||
|
||||
delegate :count, :empty?, to: :attachments, prefix: true
|
||||
|
||||
def initialize(form:, attached_file:, user_can_destroy: false, id: nil, max: nil)
|
||||
def initialize(form:, attached_file:, user_can_destroy: false, max: nil)
|
||||
@form = form
|
||||
@attached_file = attached_file
|
||||
@user_can_destroy = user_can_destroy
|
||||
@id = id
|
||||
@max = max || 10
|
||||
|
||||
@attachments = attached_file.attachments || []
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
- each_attachment do |attachment, index|
|
||||
%div{ id: dom_id(attachment) }
|
||||
= render Attachment::EditComponent.new(champ:, attached_file:, attachment:, id:, index:, as_multiple: true)
|
||||
= render Attachment::EditComponent.new(champ:, attached_file:, attachment:, index:, as_multiple: true)
|
||||
|
||||
%div{ id: empty_component_id, class: class_names("hidden": !can_attach_next?) }
|
||||
= render Attachment::EditComponent.new(champ:, attached_file:, attachment: nil, id:, index: attachments_count)
|
||||
= render Attachment::EditComponent.new(champ:, attached_file:, attachment: nil, index: attachments_count)
|
||||
|
||||
// single poll and refresh message for all attachments
|
||||
- if in_progress?
|
||||
|
|
|
@ -77,8 +77,7 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent
|
|||
def piece_justificative_template_options
|
||||
{
|
||||
attached_file: type_de_champ.piece_justificative_template,
|
||||
auto_attach_url: helpers.auto_attach_url(type_de_champ),
|
||||
id: dom_id(type_de_champ, :piece_justificative_template)
|
||||
auto_attach_url: helpers.auto_attach_url(type_de_champ)
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue