diff --git a/app/components/doctrine_index_component.rb b/app/components/doctrine_index_component.rb index b8b9908..50440b7 100644 --- a/app/components/doctrine_index_component.rb +++ b/app/components/doctrine_index_component.rb @@ -2,6 +2,8 @@ class DoctrineIndexComponent < BaseComponent with_collection_parameter :doctrine attr_reader :doctrine, :opts + include AnnotationSearch + def initialize(doctrine:, current_user:, opts: {}) @doctrine = doctrine @opts = opts @@ -10,10 +12,10 @@ class DoctrineIndexComponent < BaseComponent delegate :id, to: :doctrine delegate :subject_ids, to: :doctrine delegate :content, to: :doctrine - delegate :annotations, to: :doctrine delegate :subjects, to: :doctrine delegate :headnote, to: :doctrine delegate :doctrine_jurisprudences, to: :doctrine + delegate :jurisprudences, to: :doctrine def annotation_form_url doctrine_annotations_path(doctrine_id: id) @@ -26,7 +28,7 @@ class DoctrineIndexComponent < BaseComponent def jurisprudence return nil if doctrine_jurisprudences.blank? - doctrine_jurisprudences.first.jurisprudence + jurisprudences.first end def document_title(annotation) @@ -53,6 +55,11 @@ class DoctrineIndexComponent < BaseComponent annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil") end + def annotations + search = annotation_search(doctrine_id: id) + search.results + end + def render? doctrine.present? && doctrine.persisted? end diff --git a/app/components/doctrine_index_component/doctrine_index_component.html.erb b/app/components/doctrine_index_component/doctrine_index_component.html.erb index fcf0e04..db593ad 100644 --- a/app/components/doctrine_index_component/doctrine_index_component.html.erb +++ b/app/components/doctrine_index_component/doctrine_index_component.html.erb @@ -8,13 +8,13 @@ <% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %>
<% annotated_documents_title = [] %> <% annotation.documents.each do |annotated_document| %> <% ad_title = annotated_document.short_title || annotated_document.title %> <% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %> - <% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %> + <% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %> <% end %> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> diff --git a/app/components/document_doctrine_index_component.rb b/app/components/document_doctrine_index_component.rb index e075d40..0c40461 100644 --- a/app/components/document_doctrine_index_component.rb +++ b/app/components/document_doctrine_index_component.rb @@ -2,6 +2,8 @@ class DocumentDoctrineIndexComponent < BaseComponent with_collection_parameter :doctrine attr_reader :doctrine, :opts + include AnnotationSearch + def initialize(doctrine:, current_user:, opts: {}) @doctrine = doctrine @opts = opts @@ -10,7 +12,6 @@ class DocumentDoctrineIndexComponent < BaseComponent delegate :id, to: :doctrine delegate :subject_ids, to: :doctrine delegate :content, to: :doctrine - delegate :annotations, to: :doctrine delegate :subjects, to: :doctrine delegate :headnote, to: :doctrine delegate :doctrine_jurisprudences, to: :doctrine @@ -47,6 +48,11 @@ class DocumentDoctrineIndexComponent < BaseComponent annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil") end + def annotations + search = annotation_search(doctrine_id: id) + search.results + end + def render? doctrine.present? && doctrine.persisted? end diff --git a/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb b/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb index 2133a83..6c614c3 100644 --- a/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb +++ b/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb @@ -10,7 +10,7 @@
<% annotated_documents_title = [] %> <% annotation.documents.each do |annotated_document| %> diff --git a/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb b/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb index 3680319..f3b954f 100644 --- a/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb +++ b/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb @@ -6,7 +6,7 @@
@@ -85,7 +85,7 @@