diff --git a/app/controllers/asks_controller.rb b/app/controllers/asks_controller.rb index 7d5239b..ea61e7f 100644 --- a/app/controllers/asks_controller.rb +++ b/app/controllers/asks_controller.rb @@ -340,22 +340,24 @@ class AsksController < ApplicationController end defalt_fields end - def cal_html(fields,token_tag,form_id,referer_url,is_hidden=true) + def cal_html(fields,token_tag,form_id,referer_url,is_hidden=true,ask_setting=None) form_url = "/#{I18n.locale.to_s}/asks" submit_tag = submit_tag(t('submit'), :class=> 'btn btn-primary', :id => 'button-mail') close_tag = button_tag(t('cancel'), type: 'reset', :class=> 'btn') + multi_col_class = (ask_setting.title_layout>0 rescue false) ? ' multi-col' : ' single-col' + col_class = (ask_setting.title_layout==1 rescue false) ? ' col-sm-6' : '' tmp = fields.collect do |field| style_html = field['style_html'] label = field['label'] content = field['content'] - "
+ "
#{label}
#{content}
" end.join - "
+ " #{token_tag}
#{tmp} @@ -420,7 +422,7 @@ class AsksController < ApplicationController else form_id = ask_setting.category_id end - cal_html(fields,token_tag,form_id,referer_url,is_hidden) + cal_html(fields,token_tag,form_id,referer_url,is_hidden,ask_setting) end.join switch_form end diff --git a/app/models/ask_category_setting.rb b/app/models/ask_category_setting.rb index b937bfe..6ac6fd5 100644 --- a/app/models/ask_category_setting.rb +++ b/app/models/ask_category_setting.rb @@ -40,5 +40,5 @@ class AskCategorySetting field :custom_fields, type: Hash,default: {} field :usage_rule field :category_id - field :title_layout + field :title_layout, type: Integer end diff --git a/app/models/ask_setting.rb b/app/models/ask_setting.rb index d574123..3747fd3 100644 --- a/app/models/ask_setting.rb +++ b/app/models/ask_setting.rb @@ -43,7 +43,7 @@ class AskSetting field :custom_fields, type: Hash,default: {} field :usage_rule - field :title_layout + field :title_layout, type: Integer def get_attrs attrs = self.attributes.clone self.fields.each do |k, v| diff --git a/app/views/admin/asks/_ask_setting.html.erb b/app/views/admin/asks/_ask_setting.html.erb index 0a14533..4f510c5 100644 --- a/app/views/admin/asks/_ask_setting.html.erb +++ b/app/views/admin/asks/_ask_setting.html.erb @@ -113,6 +113,14 @@ set_input_name("#{form_type}") %>
+
+
+ +
+
+ <%= f.select :title_layout, ['single_column','two_column'].each_with_index.map{|v,i| [t("ask.#{v}"), i]} %> +
+
<% if @has_email_regex %>
diff --git a/app/views/admin/asks/_category_setting_field.html.erb b/app/views/admin/asks/_category_setting_field.html.erb index 5b5b891..de8191a 100644 --- a/app/views/admin/asks/_category_setting_field.html.erb +++ b/app/views/admin/asks/_category_setting_field.html.erb @@ -1,7 +1,7 @@ <% set_input_name('ask_category_setting[custom_fields]') %> -<%= form_for ask_setting,method: 'post',url: "/#{I18n.locale}/admin/asks/category_setting_save",html: { class: "fade-in active detail", 'id' => ask_setting.id.to_s ,:id => ask_setting.id} do |f| %> +<%= form_for ask_setting,method: 'post',url: "/#{I18n.locale}/admin/asks/category_setting_save",html: { class: "form-horizontal fade-in active detail", 'id' => ask_setting.id.to_s ,:id => ask_setting.id} do |f| %> <%= render partial: 'ask_setting',locals:{ask_setting: ask_setting,f: f,submit_text: t('ask.modify')} %> <%= hidden_field_tag "category_id",ask_setting.category_id %> diff --git a/app/views/admin/asks/category_setting.html.erb b/app/views/admin/asks/category_setting.html.erb index 5367217..e1d3559 100644 --- a/app/views/admin/asks/category_setting.html.erb +++ b/app/views/admin/asks/category_setting.html.erb @@ -99,7 +99,7 @@ <% if @category_not_add.length != 0 %> <% ask_setting = AskCategorySetting.new %> - <%= form_for ask_setting,method: 'post',url: "/#{I18n.locale}/admin/asks/category_setting_save",html: { class: "category-set-page"} do |f| %> + <%= form_for ask_setting,method: 'post',url: "/#{I18n.locale}/admin/asks/category_setting_save",html: { class: "form-horizontal category-set-page"} do |f| %>
<% prompt = t('ask.select_category') %> <%= t('category') %>: <%= select_tag "category_id", options_for_select(@category_not_add.unshift(prompt),selected: prompt,disabled: prompt), :class => "category-selector" %> @@ -131,7 +131,7 @@
<% if @category_print_not_add.length != 0 %> - + <%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<% prompt = t('ask.select_category') %> @@ -161,7 +161,7 @@ <% @category_print_added.each_with_index do |category_print_added,index1| %> <% if !categories[index1].nil? %> <% index2 = index2 + 1 %> - " method="post" id='<%= category_print_added.id.to_s %>' class="fade-in <%= 'active' if index2==1 %>"> + " method="post" id='<%= category_print_added.id.to_s %>' class="form-horizontal fade-in <%= 'active' if index2==1 %>"> <%= hidden_field_tag :category_id, category_print_added.category_id %> <%= hidden_field_tag :authenticity_token, form_authenticity_token %> <%= render partial: 'category_print_setting',locals:{print_setting: category_print_added} %> diff --git a/app/views/asks/index.html.erb b/app/views/asks/index.html.erb index 8f6b750..7a310e3 100644 --- a/app/views/asks/index.html.erb +++ b/app/views/asks/index.html.erb @@ -22,7 +22,6 @@ .ask-question .control-group{ flex-wrap: wrap; display: flex; - width: 100%; align-items: center; } .ask-question .controls > *{ @@ -40,21 +39,34 @@ } .ask-question .form-horizontal .control-group .controls{ margin: 0; - display: inline-flex; - flex-wrap: wrap; - align-items: center; overflow: hidden; position: relative; min-width: 10em; max-width: 25em; padding-left: 0; - width: 100%; padding: 0.5em; + } + .ask-question .single-col.form-horizontal .control-group{ + width: 100%; + } + .ask-question .single-col.form-horizontal .control-group .controls{ + width: 100%; + display: inline-flex; + flex-wrap: wrap; + align-items: center; justify-content: center; } + .ask-question .ask-question-form.multi-col.form-horizontal div[data-list="fields"]{ + float: left; + } + .ask-question .ask-question-form.multi-col.form-horizontal .form-actions{ + float: left; + width: 100%; + } .ask-question .form-horizontal input[type="text"],.ask-question .form-horizontal select{ width: 97%; } + .ask-question .form-horizontal .form-actions{ position: relative; padding: 1em 0 0 0;