AyuntamientoMadrid/participacion

View on GitHub
app/views/legislation/annotations/_comments_box.html.erb

Summary

Maintainability
Test Coverage
<div class="comment-box" id="comments-box-<%= annotation.id %>" data-id="<%= annotation.id %>">
  <div class="comment-header">
    <%= render "comment_header", annotation: annotation %>
  </div>
  <div class="comments-wrapper">
    <div id="comments">
      <%= render "comments", annotation: annotation %>
    </div>
  </div>

  <div class="comment-footer">
    <% if annotation.comments.roots.count > Legislation::Annotation::COMMENTS_PAGE_SIZE %>
      <%= link_to legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation), class: "button" do %>
          <strong><%= t("legislation.annotations.comments.see_all") %></strong>
      <% end %>
    <% end %>

    <% if @process.allegations_phase.open? %>
      <% if user_signed_in? %>
        <a class="button publish-comment" href="#"><strong><%= t("legislation.annotations.comments.publish_comment") %></strong></a>
        &nbsp;
        <% css_id = parent_or_commentable_dom_id(nil, annotation) %>
        <div id="js-comment-form-annotation-<%= annotation.id %>" style="display:none" class="comment-form js-comment-form-annotation">
          <%= form_for @comment, url: legislation_process_draft_version_annotation_new_comment_path(annotation.draft_version.process, annotation.draft_version, annotation), remote: true do |f| %>
            <%= f.text_area :body,
                            id: "comment-body-#{css_id}",
                            maxlength: Comment.body_max_length,
                            label: leave_comment_text(annotation),
                            rows: 8 %>
            <%= f.submit comment_button_text(nil, annotation), class: "button" %>
          <% end %>
        </div>
      <% else %>
        <%= render "shared/login_to_comment" %>
      <% end %>
    <% end %>
  </div>
</div>