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.
52 lines
1.5 KiB
52 lines
1.5 KiB
class DocumentDoctrineShowComponent < BaseComponent |
|
attr_reader :current_user, :annotations, :jurisprudence_id, :doctrine, :subjects |
|
|
|
def initialize(current_user:, annotations:, doctrine:, jurisprudence_id:, subjects:, opts: {}) |
|
@annotations = annotations |
|
@doctrine = doctrine |
|
@jurisprudence_id = jurisprudence_id |
|
@current_user = current_user |
|
@subjects = subjects |
|
@opts = opts |
|
end |
|
|
|
delegate :id, to: :doctrine |
|
delegate :headnote, to: :doctrine |
|
delegate :subject_ids, to: :doctrine |
|
delegate :content, to: :doctrine |
|
delegate :subjects, to: :doctrine |
|
|
|
def annotation_form_url |
|
doctrine_annotations_path(doctrine_id: id,) |
|
end |
|
|
|
def document_title(annotation) |
|
return annotation.document.short_title if annotation.document.short_title.present? |
|
|
|
annotation.document.title |
|
end |
|
|
|
def document |
|
Document.find(document_id) |
|
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 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 |
|
end |