diff --git a/app/views/phases/_answer_form.html.erb b/app/views/phases/_answer_form.html.erb index e5408af..abee475 100644 --- a/app/views/phases/_answer_form.html.erb +++ b/app/views/phases/_answer_form.html.erb @@ -61,41 +61,62 @@
    <% options.each do |op| %>
  1. - <%= f.check_box(:question_option_ids, { multiple: true, checked: answer.has_question_option(op.id) }, op.id, nil) %> + <%= f.check_box(:question_option_ids, { multiple: true, checked: answer.has_question_option(op.id), disabled: readonly }, op.id, nil) %> <%= raw op.text %>
  2. <% end %>
- <% elsif q_format.multiselectbox? %> - <%= f.input :options, as: :select, collection: options, label: false, input_html: { multiple: true , id: "options-#{question.id}" } %> <% elsif q_format.radiobuttons? %>
    <% options.each do |op| %>
  1. - <%= f.radio_button :question_option_ids, op.id, { checked: answer.has_question_option(op.id), id: "answer_option_ids_#{op.id}" } %> + <%= f.radio_button :question_option_ids, op.id, { checked: answer.has_question_option(op.id), id: "answer_option_ids_#{op.id}", disabled: readonly } %> <%= raw op.text %>
  2. <% end %>
- <% elsif q_format.dropdown? %> - <%= f.input :options, as: :select, collection: options, label: false, input_html: { multiple: false, id: "options-#{question.id}" } %> + <% elsif q_format.dropdown? || q_format.multiselectbox? %> + <% + options_html = "" + options.each do |op| + options_html += answer.has_question_option(op.id) ? + "" : + "" + end + %> + <%= select_tag('answer[question_option_ids]', raw(options_html), + {multiple: q_format.multiselectbox?, include_blank: q_format.dropdown?, disabled: readonly }) %> <% end %> <% if question.option_comment_display == true %> <%= label_tag("answer-text-#{question.id}".to_sym, _('Comment')) %> - <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %> + <% if readonly %> +

<%= raw(answer.text) %>

+ <% else %> + <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %> + <% end %> <%end%> <% end %> <% if q_format.textfield? %> - <%= text_field_tag("answer-text-#{question_id}".to_sym, strip_tags(answer.text), class: "question_text_field") %> + <% if readonly %> +

<%= strip_tags(answer.text) %>

+ <% else %> + <%= text_field_tag("answer-text-#{question_id}".to_sym, strip_tags(answer.text), { class: "question_text_field" }) %> + <% end %> <% elsif q_format.textarea? %> - <%= text_area_tag("answer-text-#{question_id}".to_sym, answer.text, class: "tinymce") %> + <% if readonly %> +

<%= raw(answer.text) %>

+ <% else %> + <%= text_area_tag("answer-text-#{question_id}".to_sym, answer.text, class: "tinymce") %> + <% end %> <% end %> - + <% if !readonly %> + + <% end %> @@ -202,12 +223,10 @@ -
<%= render partial: "note", locals: {question: question, answer: answer, plan: plan, suffix: "" }%>
- diff --git a/app/views/phases/_answer_form_ro.html.erb b/app/views/phases/_answer_form_ro.html.erb deleted file mode 100644 index 915db2a..0000000 --- a/app/views/phases/_answer_form_ro.html.erb +++ /dev/null @@ -1,235 +0,0 @@ - -<% answer = @plan.answer(question.id) %> - -
- - <% q_format = question.question_format%> - - - <% if readonly != "always" then %> -
> - <%= semantic_form_for answer, :url => {:controller => :answers, :action => :update }, :html=>{:method=>:post}, :remote => true do |f| %> - <%= f.inputs do %> - <%= f.input :plan_id, :as => :hidden %> - <%= f.input :user_id, :as => :hidden, :input_html => { :value => current_user.id } %> - <%= f.input :question_id, :as => :hidden, :input_html => { :class => "question_id" } %> - - - -

<%= raw question.text %>

- - - <% if question.annotations.where('type <> ?',Annotation.types[:example_answer]).any? %> - <% annotation = question.annotations.where('type <> ?',Annotation.types[:example_answer]).order(:created_at).first %> -
- - <%= _('Example of answer')%> - -
-

- <%= raw annotation.text %> -

