133 lines
6.3 KiB
Plaintext
133 lines
6.3 KiB
Plaintext
<% content_for :page_specific_css do %>
|
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
|
<%= stylesheet_link_tag "lib/wrap-nav" %>
|
|
<%= stylesheet_link_tag "lib/main-list" %>
|
|
<% end %>
|
|
<% content_for :page_specific_javascript do %>
|
|
<%= javascript_include_tag "jquery-ui-custom.js" %>
|
|
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
|
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
|
<%= javascript_include_tag "lib/member/textarea-lang-btn.js" %>
|
|
<%= javascript_include_tag "lib/jquery.tmpl.min.js" %>
|
|
<%= javascript_include_tag "survey.js" %>
|
|
<% end %>
|
|
|
|
<%= form_for @survey, url: admin_survey_path(@survey), html: {class: "form-horizontal main-forms"} do |f| %>
|
|
|
|
<fieldset>
|
|
|
|
<div class="input-area">
|
|
<div class="attributes">
|
|
<div class="attributes-header clearfix">
|
|
<h4><%= @survey.title %> <%= t('survey.set_answers') %></h4>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Result Type -->
|
|
<div class="control-group" data-type="0">
|
|
<label class="control-label muted" for="account"><%= t('survey.result_type') %></label>
|
|
<div class="controls">
|
|
<%= f.select :result_type, {
|
|
t('survey.chart') => QuestionnaireSurvey::ResultChart,
|
|
t('survey.extern_link') => QuestionnaireSurvey::ResultExtern,
|
|
t('survey.upload_file') => QuestionnaireSurvey::ResultFile,
|
|
t('survey.criteria') => QuestionnaireSurvey::ResultCriteria
|
|
}, {}, :class => "tinput-medium", :onchange=>"OnSelectionChange (this)" %>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Extern Link -->
|
|
<div class="control-group selectable <%= (@survey.result_type == 1) ? '' : 'hide' %>" data-type="1">
|
|
<label class="control-label muted" for="account"><%= t('survey.extern_link') %></label>
|
|
<div class="controls">
|
|
<%= f.text_field :extern_link, :style=>"width:80%;", :class=>'post-extern_link' %>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Upload_file -->
|
|
<div class="control-group selectable <%= (@survey.result_type == 2) ? '' : 'hide' %>" data-type="2">
|
|
<label class="control-label muted" for="account"><%= t('survey.upload_file') %></label>
|
|
<div class="controls">
|
|
<%= f.file_field :upload_file %>
|
|
<% if @survey.upload_file? %>
|
|
<div class="controls" data-toggle="buttons-checkbox">
|
|
<%= link_to t(:view), @survey.upload_file.url, {:class => 'for_preview btn', :target => '_blank', :title => t(:view), "data-trigger" => :hover} %>
|
|
<label class="checkbox inline btn btn-danger fileupload-remove">
|
|
<%= f.check_box :remove_upload_file %><%= t('survey.remove_upload_file') %>
|
|
</label>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<!-- points criteria -->
|
|
<div class="control-group selectable <%= (@survey.result_type == 3) ? '' : 'hide' %>" data-type="3">
|
|
<label class="control-label muted" for="account"><%= t('survey.criteria') %></label>
|
|
<div class="controls">
|
|
<button class="btn btn-small btn-primary" id="add-criteria">Add</button>
|
|
</div>
|
|
<div id="criterias" class="controls" style="width:850px;">
|
|
<% if @survey.result_criteria.blank? %>
|
|
<div class="criteria-span" style="margin-left:0px;display:block;">
|
|
<label style="padding-left:0px;" for="" class="radio inline"> From : <input name="questionnaire_survey[result_criteria][0][]" class="span1" max="<%= @survey.total_points %>" type="number"></label>
|
|
<label for="" class="radio inline"> To : <input name="questionnaire_survey[result_criteria][0][]" class="span1" max="<%= @survey.total_points %>" type="number"></label>
|
|
<label for="" class="radio inline">Save to add text</label>
|
|
</div>
|
|
<% else %>
|
|
<% @survey.result_criteria.each_with_index do |criteria, idx| %>
|
|
<div class="criteria-span" style="margin-left:0px;display:block;margin-bottom:50px;">
|
|
<label style="padding-left:0px;" for="" class="radio inline"> From : <input name="questionnaire_survey[result_criteria][<%= idx %>][]" class="span1" max="<%= @survey.total_points %>" type="number" value="<%= criteria[0] %>"></label>
|
|
<label for="" class="radio inline"> To : <input name="questionnaire_survey[result_criteria][<%= idx %>][]" class="span1" max="<%= @survey.total_points %>" type="number" value="<%= criteria[1] %>"></label>
|
|
<% if idx != 0 %>
|
|
<a href="" style="margin-left:5px;" class="btn btn-danger delete-critera"><i class="icon icon-trash"></i></a>
|
|
<% end %>
|
|
<label for="" class="radio inline">
|
|
<textarea class="ckeditor" name="questionnaire_survey[result_criteria][<%= idx %>][]"><%= criteria[2] %></textarea>
|
|
</label>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-actions">
|
|
<%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %>
|
|
<%= hidden_field_tag 'et', "result" %>
|
|
<%= f.submit t('save'), :class=>'btn btn-primary' %>
|
|
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
<% end %>
|
|
|
|
<script type="text/javascript">
|
|
function OnSelectionChange (select) {
|
|
var selectedOption = select.options[select.selectedIndex];
|
|
$(".selectable").addClass("hide");
|
|
$(".selectable[data-type=" + selectedOption.value + "]").removeClass("hide");
|
|
}
|
|
var index = <%= @survey.result_criteria.count == 0 ? 1 : @survey.result_criteria.count + 1 %>,
|
|
html = '<div data-critera-number="criteria_{index}" class="criteria-span" style="width:800px;"><label style="padding-left:0px;" for="" class="radio inline"> From : <input name="questionnaire_survey[result_criteria][{index}][]" class="span1" max="<%= @survey.total_points %>" type="number"></label><label for="" class="radio inline"> To : <input name="questionnaire_survey[result_criteria][{index}][]" class="span1" max="<%= @survey.total_points %>" type="number"></label><a href="" style="margin-left:5px;" class="btn btn-primary delete-critera"><i class="icon icon-trash"></i></a><span class="radio inline">Save to add text</span></div>';
|
|
|
|
$("#add-criteria").on("click",function(){
|
|
var newhtml = html.replace(/{index}/g,index);
|
|
console.log(newhtml);
|
|
index++;
|
|
$("#criterias").append(newhtml);
|
|
return false;
|
|
})
|
|
|
|
$(document).on("click", ".delete-critera" ,function(){
|
|
$(this).parent().remove();
|
|
return false;
|
|
})
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|