survey module: ensure the commit
This commit is contained in:
parent
e48a1ffece
commit
96fc5ceea3
|
@ -16,6 +16,8 @@ class SurveyQuestion
|
||||||
|
|
||||||
# allow custom answer option
|
# allow custom answer option
|
||||||
field :custom_option, :type => Boolean
|
field :custom_option, :type => Boolean
|
||||||
|
|
||||||
|
field :sequence, :type => Integer, :default => 0
|
||||||
|
|
||||||
belongs_to :survey
|
belongs_to :survey
|
||||||
embeds_many :survey_question_options
|
embeds_many :survey_question_options
|
||||||
|
@ -24,6 +26,8 @@ class SurveyQuestion
|
||||||
accepts_nested_attributes_for :survey_question_options, :allow_destroy => true
|
accepts_nested_attributes_for :survey_question_options, :allow_destroy => true
|
||||||
accepts_nested_attributes_for :survey_question_radiogroups, :allow_destroy => true
|
accepts_nested_attributes_for :survey_question_radiogroups, :allow_destroy => true
|
||||||
|
|
||||||
|
default_scope asc(:sequence)
|
||||||
|
|
||||||
def jumpable?
|
def jumpable?
|
||||||
case type
|
case type
|
||||||
when SurveyQuestion::Radio, SurveyQuestion::Select
|
when SurveyQuestion::Radio, SurveyQuestion::Select
|
||||||
|
|
|
@ -103,7 +103,31 @@
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
<%= javascript_include_tag "survey_form" %>
|
<%= javascript_include_tag "survey_form" %>
|
||||||
<script>
|
<script>
|
||||||
|
var refresh_sequence_input = function() {
|
||||||
|
var sequence = 0;
|
||||||
|
$('.sequence input').each(function(){
|
||||||
|
sequence += 1;
|
||||||
|
$(this).val(sequence);
|
||||||
|
});
|
||||||
|
}
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$('.sequence .move-up').bind('click', function(){
|
||||||
|
$survey_question_item = $(this).parents('.survey_question_item')
|
||||||
|
$prev = $survey_question_item.prev();
|
||||||
|
$survey_question_item.insertBefore($prev);
|
||||||
|
refresh_sequence_input();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.sequence .move-down').bind('click', function(){
|
||||||
|
$survey_question_item = $(this).parents('.survey_question_item')
|
||||||
|
$next = $survey_question_item.next();
|
||||||
|
$survey_question_item.insertAfter($next);
|
||||||
|
refresh_sequence_input();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
refresh_sequence_input();
|
||||||
|
|
||||||
$('#add_survey_question a.add').live('click', function(){
|
$('#add_survey_question a.add').live('click', function(){
|
||||||
var new_id = $(this).prev().attr('value');
|
var new_id = $(this).prev().attr('value');
|
||||||
|
|
1
vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/_answer_error.erb
vendored
Normal file
1
vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/_answer_error.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
alert("<%= @survey_answer_error %>");
|
2
vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/_answer_success.erb
vendored
Normal file
2
vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/_answer_success.erb
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
alert("<%= t('survey.answer_success')%>");
|
||||||
|
window.location.href = "<%= root_path %>";
|
1
vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/answer_error.js.erb
vendored
Normal file
1
vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/answer_error.js.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<%= render 'answer_error' %>
|
|
@ -0,0 +1 @@
|
||||||
|
<%= render 'answer_success' %>
|
|
@ -53,6 +53,7 @@ en:
|
||||||
survey_question:
|
survey_question:
|
||||||
title: Question
|
title: Question
|
||||||
description: Description
|
description: Description
|
||||||
|
sequence: Sequence
|
||||||
type: Type
|
type: Type
|
||||||
is_required: Is Required
|
is_required: Is Required
|
||||||
required: Required
|
required: Required
|
||||||
|
@ -74,3 +75,5 @@ en:
|
||||||
|
|
||||||
move_up: Move up
|
move_up: Move up
|
||||||
move_down: Move down
|
move_down: Move down
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ zh_tw:
|
||||||
survey_question:
|
survey_question:
|
||||||
title: 題目
|
title: 題目
|
||||||
description: 說明
|
description: 說明
|
||||||
|
sequence: 順序
|
||||||
type: 作答方式
|
type: 作答方式
|
||||||
is_required: 設為必填
|
is_required: 設為必填
|
||||||
required: 必填
|
required: 必填
|
||||||
|
@ -75,4 +76,4 @@ zh_tw:
|
||||||
have_not_chart: 此種類型問題不含結果圖表
|
have_not_chart: 此種類型問題不含結果圖表
|
||||||
|
|
||||||
move_up: 上移
|
move_up: 上移
|
||||||
move_down: 下移
|
move_down: 下移
|
Loading…
Reference in New Issue