Module: AssetZipImportable::ApplicationHelper

Defined in:
app/helpers/asset_zip_importable/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#import_form_for(new_import, url, html_options = {}) ⇒ Object



3
4
5
6
7
8
# File 'app/helpers/asset_zip_importable/application_helper.rb', line 3

def import_form_for(new_import, url, html_options = {})
  form_for(new_import, url: url, html: { class: 'form-inline' }.merge(html_options)) do |f|
    f.file_field(:zip) +
    f.submit('インポート', class: 'btn')
  end
end

#imports_table(imports) ⇒ Object



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 'app/helpers/asset_zip_importable/application_helper.rb', line 10

def imports_table(imports)
  (:table, class: 'table') do
    (:thead) do
      (:tr) do
        (:th, 'id') +
        (:th, 'zip') +
        (:th, 'アップロード日時') +
        (:th, '処理済み件数') +
        (:th, '全件数') +
        (:th, '状態')
      end
    end +
    (:tbody) do
      imports.map do |import|
        (:tr) do
          (:td, import.id.to_s) +
          (:td, link_to(import.read_attribute(:zip), import.zip_url)) +
          (:td, import.created_at.to_s) +
          (:td, import.completed_number.to_s) +
          (:td, import.total_number.to_s) +
          (:td) do
            if import.completed?
              (:span, '完了', class: 'label label-success')
            else
              (:span, '未完了', class: 'label label-default')
            end
          end
        end
      end.join.html_safe
    end
  end
end