survey/app/views/admin/surveys/_questions.html.erb

258 lines
14 KiB
Plaintext

<script id="template-survery" type="text/x-tmpl">
<div class="attributes" data-index="${_l}" data-question="${_ques}">
<div class="attributes-header clearfix">
<a class="btn btn-mini pull-right btn-danger delete" href="#"><i class="icon-trash"></i> <%= t('survey_question.delete') %></a>
<input class="should_destroy" id="${_destroy[0]}" name="${_destroy[1]}" type="hidden">
<input id="${_sequence[0]}" class="sequence" name="${_sequence[1]}" type="hidden" value="${_sequence[2]}">
{{if _id}}
<input id="${_id[0]}" name="${_id[1]}" type="hidden" value="${_id[2]}">
{{/if}}
<h4><b></b> Q<span>${_length}</span> <i class="icon-caret-up"></i> <span class="questions-title">${_title_translations[3].<%= @primary_locale %>}</span></h4>
</div>
<div class="attributes-body">
<div class="control-group">
<label class="control-label muted" for=""><%= t('survey_question.title') %></label>
<div class="controls">
<div class="input-append">
<div class="tab-content">
<div class="tab-pane fade active in" id="${_title_translations[2]+'_<%= @primary_locale %>'}">
<input class="span4 q-title" id="${_title_translations[0]+'_<%= @primary_locale %>'}" name="${_title_translations[1]+'[<%= @primary_locale %>]'}" type="text" value="${_title_translations[3].<%= @primary_locale %>}" />
</div>
<div class="tab-pane fade" id="${_title_translations[2]+'_<%= @secondary_locale %>'}">
<input class="span4 q-title" id="${_title_translations[0]+'_<%= @secondary_locale %>'}" name="${_title_translations[1]+'[<%= @secondary_locale %>]'}" type="text" value="${_title_translations[3].<%= @secondary_locale %>}" />
</div>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn change-title <%= ( i == 0 ) ? "active" : '' %>" href="${'#'+_title_translations[2]+'_<%= locale %>'}" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('survey_question.description') %></label>
<div class="controls">
<div class="tab-content textarea-lang">
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn change-title <%= ( i == 0 ) ? "active" : '' %>" href="${'#'+_description_translations[2]+'_<%= locale %>'}" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
<div class="tab-pane fade active in" id="${_description_translations[2]+'_<%= @primary_locale %>'}">
<textarea class="resizable" id="${_description_translations[0]+'_<%= @primary_locale %>'}" name="${_description_translations[1]+'[<%= @primary_locale %>]'}" rows="3">${_description_translations[3].<%= @primary_locale %>}</textarea>
</div>
<div class="tab-pane fade" id="${_description_translations[2]+'_<%= @secondary_locale %>'}">
<textarea class="resizable" id="${_description_translations[0]+'_<%= @secondary_locale %>'}" name="${_description_translations[1]+'[<%= @secondary_locale %>]'}" rows="3">${_description_translations[3].<%= @secondary_locale %>}</textarea>
</div>
</div>
</div>
</div>
<div class="control-group weight_block" {{if _type[2] != 0 && _type[2] != 1 && _type[2] != 6 }}class="hide"{{/if}}>
<label class="control-label muted" for=""><%= t('survey.weight') %> </label>
<div class="controls">
<input type="number" name="${_weight[1]}" value="${_weight[2]}" min="1">
</div>
</div>
<div class="control-group">
<label class="control-label muted" for=""><%= t('survey_question.type') %> </label>
<div class="controls">
<select class="type-selector" name="${_type[1]}">
<option value="0" {{if _type[2] == 0}}selected="selected"{{/if}}><%= t('survey_question.oneline') %></option>
<option value="1" {{if _type[2] == 1}}selected="selected"{{/if}}><%= t('survey_question.multiline') %></option>
<option value="2" {{if _type[2] == 2}}selected="selected"{{/if}}><%= t('survey_question.radio') %></option>
<option value="3" {{if _type[2] == 3}}selected="selected"{{/if}}><%= t('survey_question.check') %></option>
<option value="4" {{if _type[2] == 4}}selected="selected"{{/if}}><%= t('survey_question.select') %></option>
<option value="5" {{if _type[2] == 5}}selected="selected"{{/if}}><%= t('survey_question.radiogroup') %></option>
<option value="6" {{if _type[2] == 6}}selected="selected"{{/if}}><%= t('survey_question.datetime') %></option>
<option value="7" {{if _type[2] == 7}}selected="selected"{{/if}}><%= t('survey_question.double_level_options') %></option>
</select>
<%= render :partial => 'selectable_question' %>
</div>
</div>
<div class="field-type" style="display: none">
<div class="control-group rgl">
<label for="" class="control-label muted"><%= t('survey_question.radiogroup_label') %></label>
<div class="controls add-input">
<div class="add-target">
<p class="add-btn">
<a href="#" class="btn btn-mini btn-primary"><i class="icons-plus"></i> <%= t('survey_question.add') %></a>
</p>
</div>
</div>
</div>
<hr />
<div class="control-group options">
<label for="" class="control-label muted"><%= t('survey_question.options_lists') %></label>
<div class="controls add-input">
<div class="add-target">
<p class="add-btn">
<a href="#" class="btn btn-mini btn-primary"><i class="icons-plus"></i> <%= t('survey_question.add') %></a>
</p>
</div>
</div>
</div>
<div class="control-group allow">
<div class="controls">
<label class="checkbox">
<input name="${_custom_option[1]}" type="hidden" value="${_custom_option[2] << 0}" />
<input id="${_custom_option[0]}" type="checkbox" {{if _custom_option[2]}} checked="checked" {{/if}} data-div="custom_option_div" />
<%= t('survey_question.custom_option') %>
</label>
<div class="custom_option_div">
<% SurveysHelper::CustomOptionTypeMap.each_with_index do |key,i| %>
<label for="${_custom_option_type[2]}_<%= i %>" class="checkbox">
<input type="checkbox" id="${_custom_option_type[2]}_<%= i %>" name="${_custom_option_type[0]}" value="<%= i %>"
{{if _custom_option_type[1].includes(<%= i %>) || (_custom_option_type[1]==='' && <%= i %>===1 )}}checked{{/if}}>
<%= t("custom_option_type.#{key}") %></label>
<% end %>
</div>
</div>
</div>
<div class="input-append custom_option_div hide" for="1" data-parent=".field-type" data-trigger="input[name='${_custom_option_type[0]}']">
<div class="control-group">
<label class="control-label muted"><%= t('survey_question.option_title') %></label>
<div class="controls">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade<%= ( i == 0 ) ? " active in" : '' %>" id="${_custom_option_title_translations[2]+'_<%= locale %>'}">
<input class="span4 q-title" id="${_custom_option_title_translations[0]+'_<%= locale %>'}" name="${_custom_option_title_translations[1]+'[<%= locale %>]'}" type="text" value="${_custom_option_title_translations[3].<%= locale %>}"
placeholder="<%= I18n.with_locale(locale){t('survey_question.option_title_default')} %>" />
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn change-title <%= ( i == 0 ) ? "active" : '' %>" href="${'#'+_custom_option_title_translations[2]+'_<%= locale %>'}" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
</div>
</div>
</div>
</div>
<div class="control-group date-format" style="display:none;">
<label class="control-label muted" for=""><%= t('survey_question.datetimeformat') %> </label>
<div class="controls">
<select id="${_dateformat[0]}" name="${_dateformat[1]}">
<option value="yyyy/MM/dd hh:mm" {{if _dateformat[2] == 'yyyy/MM/dd hh:mm'}}selected="selected"{{/if}}>YYYY/MM/DD HH:MM</option>
<option value="yyyy/MM/dd" {{if _dateformat[2] == 'yyyy/MM/dd'}}selected="selected"{{/if}}>YYYY/MM/DD</option>
<option value="yyyy/MM" {{if _dateformat[2] == 'yyyy/MM'}}selected="selected"{{/if}}>YYYY/MM</option>
<option value="yyyy" {{if _dateformat[2] == 'yyyy'}}selected="selected"{{/if}}>YYYY</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label muted" for="redirectMode"></label>
<div class="controls">
<label class="checkbox">
<input name="${_is_required[1]}" type="hidden" value="${_is_required[2] << 0}" />
<input id="${_is_required[0]}" type="checkbox" {{if _is_required[2]}} checked="checked" {{/if}} />
<%= t('survey_question.is_required') %>
</label>
</div>
</div>
</div>
</div>
</script>
<script id="template-survery-option" type="text/x-tmpl">
{{if _className == 'rgl'}}
<div class="input-append" data-question-option="${_ques}">
{{if _radiogroups_id}}
<input type="hidden" value="${_radiogroups_id[1]}" name="${_radiogroups_id[0]}" />
<input type="hidden" class="should_destroy_option" name="${_destroy[0]}" />
{{/if}}
<div class="tab-content">
<div class="tab-pane fade active in" id="${_radiogroups[2]+'<%= @primary_locale %>'}">
<input type="text" class="span4" id="${_radiogroups[0]+'<%= @primary_locale %>'}" name="${_radiogroups[1]+'[<%= @primary_locale %>]'}" value="${_radiogroups[3].<%= @primary_locale %>}" />
</div>
<div class="tab-pane fade" id="${_radiogroups[2]+'<%= @secondary_locale %>'}">
<input type="text" class="span4" id="${_radiogroups[0]+'<%= @secondary_locale %>'}" name="${_radiogroups[1]+'[<%= @secondary_locale %>]'}" value="${_radiogroups[3].<%= @secondary_locale %>}" />
</div>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn change-title <%= ( i == 0 ) ? "active" : '' %>" href="${'#'+_radiogroups[2]+'_<%= locale %>'}" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
<a href="#" class="btn remove-input">
<i class="icon-trash"></i>
</a>
</div>
</div>
{{else}}
<div class="input-append" data-question-option="${_ques}">
{{if _options_id}}
<input type="hidden" value="${_options_id[1]}" name="${_options_id[0]}" />
<input type="hidden" class="should_destroy_option" name="${_destroy[0]}" />
{{/if}}
<div class="tab-content">
<div class="tab-pane fade active in" id="${_option[2]+'<%= @primary_locale %>'}">
<input type="text" class="span4" id="${_option[0]+'<%= @primary_locale %>'}" name="${_option[1]+'[<%= @primary_locale %>]'}" value="${_option[3].<%= @primary_locale %>}" />
</div>
<div class="tab-pane fade" id="${_option[2]+'<%= @secondary_locale %>'}">
<input type="text" class="span4" id="${_option[0]+'<%= @secondary_locale %>'}" name="${_option[1]+'[<%= @secondary_locale %>]'}" value="${_option[3].<%= @secondary_locale %>}" />
</div>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn change-title <%= ( i == 0 ) ? "active" : '' %>" href="${'#'+_option[2]+'<%= locale %>'}" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
<a href="#" class="btn remove-input">
<i class="icon-trash"></i>
</a>
</div>
<div style="margin-left:10px; display:inline;">
<input type="number" name="${_points[1]}" id="${_points[0]}" class="span1" value="${_points[3]}" />
<label for="${_points[0]}" class="radio inline" style="padding-left: 5px;">Points</label>
</div>
</div>
{{/if}}
</script>
<script id="template-survery-option-leve11-wrapper" type="text/x-tmpl">
<div class="level1">
<div class="level1_wrapper">
<div class="question_type_wrapper">
<% SurveysHelper::QuestionTypeOptionMap.each_with_index do |key,i| %>
<label class="radio">
<input type="radio" name="${_question_type[0]}" value="<%= i %>"
{{if _question_type[1]===<%= i %> || (_question_type[1]==='' && <%= i %>===0)}}checked{{/if}}>
<%= t("survey_question_type.#{key}") %></label>
<% end %>
</div>
</div>
</div>
</script>
<script id="template-survery-option-level2-wrapper" type="text/x-tmpl">
<div class="level2">
<div class="control-group options">
<label class="control-label muted"><%= t('survey_question.level_2_options') %></label>
<div class="controls add-input">
<div class="add-target">
<p class="add-btn level2">
<a href="#" class="btn btn-mini btn-primary"><i class="icons-plus"></i> <%= t('survey_question.add') %></a>
</p>
</div>
</div>
</div>
</div>
</script>