diff --git a/app/views/phases/_answer_section.html.erb b/app/views/phases/_answer_section.html.erb new file mode 100644 index 0000000..ac63c24 --- /dev/null +++ b/app/views/phases/_answer_section.html.erb @@ -0,0 +1,10 @@ +
+
" class="answer-locking">
+
"> + <%= render(partial: 'answers/new_edit', + locals: { question: question, answer: answer, readonly: @readonly }) %> +
+
" class="answer-status"> + <%= render(partial: 'answers/status', locals: { answer: answer }) %> +
+
\ No newline at end of file diff --git a/app/views/phases/_guidance_section.html.erb b/app/views/phases/_guidance_section.html.erb new file mode 100644 index 0000000..32fd4c9 --- /dev/null +++ b/app/views/phases/_guidance_section.html.erb @@ -0,0 +1,106 @@ +
+ <% comments = answer.notes.all %> + <% active_tab = nil %> + <%= hidden_field_tag :question_id, question.id, class: "question_id" %> + + + + +
+
+ + +
+ + <% num_annotations = 0 %> + <% i = 0 %> + <% if annotations.present? %> + <% annotations.each do |annotation| %> + <%= render partial: 'annotations/show', locals: {annotation: annotation} %> + <% num_annotations += 1%> + <% i += 1 %> + <% end %> + <% end %> + + + <% guidances = @question_guidance[question.id] %> + <% guidance_accordion_id = num_annotations %> + <% guidances.each_pair do |theme, groups| %> + <% groups.each do |group| %> + <%= render partial: 'guidance_groups/show', + locals: {group: group, theme: theme, i: i, question: question, + guidance_accordion_id: guidance_accordion_id} %> + + <% guidance_accordion_id += 1 %> + <% i += 1 %> + <% end %> + <% end %> +
+ +
+ +
+ + + <% if answer.present? && answer.notes.any? %> + <% notes = answer.notes.all.to_a.sort! {|x,y| y.updated_at <=> x.updated_at } %> + <% questionid = question.id %> + <%= hidden_field_tag :question_id, questionid, class: "question_id" %> + + +
+ <%= link_to _('Add note'), "#question-form-#{questionid}", + class: "btn btn-primary add_comment_button", + onclick: "add_note_button(#{questionid})", + role: "button" %> +
+ +
+ + + <%= render partial: "/notes/list", + locals: {question_id: question.id, notes: notes, plan: @plan} %> + +
+ + + + <% else %> + <%= render partial: "/notes/add", + locals: {answer: answer, question: question, plan_id: @plan.id }%> + <% end%> +
+ +
+
\ No newline at end of file diff --git a/app/views/phases/edit.html.erb b/app/views/phases/edit.html.erb index a9e8349..ed748fe 100644 --- a/app/views/phases/edit.html.erb +++ b/app/views/phases/edit.html.erb @@ -52,7 +52,7 @@ -
+

<%= raw section.description %>

@@ -69,178 +69,68 @@ <% if question.id == session[:question_id_comments].to_i then id_css = "current_question" end %>
+ <% + # Load the answer or create a new one + answers = question.plan_answers(@plan.id) + if answers.present? + answer = answers.first + else + answer = Answer.new({plan_id: @plan.id, + question_id: question.id, + user_id: current_user.id }) + if question.default_value.present? + answer.text = question.default_value + end + end + %> +
- <% - # Load the answer or create a new one - answers = question.plan_answers(@plan.id) - if answers.present? - answer = answers.first - else - answer = Answer.new({plan_id: @plan.id, - question_id: question.id, - user_id: current_user.id }) - if question.default_value.present? - answer.text = question.default_value - end - end - %> -
-
" class="answer-locking">
-
"> - <%= render(partial: 'answers/new_edit', - locals: { question: question, answer: answer, readonly: @readonly }) %> -
-
" class="answer-status"> - <%= render(partial: 'answers/status', locals: { answer: answer }) %> -
-
+ <%= render partial: 'answer_section', + locals: {plan: @plan, question: question, answer: answer, readonly: @readonly}%> +
+
-
- <% comments = answer.notes.all %> - <% active_tab = nil %> - <%= hidden_field_tag :question_id, question.id, class: "question_id" %> - - -
    - <% annotations = question.annotations.where(type: Annotation.types[:guidance]) %> - <% if annotations.present? || question_guidances.present? %> - <% active_tab = 'guidance_tab' %> - - <% else %> - <% active_tab = 'note_tab' %> - <% end %> - -
  • " role="tab" - aria-controls="comment-question-area-<%= question.id %>"> - <% if comments.length > 0 %> - <%= _('Notes') %> - <% else %> - <%= _('Share note') %> - <% end %> -
  • -
