index.html.haml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. - content_for :page_title do
  2. = t('settings.import')
  3. = simple_form_for @import, url: settings_imports_path do |f|
  4. .field-group
  5. = f.input :type, as: :grouped_select, collection: { constructive: %i(following bookmarks lists), destructive: %i(muting blocking domain_blocking) }, wrapper: :with_block_label, include_blank: false, label_method: ->(type) { I18n.t("imports.types.#{type}") }, group_label_method: ->(group) { I18n.t("imports.type_groups.#{group.first}") }, group_method: :last, hint: t('imports.preface')
  6. .fields-row
  7. .fields-group.fields-row__column.fields-row__column-6
  8. = f.input :data, as: :file, wrapper: :with_block_label, hint: t('simple_form.hints.imports.data')
  9. .fields-group.fields-row__column.fields-row__column-6
  10. = f.input :mode, as: :radio_buttons, collection: Import::MODES, label_method: ->(mode) { safe_join([I18n.t("imports.modes.#{mode}"), content_tag(:span, I18n.t("imports.modes.#{mode}_long"), class: 'hint')]) }, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
  11. .actions
  12. = f.button :button, t('imports.upload'), type: :submit
  13. - unless @recent_imports.empty?
  14. %hr.spacer/
  15. %h3= t('imports.recent_imports')
  16. .table-wrapper
  17. %table.table
  18. %thead
  19. %tr
  20. %th= t('imports.type')
  21. %th= t('imports.status')
  22. %th= t('imports.imported')
  23. %th= t('imports.time_started')
  24. %th= t('imports.failures')
  25. %tbody
  26. - @recent_imports.each do |import|
  27. %tr
  28. %td= t("imports.types.#{import.type}")
  29. %td
  30. - if import.unconfirmed?
  31. = link_to t("imports.states.#{import.state}"), settings_import_path(import)
  32. - else
  33. = t("imports.states.#{import.state}")
  34. %td
  35. #{import.imported_items} / #{import.total_items}
  36. %td= l(import.created_at)
  37. %td
  38. - num_failed = import.processed_items - import.imported_items
  39. - if num_failed.positive?
  40. - if import.finished?
  41. = link_to num_failed, failures_settings_import_path(import, format: 'csv')
  42. - else
  43. = num_failed