Newer
Older
dmpopidor / app / views / phases / _note.html.erb
<!-- if there are notes then list of notes and view last note
  else display display add note form -->

  <% if answer.present? && answer.notes.any? %>
    <% notes = answer.notes.all.to_a.sort! {|x,y| y["updated_at"] <=> x["updated_at"] } %>
    <% answerid = answer.id %>
    <%= hidden_field_tag :answer_id, answer.id %>

    <!-- add note -->
    <div id="add_comment_button_top_div_<%= answerid %>" class="move_2_right" >
      <%= link_to _('Add note'),'#', :class => "btn btn-primary add_comment_button" %>
    </div>

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

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

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

    <!-- add a note button -->
    <div id="add_comment_button_bottom_div_<%= answerid %>" class="move_2_right">
      <%= link_to _('Add note'),'#', :class => "btn btn-primary add_comment_button" %>  <!-- helpers.comments.add_comment_label has as value Add note -->
    </div>

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

    <!-- add a note block -->
    <div id="add_comment_block_div_<%= answerid %>" style="display: none">
      <%= render :partial => "add_note", locals: {answer: answer, question: question, plan_id: plan.id }%>
    </div>

  <% else%>
    <%= _('Share note with collaborators')%>
    <%= render :partial => "add_note", locals: {answer: answer, question: question, plan_id: plan.id }%>
  <% end%>