refactor(piece_justificative): UX follows mockups
This commit is contained in:
parent
84ca01bdf7
commit
b13c5e56f6
39 changed files with 373 additions and 272 deletions
|
@ -22,19 +22,43 @@ class Attachment::MultipleComponent < ApplicationComponent
|
|||
@attachments = attached_file.attachments || []
|
||||
end
|
||||
|
||||
def champ
|
||||
form.object
|
||||
end
|
||||
|
||||
def each_attachment(&block)
|
||||
@attachments.each_with_index(&block)
|
||||
end
|
||||
|
||||
def can_attach_next?
|
||||
return false if @attachments.empty?
|
||||
return false if !@attachments.last.persisted?
|
||||
|
||||
@attachments.count < @max
|
||||
end
|
||||
|
||||
def stimulus_controller_name
|
||||
"attachment-multiple"
|
||||
def empty_component_id
|
||||
"attachment-multiple-empty-#{form.object.id}"
|
||||
end
|
||||
|
||||
def in_progress?
|
||||
@attachments.any? do
|
||||
attachment_in_progress?(_1)
|
||||
end
|
||||
end
|
||||
|
||||
def in_progress_long?
|
||||
@attachments.any? do
|
||||
attachment_in_progress?(_1) && _1.created_at < 30.seconds.ago
|
||||
end
|
||||
end
|
||||
|
||||
def poll_controller_options
|
||||
{
|
||||
controller: 'turbo-poll',
|
||||
turbo_poll_url_value: auto_attach_url
|
||||
}
|
||||
end
|
||||
|
||||
def auto_attach_url
|
||||
helpers.auto_attach_url(form.object)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -42,4 +66,8 @@ class Attachment::MultipleComponent < ApplicationComponent
|
|||
def attachments
|
||||
@attachments
|
||||
end
|
||||
|
||||
def attachment_in_progress?(attachment)
|
||||
attachment.virus_scanner.pending? || attachment.watermark_pending?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue