Skip to content

Commit c84329c

Browse files
authored
Merge pull request #443 from DigitalCurationCentre/issue_431
Issue 431
2 parents 8e1511e + a768072 commit c84329c

File tree

12 files changed

+136
-400
lines changed

12 files changed

+136
-400
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<%= form_for(note,
32
url: archive_note_path(note),
43
remote: true,
@@ -8,7 +7,7 @@
87
<%= f.hidden_field :id, :value => note.id %>
98
<%= f.hidden_field :archived_by, :value => current_user.id %>
109

11-
<%= render :partial => "/phases/view_note", locals: {note: note} %>
10+
<%= render :partial => "/notes/view", locals: {note: note} %>
1211

1312
<p><%= _('Are you sure you want to remove this note?')%></p>
1413

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,27 @@
5858
<% latest_note = notes_not_archived.sort { |x,y| y.updated_at <=> x.updated_at }.first %>
5959
<% if !latest_note.nil? then%>
6060
<div id = "latest_comment_div_<%= question_id %>" class ="view_comment_class">
61-
<%= render :partial => "/phases/view_note", locals: {note: latest_note} %>
61+
<%= render :partial => "/notes/view", locals: {note: latest_note} %>
6262
<div class="two-column-clear question-divider"></div>
6363
</div>
6464
<%end%>
6565
<!-- load notes to view and edit -->
6666
<%notes.each do |note|%>
6767
<!-- view note -->
6868
<div id = "view_comment_div_<%= note.id %>" class ="view_comment_class" style="display: none">
69-
<%= render :partial => "/phases/view_note", locals: {note: note} %>
69+
<%= render :partial => "/notes/view", locals: {note: note} %>
7070
<div class="two-column-clear question-divider"></div>
7171
</div>
7272

7373
<!-- edit note block -->
7474
<div id = "edit_comment_div_<%= note.id %>" class ="edit_comment_class" style="display: none">
75-
<%= render :partial => "/phases/edit_note", locals: {note: note} %>
75+
<%= render :partial => "/notes/edit", locals: {note: note} %>
7676
<div class="two-column-clear question-divider"></div>
7777
</div>
7878

7979
<!-- archive note block -->
8080
<div id = "archive_comment_div_<%= note.id %>" class ="archive_comment_class" style="display: none">
81-
<%= render :partial => "/phases/archive_note", locals: {note: note, question_id: question_id} %>
81+
<%= render :partial => "/notes/archive", locals: {note: note, question_id: question_id} %>
8282
<div class="two-column-clear question-divider"></div>
8383
</div>
8484

app/views/phases/_answer_form.html.erb

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,30 @@
3434
<div id="right-area-tabs-<%= question.id %>" class="question_right_column_nav">
3535
<% comments = answer.notes.all %>
3636
<%= hidden_field_tag :question_id, question.id, class: "question_id" %>
37+
<% active_tab = nil %>
3738
<ul class="question_right_column_ul">
38-
<% annotations = question.annotations.where(type: Annotation.types[:guidance]) %>
39-
<% if annotations.present? || question_guidances.present? %>
40-
<!-- add css to comment div-->
41-
<% css_style_comment_div = "display: none;"%>
42-
<% css_style_guidance_div = ""%>
43-
<li class="active guidance_tab_class">
44-
<%= link_to _('Guidance'), "#", class: "guidance_accordion_button" %>
45-
</li>
46-
<li class="comment_tab_class">
47-
<% if comments.count > 0%>
48-
<% comments_label_with_count = "#{_('Notes')} (#{comments.count})"%>
49-
<%= link_to comments_label_with_count , "#", id: "notes_number_#{question.id}", class: "comments_accordion_button" %>
39+
<% annotations = question.annotations.where(type: Annotation.types[:guidance]) %>
40+
<% if annotations.present? || question_guidances.present? %>
41+
<% active_tab = 'guidance_tab' %>
42+
<li class="guidance_tab active">
43+
<%= link_to _('Guidance'), "#", class: "right_column_tab_link" %>
44+
</li>
45+
<% else %>
46+
<% active_tab = 'note_tab' %>
47+
<% end %>
48+
<li class="note_tab <%= "active" if active_tab == 'note_tab' %>">
49+
<% if comments.count > 0 %>
50+
<%= link_to "#{_('Notes')} (#{comments.count})" , "#", id: "notes_number_#{question.id}", class: "right_column_tab_link" %>
5051
<% else %>
51-
<%= link_to _('Share note'), "#", id: "notes_number_#{question.id}", class: "comments_accordion_button" %>
52+
<%= link_to _('Share note'), "#", id: "notes_number_#{question.id}", class: "right_column_tab_link" %>
5253
<% end %>
5354
</li>
54-
<% else %>
55-
<!-- remove the css from comment div-->
56-
<% css_style_comment_div = ""%>
57-
<% css_style_guidance_div = "display: none;"%>
58-
<li>
59-
<% if comments.count > 0 %>
60-
<% comments_label_with_count = "#{_('Notes')} (#{comments.count})"%>
61-
<p id="notes_number_<%=question.id%>" class= "accordion_label"><%= comments_label_with_count %></p>
62-
<% else %>
63-
<p id="notes_number_<%=question.id%>" class= "accordion_label"><%= _('Share note') %></p>
64-
<% end %>
65-
</li>
66-
<% end %>
6755
</ul>
6856
</div>
6957

7058

71-
<!--guidance area -->
72-
<div class="question-guidance" id="guidance-question-area-<%= question.id %>" style="<%= css_style_guidance_div%>" >
59+
<!--guidance content -->
60+
<div class="question-guidance guidance_tab" id="guidance-question-area-<%= question.id %>" style="<%= active_tab == 'guidance_tab' ? '' : 'display:none;' %>">
7361
<div class="accordion" id="<%= question.id %>-guidance">
7462

7563
<!--question guidance-->
@@ -120,9 +108,9 @@
120108
<% end %> <!-- question_guidances.each_pair -->
121109

122110
</div> <!-- accordion-questionid -->
123-
</div> <!-- question-guidance -->
124-
<!--comment area -->
125-
<div class="comment-area" id="comment-question-area-<%= question.id %>" style="<%= css_style_comment_div%>">
111+
</div> <!-- question-guidance -->
112+
<!--note content -->
113+
<div class="comment-area note_tab" id="comment-question-area-<%= question.id %>" style="<%= active_tab == 'note_tab' ? '' : 'display:none;' %>">
126114
<%= render partial: "note", locals: {question: question, answer: answer, plan: plan, suffix: "" }%>
127115
</div>
128116
</div> <!-- question area right column -->

app/views/phases/_note.html.erb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
<!-- if there are notes then list of notes and view last note
2-
else display display add note form -->
3-
41
<% if answer.present? && answer.notes.any? %>
52
<% notes = answer.notes.all.to_a.sort! {|x,y| y.updated_at <=> x.updated_at } %>
63
<% questionid = question.id %>
@@ -18,15 +15,15 @@
1815
<div class="div_clear"></div>
1916

2017
<!-- list of notes, view and edit a note -->
21-
<%= render :partial => "/phases/list_notes", locals: {question_id: question.id, notes: notes, plan: plan} %>
18+
<%= render :partial => "/notes/list", locals: {question_id: question.id, notes: notes, plan: plan} %>
2219

2320

2421
<div class="div_clear"></div>
2522

2623
<!-- add a note block -->
2724
<div id="add_comment_block_div_<%= questionid %>" style="display: none">
28-
<%= render :partial => "/phases/add_note", locals: {answer: answer, question: question, plan_id: plan.id }%>
25+
<%= render :partial => "/notes/add", locals: {answer: answer, question: question, plan_id: plan.id }%>
2926
</div>
3027
<% else%>
31-
<%= render :partial => "/phases/add_note", locals: {answer: answer, question: question, plan_id: plan.id }%>
28+
<%= render :partial => "/notes/add", locals: {answer: answer, question: question, plan_id: plan.id }%>
3229
<% end%>

app/views/phases/edit.html.erb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<%- model_class = Plan -%>
22
<% javascript "plans.js" %>
33
<% javascript "answers/status.js" %>
4+
<% javascript "notes/index.js" %>
45
<!--
56
editing plan details is handled through plan#show
67
so if we come this way then we are editing a phase
@@ -25,14 +26,6 @@
2526

2627
<% sectionid = section.id %>
2728

28-
<!-- verify if the session[:question_id_comments] has been created. -->
29-
<% if session[:question_id_comments].to_i != 0 then %>
30-
<% question_from_comment = Question.find(session[:question_id_comments])%>
31-
<% if sectionid == question_from_comment.section_id then %>
32-
<%= hidden_field_tag :comment_section_id, question_from_comment.section_id, :class => "comment_section_id" %>
33-
<%end%>
34-
<% end%>
35-
3629
<div class="accordion-group">
3730
<!-- section heading -->
3831
<div class="accordion-heading">
@@ -123,6 +116,3 @@
123116
</div>
124117

125118
<%= render :partial => "plans/export", locals: {plan: @plan, plan_data: @plan_data, phase: @phase } %>
126-
127-
<!-- this session is created when a comment is created, edited or deleted. After the view is loaded this session variable can be deleted-->
128-
<% session.delete(:question_id_comments)%>

config/application.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class Application < Rails::Application
8383
config.assets.precompile += %w(contacts/new_contact.js)
8484
config.assets.precompile += %w(shared/register_form.js)
8585
config.assets.precompile += %w(answers/status.js)
86+
config.assets.precompile += %w(notes/index.js)
8687

8788
config.autoload_paths += %W(#{config.root}/lib)
8889
config.action_controller.include_all_helpers = true

0 commit comments

Comments
 (0)