You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

65 lines
1.7 KiB

class DoctrineIndexComponent < BaseComponent
attr_reader :search_results, :opts
include AnnotationSearch
include DoctrineSearch
def initialize(search_results:, current_user:, opts: {})
@search_results = search_results
@opts = opts
end
def annotation_form_url
doctrine_annotations_path(doctrine_id: id)
end
def subject_names
"(No Subjects Provided)"
end
def document_title(annotation)
return annotation.document.short_title if annotation.document.short_title.present?
annotation.document.title
end
def date_or_year(annotation)
return annotation.document.docdate.to_date.strftime("%B %d, %Y") if annotation.document.docdate.present?
annotation.document.year
end
def doctrine_show_url
return document_doctrine_path(jurisprudence.id, id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?)) if jurisprudence.present?
doctrine_path(id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?))
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def search_annotations(search_params)
search = annotation_search(search_params)
search.results
end
def content_diplay_text(annotation)
return annotation.content.gsub("<div>", "").gsub("</div>", "") if annotation.content.include?("Phil")
contents = annotation.content.gsub("<div>", "").gsub("</div>", "").split(" citing ")
contents[0] = [contents[0], clean_phil_rep(annotation)].reject(&:blank?).join(", ")
contents.join(" citing ")
end
def search_doctrines(search_params)
search = doctrine_search(search_params)
search
end
def render?
search_results.present?
end
end