File: export.html.haml

package info (click to toggle)
ruby-rails-admin 0.8.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,492 kB
  • ctags: 1,292
  • sloc: ruby: 5,341; makefile: 3
file content (83 lines) | stat: -rw-r--r-- 5,464 bytes parent folder | download
1
2
3
4
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
- params = request.params.except(:action, :controller, :utf8, :page, :per_page, :format, :authenticity_token)
- visible_fields = @model_config.export.with(view: self, object: @abstract_model.model.new, controller: self.controller).visible_fields

= form_tag export_path(params.merge(all: true)), method: 'post', class: 'form-horizontal denser' do

  %input{name: "send_data", type: "hidden", value: "true"}/
  %fieldset{id: 'fields_to_export'}
    %legend
      %i.icon-chevron-down
      = t('admin.export.select')
    .form-group.control-group.col-sm-12
      .controls
        .col-sm-12
        %label.col-sm-12.checkbox{for: 'check_all'}
          = check_box_tag 'all', 'all', true, { id: 'check_all' }
          = t('admin.export.select_all_fields')
    .form-group.control-group.col-sm-12
      %label.col-sm-12.well.control-label{rel: 'tooltip', :'data-original-title' => t('admin.export.click_to_reverse_selection'), onclick: 'jQuery(this).siblings(".controls").find("input").click()'}= t('admin.export.fields_from', name: @model_config.label_plural.downcase)
      .col-sm-11.col-sm-offset-1.controls
        - visible_fields.select{ |f| !f.association? || f.association.polymorphic? }.each do |field|
          - list = field.virtual? ? 'methods' : 'only'
          - if field.association? && field.association.polymorphic?
            %label.checkbox.col-sm-3{for: "schema_#{list}_#{field.method_name}"}
              = check_box_tag "schema[#{list}][]", field.method_name, true, { id: "schema_#{list}_#{field.method_name}" }
              = field.label + " [id]"
            - polymorphic_type_column_name = @abstract_model.properties.detect {|p| field.association.foreign_type == p.name }.name
            %label.checkbox.col-sm-3{for: "schema_#{list}_#{polymorphic_type_column_name}"}
              = check_box_tag "schema[#{list}][]", polymorphic_type_column_name, true, { id: "schema_#{list}_#{polymorphic_type_column_name}" }
              = capitalize_first_letter(field.label) + " [type]"
          - else
            %label.checkbox.col-sm-3{for: "schema_#{list}_#{field.name}"}
              = check_box_tag "schema[#{list}][]", field.name, true, { id: "schema_#{list}_#{field.name}" }
              = capitalize_first_letter(field.label)

    - visible_fields.select{ |f| f.association? && !f.association.polymorphic? }.each do |field|
      - fields = field.associated_model_config.export.with(controller: self.controller, view: self, object: (associated_model = field.associated_model_config.abstract_model.model).new).visible_fields.select{ |f| !f.association? }
      .form-group.control-group.col-sm-12
        %label.col-sm-12.well.control-label{rel: 'tooltip', :'data-original-title' => t('admin.export.click_to_reverse_selection'), onclick: 'jQuery(this).siblings(".controls").find("input").click()'}= t('admin.export.fields_from_associated', name: field.label.downcase)
        .col-sm-11.col-sm-offset-1.controls
          - fields.each do |associated_model_field|
            - list = associated_model_field.virtual? ? 'methods' : 'only'
            %label.checkbox.col-sm-3{for: "schema_include_#{field.name}_#{list}_#{associated_model_field.name}"}
              = check_box_tag "schema[include][#{field.name}][#{list}][]", associated_model_field.name, true, { id: "schema_include_#{field.name}_#{list}_#{associated_model_field.name}" }
              = capitalize_first_letter(associated_model_field.label)

  %fieldset
    %legend
      %i.icon-chevron-down
      = t('admin.export.options_for', name: 'csv')
    .form-group.control-group
      - guessed_encoding = @abstract_model.encoding
      %label.col-sm-2.control-label{for: "csv_options_encoding_to"}= t('admin.export.csv.encoding_to')
      .col-sm-10.controls
        -# from http://books.google.com/support/partner/bin/answer.py?answer=30990 :
        = select_tag 'csv_options[encoding_to]', options_for_select(RailsAdmin::CSVConverter::TARGET_ENCODINGS), include_blank: true
        %p.help-block= t('admin.export.csv.encoding_to_help', name: guessed_encoding)

    .form-group.control-group
      %label.col-sm-2.control-label{for: "csv_options_skip_header"}= t('admin.export.csv.skip_header')
      .col-sm-10.controls
        %label.checkbox
          = check_box_tag 'csv_options[skip_header]', 'true'
        %p.help-block= t('admin.export.csv.skip_header_help')

    .form-group.control-group
      %label.col-sm-2.control-label{for: "csv_options_generator_col_sep"}= t('admin.export.csv.col_sep')
      .col-sm-10.controls
        = select_tag 'csv_options[generator][col_sep]', options_for_select({ '' => t('admin.export.csv.default_col_sep'), "<comma> ','" => ',', "<semicolon> ';'" => ';', '<tabs>' => "'\t'" })
        %p.help-block= t('admin.export.csv.col_sep_help', value: t('admin.export.csv.default_col_sep'))

  .form-group.form-actions
    .col-sm-offset-2.col-sm-10
      %input{type: :hidden, name: 'return_to', value: (params[:return_to].presence || request.referer)}
      %button.btn.btn-primary{type: "submit", name: 'csv'}
        %i.icon-white.icon-ok
        = t("admin.export.confirmation", name: 'csv')
      %button.btn.btn-info{type: "submit", name: 'json'}
        = t("admin.export.confirmation", name: 'json')
      %button.btn.btn-info{type: "submit", name: 'xml'}
        = t("admin.export.confirmation", name: 'xml')
      %button.btn{type: "submit", name: "_continue"}
        %i.icon-remove
        = t("admin.form.cancel")