-
-
- <% end %> - - - <% if q_format.title == _('Check box') || q_format.title == _('Multi select box') || q_format.title == _('Radio buttons') || q_format.title == _('helpers.dropdown') then%> - <% options = question.options.order("number") %> - - <% if q_format.title == _('Check box') %> - <% if readonly %> - <%= f.input :options, :as => :check_boxes, :collection => options, :label => false, input_html => { :disabled => true, :id => "options-#{question.id}" } %> - <% else %> - <%= f.input :options, :as => :check_boxes, :collection => options, :label => false, :input_html => { :id => "options-#{question.id}" } %> - <% end %> - - <% elsif q_format.title == _('Multi select box') %> - <% if readonly then %> - <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => true, :disabled => true , :id => "options-#{question.id}" } %> - <% else %> - <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => true , :id => "options-#{question.id}" } %> - <% end %> - - <% elsif q_format.title == _('Radio buttons') %> -
    - <% options.each do |op| %> -
  1. - <% if answer.option_ids[0] == op.id then%> - <% if readonly then %> - <%= f.radio_button :option_ids, op.id, :checked => true, disabled: true, id: "answer_option_ids_#{op.id}"%> - <% else %> - <%= f.radio_button :option_ids, op.id, :checked => true, id: "answer_option_ids_#{op.id}"%> - <% end %> - <%else%> - <% if readonly then %> - <%= f.radio_button :option_ids, op.id, :checked => false, disabled: true, id: "answer_option_ids_#{op.id}"%> - <% else %> - <%= f.radio_button :option_ids, op.id, :checked => false, id: "answer_option_ids_#{op.id}"%> - <% end %> - <% end %> - <%= op.text %>
  2. - <% end %> -
- - <% elsif q_format.title == _('Dropdown') %> - <% if readonly %> - <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => false, :disabled => true, :id => "options-#{question.id}" } %> - <% else %> - <%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => false, :id => "options-#{question.id}" } %> - <% end %> - - - <% elsif q_format.title == _('Text field') then %> - <%= text_field_tag("answer-text-#{question.id}".to_sym, strip_tags(answer.text), class: "question_text_field") %> - - <% elsif q_format.title == _('Text area') then%> - <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %> - <% end %> - - <% if question.option_comment_display == true then%> - <%= label_tag("answer-text-#{question.id}".to_sym, _('Comment')) %> - <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %> - <%end%> - - <% end %> - - - <%= f.actions do %> - - - <% end %> - <% end %> -
- <% end %> - -
> -
- <% if q_format.title == _('Check box') || q_format.title == _('Multi select box') || q_format.title == _('Radio buttons') || q_format.title == _('Dropdown') %> -
    - <% if answer.options.is_a? Option then %> -
  • <%= answer.options.text %>
  • - <% else %> - <% answer.options.each do |o| %> -
  • <%= o.text %>
  • - <% end %> - <% end %> -
- <% end %> -
- <%= raw answer.text %> -
-
-
- <% if answer.created_at.nil? then %> - <%= _('Not answered yet') %> - <% else %> - <%= _('Answered ')%><%= answer.created_at %><%= _(' by ')%><%= answer.user.name %> - <% end %> - -
- - - -
-
- <% @comments = answer.notes.all %> - <%= hidden_field_tag :question_id, question.id, :class => "question_id" %> - - -
- - - -
-
- - <% q_guidance = question.get_guidance_annotation(current_user.org) %> - <% if q_guidance.present? && q_guidance.text.present %> - - <% end %> - - <% guidance_accordion_id = 0 %> - <% question_guidances.each_pair do |theme, group| %> - <% group.each do |gobj| %> -
- -
-
<%= raw gobj[:text] %>
-
- <% guidance_accordion_id += 1 %> -
- <% end %> - <% end %> - <% end %> -
-
- - -
- <%= render :partial => "note", locals: {question: question, plan: @plan, answer: answer }%> -
- - - -
- -<% if last_question_id == question.id %> -
-<% else %> -
-<% end %> \ No newline at end of file diff --git a/app/views/phases/edit.html.erb b/app/views/phases/edit.html.erb index 3a29a21..8310dce 100644 --- a/app/views/phases/edit.html.erb +++ b/app/views/phases/edit.html.erb @@ -86,15 +86,10 @@ <% section.questions.each do |question| %> <% if question.id == session[:question_id_comments].to_i then id_css = "current_question" end %>
- <% partialname = "answer_form" - if @readonly - partialname += "_ro" - end - %> <% guidances = @question_guidance[question.id] %> - <%= render partial: partialname, + <%= render partial: 'answer_form', locals: { plan: @plan, phase_id: @phase.id,