From 7ba0977e16866baa6e4ad57a0f745c45be0231ef Mon Sep 17 00:00:00 2001 From: iCross Date: Mon, 20 May 2013 17:16:06 +0800 Subject: [PATCH] stuff Conflicts: vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/show.html.erb --- .../survey/front_end/surveys_controller.rb | 17 +- .../survey/app/models/survey.rb | 3 + .../survey/back_end/surveys/_form.html.erb | 16 ++ .../survey/back_end/surveys/_survey.html.erb | 1 - .../survey/front_end/surveys/result.html.erb | 2 +- .../survey/front_end/surveys/show.html.erb | 208 +++++++++--------- .../survey/config/locales/en.yml | 4 + .../survey/config/locales/zh_tw.yml | 4 + 8 files changed, 147 insertions(+), 108 deletions(-) diff --git a/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb b/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb index 5d83101e..847fa430 100644 --- a/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb +++ b/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb @@ -10,13 +10,18 @@ class Panel::Survey::FrontEnd::SurveysController < OrbitWidgetController end def show - redirect_standalone panel_survey_front_end_survey_path(params[:id], :standalone => 'true') do - @survey = ::Survey.find params[:id] - @questions = @survey.survey_questions.all - if @survey.jump_mode - @jumpable_questions = @questions.all.select{ |q| q.jumpable? && q.can_set_jump? } + @survey = ::Survey.find params[:id] + if @survey.redirect_mode + @redirect_url = @survey.redirect_url + render :redirect_standalone + else + redirect_standalone panel_survey_front_end_survey_path(params[:id], :standalone => 'true') do + @questions = @survey.survey_questions.all + if @survey.jump_mode + @jumpable_questions = @questions.all.select{ |q| q.jumpable? && q.can_set_jump? } - @jump_tos_map = @jumpable_questions.map(&:get_jump_tos).inject(:merge) + @jump_tos_map = @jumpable_questions.map(&:get_jump_tos).inject(:merge) + end end end end diff --git a/vendor/built_in_modules/survey/app/models/survey.rb b/vendor/built_in_modules/survey/app/models/survey.rb index 295658c9..4767b2f2 100644 --- a/vendor/built_in_modules/survey/app/models/survey.rb +++ b/vendor/built_in_modules/survey/app/models/survey.rb @@ -28,6 +28,9 @@ class Survey mount_uploader :upload_file, AssetUploader field :jump_mode, :type => Boolean, :default => false + + field :redirect_mode, :type => Boolean, :default => false + field :redirect_url, :type => String validates :title, :at_least_one => true diff --git a/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_form.html.erb b/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_form.html.erb index 0bd483a8..3309a202 100644 --- a/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_form.html.erb +++ b/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_form.html.erb @@ -18,6 +18,22 @@ +
+
+ +
+

<%= t('survey.redirect') %>

+
+
+ <%= f.label :redirect_mode, t('survey.redirect_mode')%> + <%= f.check_box :redirect_mode %> +
+
+ <%= f.label :redirect_url, t('survey.redirect_url') %> + <%= f.text_field :redirect_url %> +
+
+
diff --git a/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_survey.html.erb b/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_survey.html.erb index 762b7fc9..1383bc07 100644 --- a/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_survey.html.erb +++ b/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_survey.html.erb @@ -13,7 +13,6 @@
  • <%= link_to t('survey.duplicate_it'), duplicate_it_panel_survey_back_end_survey_path(survey, :page => params[:page]) %>
  • <%= link_to t('survey.jump'), jump_panel_survey_back_end_survey_path(survey, :page => params[:page]) %>
  • <%= link_to t('survey.set_answers'), set_answers_panel_survey_back_end_survey_path(survey, :page => params[:page]) %>
  • -
  • <%= link_to t('survey.answers_list'), panel_survey_back_end_survey_answers_path(survey, :page => params[:page]) %>
  • <%= link_to t('survey.export_csv'), export_panel_survey_back_end_survey_path(survey, :format => :csv), :target => '_blank' %>
  • <%= link_to t('survey.chart'), result_panel_survey_front_end_survey_path(survey, :force_chart => true, :standalone => true), :target => '_blank' %>
  • <%= link_to t(:delete_), panel_survey_back_end_survey_path(survey), :confirm => t('sure?'), :method => :delete, :remote => true %>
  • diff --git a/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/result.html.erb b/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/result.html.erb index 6db8b0c5..2d02eea7 100644 --- a/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/result.html.erb +++ b/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/result.html.erb @@ -6,7 +6,7 @@
    - <%= t 'survey.results_count' %>: <%= @survey_questions.count %> + <%= t 'survey.results_count' %>: <%= @survey.survey_answers.count %>
      <% @survey_questions.each do |question| %> diff --git a/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/show.html.erb b/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/show.html.erb index e2126998..b013e007 100644 --- a/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/show.html.erb +++ b/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/show.html.erb @@ -1,109 +1,117 @@ <% # encoding: utf-8 %> -

      <%= @survey.title %>

      -
      -
      -
      - <%= form_for :answer, :method => :put, :url => panel_survey_front_end_survey_path(@survey, :inner => true), :html => {:class => 'clear'} do |f| %> -
      - <%= @survey.description %> -
      -
        - <% @questions.each_with_index do |question, i| %> -
      1. - <% label = question.title %> - <% label += ' (' + t('survey_question.required') + ')' if question.is_required %> - <%= f.label question.id, label, :class => "o-question-title" %> -
        - <%= question.description %> -
        - <% case question.type %> - <% when ::SurveyQuestion::Oneline %> - <%= f.text_field question.id, :required => question.is_required %> - <% when ::SurveyQuestion::Multiline %> - <%= f.text_area question.id, :rows => 5, :required => question.is_required %> - <% when ::SurveyQuestion::Radio %> - <% question.survey_question_options.each do |option| %> -

        - <%= f.radio_button question.id, option.id %> - <%= f.label "#{question.id}_#{option.id}", option.name, :style => "display:inline" %> -

        - <% end %> - <% if question.custom_option %> -

        - <%= f.radio_button question.id, 'custom_option' %> - <%= f.label "#{question.id}_custom_option", t('survey_question.use_custom_option') + ': ', :style => "display:inline" %> - <%= f.text_field "#{question.id}_custom_option" %> -

        - <% end %> - <% when ::SurveyQuestion::Check %> - <%= f.fields_for "#{question.id}" do |cf| %> - <% question.survey_question_options.each do |option| %> -

        - <%= cf.check_box option.id %> - <%= cf.label option.id, option.name, :style => "display:inline" %> -

        - <% end %> - <% if question.custom_option %> -

        - <%= cf.check_box 'custom_option' %> - <%= f.label "#{question.id}_custom_option", t('survey_question.use_custom_option') + ': ', :style => "display:inline" %> - <%= f.text_field "#{question.id}_custom_option" %> -

        - <% end %> - <% end %> - <% when ::SurveyQuestion::Select %> - <% options = question.survey_question_options.collect {|o| [ o.name, o.id ] } %> - <% if question.custom_option %> - <% options.push [t('survey_question.use_custom_option'), 'custom_option'] %> - <% end %> - <%= f.select question.id, options %> - <% if question.custom_option %> - <%= f.text_field "#{question.id}_custom_option", :class => 'custom_option' %> - <% end %> - <% when ::SurveyQuestion::Radiogroup %> - <%= f.fields_for "#{question.id}" do |rgf| %> - - - - - <% question.survey_question_radiogroups.each do |radiogroup| %> - - <% end %> - - - - <% question.survey_question_options.each_with_index do |option, j| %> - > - - <% question.survey_question_radiogroups.each do |radiogroup| %> - - <% end %> - - <% end %> - -
        - <%= radiogroup.name %> -
        - <%= option.name %> - - <%= rgf.radio_button option.id, radiogroup.id %> -
        - <% end %> - <% end %> -
      2. - <% end %> -
      -
      - <%= f.submit t('submit'), :class => 'survey-submit' %> -
      - <% end %> -
      -
      +
      + <%= form_for :answer, :method => :put, :url => panel_survey_front_end_survey_path(@survey, :standalone => true), :html => {:class => 'survey clear'} do |f| %> +

      <%= @survey.title %>

      +
      + <%= @survey.description %> +
      +
        + <% @questions.each_with_index do |question, i| %> +
      1. + <% label = question.title %> + <% label += ' (*)' if question.is_required %> + <%= f.label question.id, label, :class => "o-question-title" %> +
        + <%= question.description %> +
        + <% case question.type %> + <% when ::SurveyQuestion::Oneline %> + <%= f.text_field question.id, :required => question.is_required %> + <% when ::SurveyQuestion::Multiline %> + <%= f.text_area question.id, :rows => 5, :required => question.is_required %> + <% when ::SurveyQuestion::Radio %> +
          + <% question.survey_question_options.each do |option| %> +
        • + <%= f.radio_button question.id, option.id %> + <%= f.label "#{question.id}_#{option.id}", option.name, :class => 'o-question-option' %> +
        • + <% end %> + <% if question.custom_option %> +
        • + <%= f.radio_button question.id, 'custom_option' %> + <%= f.label "#{question.id}_custom_option", t('survey_question.use_custom_option') + ': ', :class => 'o-question-option' %> + <%= f.text_field "#{question.id}_custom_option" %> +
        • + <% end %> +
        + <% when ::SurveyQuestion::Check %> +
          + <%= f.fields_for "#{question.id}" do |cf| %> + <% question.survey_question_options.each do |option| %> +
        • + <%= cf.check_box option.id %> + <%= cf.label option.id, option.name, :class => 'o-question-option' %> +
        • + <% end %> + <% if question.custom_option %> +
        • + <%= cf.check_box 'custom_option' %> + <%= f.label "#{question.id}_custom_option", t('survey_question.use_custom_option') + ': ', :class => 'o-question-option' %> + <%= f.text_field "#{question.id}_custom_option" %> +
        • + <% end %> + <% end %> +
        + <% when ::SurveyQuestion::Select %> + <% options = question.survey_question_options.collect {|o| [ o.name, o.id ] } %> + <% if question.custom_option %> + <% options.push [t('survey_question.use_custom_option'), 'custom_option'] %> + <% end %> + <%= f.select question.id, options, {}, :class => 'o-question-group view-dropdown' %> + <% if question.custom_option %> + <%= f.text_field "#{question.id}_custom_option", :class => 'custom_option' %> + <% end %> + <% when ::SurveyQuestion::Radiogroup %> + <%= f.fields_for "#{question.id}" do |rgf| %> + + + + + <% question.survey_question_radiogroups.each do |radiogroup| %> + + <% end %> + + + + <% question.survey_question_options.each_with_index do |option, j| %> + > + + <% question.survey_question_radiogroups.each do |radiogroup| %> + + <% end %> + + <% end %> + +
        + <%= radiogroup.name %> +
        + <%= option.name %> + + <%= rgf.radio_button option.id, radiogroup.id %> +
        + <% end %> + <% end %> +
      2. + <% end %> +
      +
      + <%= f.submit t('submit'), :class => 'survey-submit' %> +
      + <% end %>
      <% content_for :page_stylesheets do %> <% end %> +