From 8887ae8e783d89d0ab1b8b0c8112ab3523101d5c Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Fri, 11 Dec 2015 11:36:22 +0100 Subject: [PATCH] Improve export layout --- app/views/rails_admin/main/export.html.haml | 81 ++++++++++++--------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/app/views/rails_admin/main/export.html.haml b/app/views/rails_admin/main/export.html.haml index 606e07c067..246aea3ca0 100644 --- a/app/views/rails_admin/main/export.html.haml +++ b/app/views/rails_admin/main/export.html.haml @@ -1,47 +1,55 @@ - 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 += form_tag export_path(params.merge(all: true)), method: 'post', class: 'form-horizontal' 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) + .form-group.control-group + .col-sm-12 + .checkbox + %label{for: 'check_all'} + = check_box_tag 'all', 'all', true, { id: 'check_all' } + %b= t('admin.export.select_all_fields') + .form-group.control-group + .col-sm-12 + .well.well-sm{rel: 'tooltip', :'data-original-title' => t('admin.export.click_to_reverse_selection'), onclick: 'jQuery(this).closest(".control-group").find(".controls").find("input").click()', style: 'margin: 0; cursor: pointer;'} + %b= t('admin.export.fields_from', name: @model_config.label_plural.downcase) + .controls + .row + - visible_fields.select{ |f| !f.association? || f.association.polymorphic? }.each do |field| + - list = field.virtual? ? 'methods' : 'only' + .checkbox.col-sm-3 + - if field.association? && field.association.polymorphic? + %label{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{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{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) + .form-group.control-group + .col-sm-12 + .well.well-sm{rel: 'tooltip', :'data-original-title' => t('admin.export.click_to_reverse_selection'), onclick: 'jQuery(this).closest(".control-group").find(".controls").find("input").click()', style: 'margin: 0; cursor: pointer;'} + %b= t('admin.export.fields_from_associated', name: field.label.downcase) + .controls + .row + - fields.each do |associated_model_field| + - list = associated_model_field.virtual? ? 'methods' : 'only' + .checkbox.col-sm-3 + %label{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 @@ -52,20 +60,21 @@ %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 + = select_tag 'csv_options[encoding_to]', options_for_select(RailsAdmin::CSVConverter::TARGET_ENCODINGS), include_blank: true, placeholder: t('admin.misc.search'), :'data-enumeration' => 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' + .checkbox + %label{style: 'display: block;' } + = 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'), " ','" => ',', " ';'" => ';', '' => "'\t'" }) + = select_tag 'csv_options[generator][col_sep]', options_for_select({ '' => t('admin.export.csv.default_col_sep'), " ','" => ',', " ';'" => ';', '' => "'\t'" }), placeholder: t('admin.misc.search'), :'data-enumeration' => true %p.help-block= t('admin.export.csv.col_sep_help', value: t('admin.export.csv.default_col_sep')) .form-group.form-actions