add setting for title layout
This commit is contained in:
parent
9982b60805
commit
52358bb533
|
@ -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']
|
||||
"<div class=\"control-group\" style=\"#{style_html}\">
|
||||
"<div class=\"control-group#{col_class}\" style=\"#{style_html}\">
|
||||
#{label}
|
||||
<div class=\"controls\">
|
||||
#{content}
|
||||
</div>
|
||||
</div>"
|
||||
end.join
|
||||
"<form id=\"#{form_id}\" action=\"#{form_url}\" enctype=\"multipart/form-data\" method=\"post\" class=\"form-horizontal ask-question-form\" accept-charset=\"UTF-8\" style=\"#{is_hidden ? 'display: none;' : ''}\">
|
||||
"<form id=\"#{form_id}\" action=\"#{form_url}\" enctype=\"multipart/form-data\" method=\"post\" class=\"form-horizontal ask-question-form#{multi_col_class}\" accept-charset=\"UTF-8\" style=\"#{is_hidden ? 'display: none;' : ''}\">
|
||||
#{token_tag}
|
||||
<div data-level=\"0\" data-list=\"fields\">
|
||||
#{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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -113,6 +113,14 @@
|
|||
set_input_name("#{form_type}")
|
||||
%>
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<label for="ask_title_layout"><%= t("ask.title_layout") %>:</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<%= f.select :title_layout, ['single_column','two_column'].each_with_index.map{|v,i| [t("ask.#{v}"), i]} %>
|
||||
</div>
|
||||
</div>
|
||||
<% if @has_email_regex %>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
|
|
|
@ -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 %>
|
||||
<button type="button" class="btn btn-danger" onclick="window.location='<%= "/#{I18n.locale}/admin/asks/category_setting_delete?id=#{ask_setting.id}" %>'"><%= t('delete_') %></button>
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
</script>
|
||||
<% 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| %>
|
||||
<div style="padding-bottom: 2em;border-bottom: 0.1em solid #002bff;">
|
||||
<% 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 @@
|
|||
|
||||
<div class="fade-in" id="print">
|
||||
<% if @category_print_not_add.length != 0 %>
|
||||
<form action="/<%= I18n.locale %>/admin/asks/category_print_setting_save" class='category-set-page' method="post">
|
||||
<form action="/<%= I18n.locale %>/admin/asks/category_print_setting_save" class='form-horizontal category-set-page' method="post">
|
||||
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
|
||||
<div style="padding-bottom: 2em;border-bottom: 0.1em solid #002bff;">
|
||||
<% 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 %>
|
||||
<form action="<%= "/#{I18n.locale}/admin/asks/category_print_setting_save" %>" method="post" id='<%= category_print_added.id.to_s %>' class="fade-in <%= 'active' if index2==1 %>">
|
||||
<form action="<%= "/#{I18n.locale}/admin/asks/category_print_setting_save" %>" 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} %>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue