diff --git a/app/components/doctrine_index_component.rb b/app/components/doctrine_index_component.rb index 2da5b0f..bd6aa0e 100644 --- a/app/components/doctrine_index_component.rb +++ b/app/components/doctrine_index_component.rb @@ -1,22 +1,14 @@ class DoctrineIndexComponent < BaseComponent - with_collection_parameter :doctrine - attr_reader :doctrine, :opts + attr_reader :search_results, :opts include AnnotationSearch + include DoctrineSearch - def initialize(doctrine:, current_user:, opts: {}) - @doctrine = doctrine + def initialize(search_results:, current_user:, opts: {}) + @search_results = search_results @opts = opts end - delegate :id, to: :doctrine - delegate :subject_ids, to: :doctrine - delegate :content, 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) end @@ -25,12 +17,6 @@ class DoctrineIndexComponent < BaseComponent "(No Subjects Provided)" end - def jurisprudence - return nil if doctrine_jurisprudences.blank? - - jurisprudences.first - end - def document_title(annotation) return annotation.document.short_title if annotation.document.short_title.present? @@ -55,8 +41,8 @@ class DoctrineIndexComponent < BaseComponent annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil") end - def annotations - search = annotation_search(doctrine_id: id) + def search_annotations(search_params) + search = annotation_search(search_params) search.results end @@ -68,7 +54,12 @@ class DoctrineIndexComponent < BaseComponent contents.join(" citing ") end + def search_doctrines(search_params) + search = doctrine_search(search_params) + search + end + def render? - doctrine.present? && doctrine.persisted? + search_results.present? end 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 8039be7..ac420b9 100644 --- a/app/components/doctrine_index_component/doctrine_index_component.html.erb +++ b/app/components/doctrine_index_component/doctrine_index_component.html.erb @@ -1,32 +1,56 @@ -