ask/app/views/admin/asks/_ask_setting.html.erb

144 lines
4.3 KiB
Plaintext

<style type="text/css">
thead td {
text-align: center;
color: blueviolet;
}
.add_new_options,.prompt_word,.time_setting_block{
display: none;
}
.add_new_options.active,.prompt_word.active,.time_setting_block.active{
display: block;
}
tr td {
text-align: center;
}
tr.custom_field td:nth-child(1){
text-align: left;
}
td{
padding: 0.5em;
}
.tab-content{
display: none;
}
.tab-content.active{
display: block;
}
.tab-panel{
display: flex;
flex-wrap: wrap;
}
tr.custom_field {
border: 0.1em solid #8e00ff;
}
tr.custom_field > td >div {
padding: 0.5em 0;
}
input[type=text] {
height: 30px;
}
</style>
<script type="text/javascript">
<%
option_multi_lang_tag = multiple_lang_tag(-1,'text_field','options][-2',nil,{placeholder: t('ask.option_name')},create_delete_button('delete_added_select_option').html_safe+hidden_field_tag("#{get_input_name}[-1][options][-2][disabled]",nil,{'class' => 'disabled_field'}),{},true)
%>
function check_available_setting_block(ele){
var tmp = $(ele).val()
var parent_div = $(ele).parents('.custom_field').eq(0)
if (tmp != 'date' && tmp != 'radio_button' && tmp!='checkbox'){
parent_div.find('.prompt_word').addClass('active')
}else{
parent_div.find('.prompt_word').removeClass('active')
}
if (tmp == 'select' || tmp == 'radio_button' || tmp=='checkbox'){
parent_div.find('.add_new_options').addClass('active')
}else{
parent_div.find('.add_new_options').removeClass('active')
}
if (tmp == 'date'){
parent_div.find('.time_setting_block').addClass('active')
}else{
parent_div.find('.time_setting_block').removeClass('active')
}
}
function delete_field_func(ele){
$(ele).parents('tr').remove()
var all_delete_field = $('.delete_field').val()
all_delete_field = all_delete_field + ',' + $(ele).parents('tr').find('.key').val()
$('.delete_field').val(all_delete_field)
}
function add_new_options_for_field(ele,key){
var add_html = "<%= option_multi_lang_tag.inspect %>"
add_html = add_html.replace(/-1/g,key)
var parent_div = $(ele).parents('.add_new_options')
var tab_panel = parent_div.eq(0).find('.tab-panel')
var tab_panel_length = tab_panel.length
add_html = add_html.replace(/icons-list-2/g,'icons-list-3')
add_html = add_html.replace(/-2/g,tab_panel_length)
add_html = add_html.replace(/icons-list-3/g,'icons-list-2')
parent_div.find('input[type="button"]').eq(-1).before($('<div/>').html(add_html).text().slice(1,-2))
}
function delete_added_select_option(ele){
var parent_div = $(ele).parents('.tab-panel')
parent_div.find('.disabled_field').val('true')
parent_div.hide()
}
</script>
<style type="text/css">
.border {
padding: 0.5em 0;
border-top: 0.1em solid #099700;
}
</style>
<fieldset>
<table>
<thead>
<tr>
<td>
<%= t('ask.field') %>
</td>
<td>
<%= t('ask.whether_open') %>
</td>
</tr>
</thead>
<tbody>
<% ask_setting.default_setting.each do |k,v| %>
<tr>
<td>
<%= ['agree_show','agree_usage'].include?(k.to_s) ? t("ask.#{k}_checkbox") : t("mongoid.attributes.ask_question.#{k}") %>
</td>
<td>
<%= f.select "default_setting[#{k}]",[[t('yes'),'true'],[t('no'),false]] ,selected: v %>
</td>
</tr>
<% end %>
<tr>
<td>
<%= t("ask.usage_rule") %>
</td>
<td>
<%= f.text_area "usage_rule",class: 'ckeditor' %>
</td>
</tr>
<% ask_setting.custom_fields.each do |k,v| %>
<%= custom_field_block(k,v).html_safe %>
<% end %>
<tr class="add_field">
<td colspan="2" style="text-align: center;">
<input class="btn btn-info" type="button" value="<%= t('add')%>" onclick="add_new_field(this)">
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<%= hidden_field_tag :delete_field, nil,{'class'=> 'delete_field' } %>
<% if !ask_setting.new_record? %>
<%= f.hidden_field :id, value: ask_setting.id %>
<% end %>
<input class="btn btn-primary" type="submit" value="<%= submit_text %>">
</td>
</tr>
</tbody>
</table>
</fieldset>