Add context to annotation in index view

This commit is contained in:
Amaia Castro
2017-02-13 11:18:33 +01:00
parent 8e741a6b4f
commit 58b9135c71
2 changed files with 2 additions and 2 deletions

View File

@@ -35,7 +35,7 @@ class Legislation::Annotation < ActiveRecord::Base
selector_end = "/html/body/#{range_end}" selector_end = "/html/body/#{range_end}"
el_end = doc.at_xpath(selector_end) el_end = doc.at_xpath(selector_end)
remainder_el_start = el_start.text[0 .. range_start_offset-1] remainder_el_start = el_start.text[0 .. range_start_offset-1] unless range_start_offset.zero?
remainder_el_end = el_end.text[range_end_offset .. -1] remainder_el_end = el_end.text[range_end_offset .. -1]
self.context = "#{remainder_el_start}<span class=annotator-hl>#{quote}</span>#{remainder_el_end}" self.context = "#{remainder_el_start}<span class=annotator-hl>#{quote}</span>#{remainder_el_end}"

View File

@@ -20,7 +20,7 @@
<% end %> <% end %>
</span> </span>
<div class="comment-section"> <div class="comment-section">
<%= annotation.quote %> <%= annotation.context.try(:html_safe).presence || annotation.quote %>
</div> </div>
<%= link_to legislation_process_draft_version_annotation_path(@process, @draft_version, annotation) do %> <%= link_to legislation_process_draft_version_annotation_path(@process, @draft_version, annotation) do %>
<span class="icon-comments" aria-hidden="true"></span> <span><%= t('.comments_count', count: annotation.comments_count) %></span></a> <span class="icon-comments" aria-hidden="true"></span> <span><%= t('.comments_count', count: annotation.comments_count) %></span></a>