Module: DropzoneInput::Helpers
- Defined in:
- lib/dropzone_input/helpers.rb
Instance Method Summary collapse
-
#dropzone(form, field, options = {}) ⇒ Object
rubocop:disable Style/OptionHash.
Instance Method Details
#dropzone(form, field, options = {}) ⇒ Object
rubocop:disable Style/OptionHash
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dropzone_input/helpers.rb', line 5 def dropzone(form, field, = {}) # rubocop:disable Style/OptionHash class_list = .delete(:class) class_list = ['dropzone', class_list].compact.join(' ') [:max_file_size] /= 1.megabyte if [:max_file_size] data = { controller: 'dropzone', dropzone_accepted_files: .delete(:accepted_files) || ActiveStorage.variable_content_types.join(',') } %i( croppable file_added_event file_drop_event file_drop_id file_drop_over_id file_progress_event file_removed_event file_start_event file_success_event max_file_size max_files max_thumbnail_file_size parallel_uploads queue_complete_event thumbnail_height thumbnail_width ).each do |key| data["dropzone_#{key}".to_sym] = .delete(key) if .key?(key) end content_tag :div, .merge(class: class_list, data: data) do render 'dropzone_input/dropzone', form: form, field: field do block_given? ? yield : render('dropzone_input/default_content') end end end |