This commit is contained in:
BoHung Chiu 2022-09-30 18:50:53 +08:00
parent 4ade4273e2
commit 50f9c1b5f4
1 changed files with 7 additions and 6 deletions

View File

@ -348,19 +348,20 @@ module Admin::AsksHelper
if not_editable
hint_text = "<div style=\"font-weight: bold;\">" + t('ask.this_field_is_default_custom_fields') + "</div>"
end
multi_lang_tag = multiple_lang_tag_for_ask(k,'text_field','field',v['field'],{placeholder: t('ask.field_name'), disabled: (not_editable ? 'disabled' : nil)})
tmp_field_select_tag_for_ask = field_select_tag_for_ask(k,'type',markups,v['type'],{:onchange=>'check_available_setting_block(this)', :disabled=>(not_editable ? 'disabled' : nil)})
disabled_attr = (not_editable ? 'disabled' : nil)
multi_lang_tag = multiple_lang_tag_for_ask(k,'text_field','field',v['field'],{placeholder: t('ask.field_name'), disabled: disabled_attr})
tmp_field_select_tag_for_ask = field_select_tag_for_ask(k,'type',markups,v['type'],{:onchange=>'check_available_setting_block(this)', :disabled=>disabled_attr})
key = hidden_field_tag "#{get_input_name_for_ask}[#{k}][key]",k,{'class' => 'key'}
all_new_options = Array(v['options']).collect do |key,value|
tmp = create_delete_button_for_ask('delete_added_select_option').html_safe+hidden_field_tag("#{get_input_name_for_ask}[#{k}][options][#{key}][disabled]",value['disabled'],{'class' => 'disabled_field'})
hidden_style = value['disabled'] == 'true' ? {style: 'display:none;'} : {}
"#{multiple_lang_tag_for_ask(k,'text_field',"options][#{key}",value,{placeholder: t('ask.option_name'), :disabled=>(not_editable ? 'disabled' : nil)},tmp,hidden_style,true)}"
"#{multiple_lang_tag_for_ask(k,'text_field',"options][#{key}",value,{placeholder: t('ask.option_name'), :disabled=>disabled_attr},tmp,hidden_style,true)}"
end.join
active_class = ['select','radio_button','checkbox'].include?(v['type']) ? ' active' : ''
active_prompt_class = ['date','radio_button','checkbox'].exclude?(v['type']) ? ' active' : ''
multi_lang_prompt_tag = "<div class=\"prompt_word#{active_prompt_class}\">#{multiple_lang_tag_for_ask(k,'text_field','prompt_word',v['prompt_word'],{placeholder: t('ask.prompt_word'), disabled: (not_editable ? 'disabled' : nil)})}</div>"
instructions_text_area = "<div class=\"instructions_text_area#{v['type'] == 'instructions' ? '' : ' hide'}\">#{multiple_lang_tag_for_ask(k,'text_area','instructions',v['instructions'],{placeholder: t('ask.prompt_word'), class: 'ckeditor', disabled: 'disabled'})}</div>"
require_ask_tag = "<div>#{t('ask.required')}:&nbsp;&nbsp;#{field_radio_button_tag(k,'required','true',v['required']=='true',{disabled: (not_editable ? 'disabled' : nil)})}#{t('ask.yes')}#{field_radio_button_tag(k,'required','false',v['required']!='true',{disabled: (not_editable ? 'disabled' : nil)})}#{t('ask.no')}</div>"
multi_lang_prompt_tag = "<div class=\"prompt_word#{active_prompt_class}\">#{multiple_lang_tag_for_ask(k,'text_field','prompt_word',v['prompt_word'],{placeholder: t('ask.prompt_word'), disabled: disabled_attr})}</div>"
instructions_text_area = "<div class=\"instructions_text_area#{v['type'] == 'instructions' ? '' : ' hide'}\">#{multiple_lang_tag_for_ask(k,'text_area','instructions',v['instructions'],{placeholder: t('ask.prompt_word'), class: 'ckeditor', disabled: disabled_attr})}</div>"
require_ask_tag = "<div>#{t('ask.required')}:&nbsp;&nbsp;#{field_radio_button_tag(k,'required','true',v['required']=='true',{disabled: disabled_attr})}#{t('ask.yes')}#{field_radio_button_tag(k,'required','false',v['required']!='true',{disabled: disabled_attr})}#{t('ask.no')}</div>"
tmp = "<div class=\"add_new_options#{active_class}\">#{all_new_options}<input class=\"btn btn-info\" type=\"button\" value=\"#{t('ask.add_new_options')}\" onclick=\"add_new_options_for_field(this,#{k})\"></div>"
field_html = "<tr class=\"custom_field #{extra_class}\" data-key=\"#{k}\">
<td>