- -
-
- - -
- - <% num_annotations = 0 %> - <% i = 0 %> - <% if annotations.present? %> - <% annotations.each do |annotation| %> - <%= render partial: 'annotations/show', locals: {annotation: annotation} %> - <% num_annotations += 1%> - <% i += 1 %> - <% end %> - <% end %> - - - <% guidances = @question_guidance[question.id] %> - <% guidance_accordion_id = num_annotations %> - <% guidances.each_pair do |theme, groups| %> - <% groups.each do |group| %> - <%= render partial: 'guidance_groups/show', - locals: {group: group, theme: theme, i: i, question: question, - guidance_accordion_id: guidance_accordion_id} %> - - <% guidance_accordion_id += 1 %> - <% i += 1 %> - <% end %> - <% end %> -
- -
- -
- - - <% if answer.present? && answer.notes.any? %> - <% notes = answer.notes.all.to_a.sort! {|x,y| y.updated_at <=> x.updated_at } %> - <% questionid = question.id %> - <%= hidden_field_tag :question_id, questionid, class: "question_id" %> - - -
- <%= link_to _('Add note'), "#question-form-#{questionid}", - class: "btn btn-primary add_comment_button", - onclick: "add_note_button(#{questionid})", - role: "button" %> -
- -
- - - <%= render partial: "/notes/list", - locals: {question_id: question.id, notes: notes, plan: @plan} %> - -
- - - - <% else %> - <%= render partial: "/notes/add", - locals: {answer: answer, question: question, plan_id: @plan.id }%> - <% end%> -
- -
-
+ <%= render partial: 'guidance_section', + locals: {plan: @plan, question: question, answer: answer} %>
- -
-
- <% end %> +
+ <% end %> - + + + <% i += 1 %> diff --git a/lib/assets/javascripts/views/plans/edit.js b/lib/assets/javascripts/views/plans/edit.js index 322f903..3061ab9 100644 --- a/lib/assets/javascripts/views/plans/edit.js +++ b/lib/assets/javascripts/views/plans/edit.js @@ -1,34 +1,7 @@ $(document).ready(function(){ - $("#is_test").on('click, change', function(e){ - toggleVisibility(); - // If the test box is checked then update the visibility to 'is_test' - if($("#is_test").is(':checked')){ - $('#plan_visibility').val('is_test'); - }else{ - $('#plan_visibility').val(''); - } + $(".accordion-section").accordion({ + active: false, + collapsible: true, + heightStyle: "content" }); - - $("input[name='vis']").on('change', function(e){ - $('#plan_visibility').val($("input[name='vis']:checked").attr('id')); - }); - - toggleVisibility(); - - function toggleVisibility(){ - var test = $("#is_test").is(':checked'); - // If the test checkbox is true then disable the visibility dropdown - $("input[name='vis']").attr('aria-disabled', test).attr('disabled', test); - } - - /*---------------- - TODO: See if this is still necessary after redesign of Edit Plan page - Listener for click on buttons containing show-edit-toggle class - ------------------*/ - $(".show-edit-toggle").click(function (e) { - e.preventDefault(); - $(".edit-plan-details").toggle(); - $(".show-plan-details").toggle(); - }); - }); \ No newline at end of file