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.
53 lines
1.3 KiB
53 lines
1.3 KiB
class DocumentDoctrineIndexComponent < BaseComponent |
|
with_collection_parameter :doctrine |
|
attr_reader :doctrine, :opts |
|
|
|
def initialize(doctrine:, current_user:, opts: {}) |
|
@doctrine = doctrine |
|
@opts = opts |
|
end |
|
|
|
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 |
|
|
|
def annotation_form_url |
|
doctrine_annotations_path(doctrine_id: id) |
|
end |
|
|
|
def subject_names |
|
"(No Subjects Provided)" |
|
end |
|
|
|
def jurisprudence |
|
return nil if doctrine_jurisprudences.blank? |
|
|
|
doctrine_jurisprudences.first.jurisprudence |
|
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 clean_phil_rep(annotation) |
|
return if annotation.phil_rep.blank? |
|
|
|
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil") |
|
end |
|
|
|
def render? |
|
doctrine.present? && doctrine.persisted? |
|
end |
|
end
|
|
|