Add context to annotation in index view
This commit is contained in:
@@ -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}"
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user