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.
30 lines
701 B
30 lines
701 B
class AnnotationFormComponent < BaseComponent |
|
attr_reader :annotation, :opts |
|
|
|
def initialize(current_user:, annotation:, opts: {}) |
|
@annotation = annotation |
|
@opts = opts |
|
end |
|
|
|
def document |
|
return annotation.document if annotation.persisted? |
|
|
|
Cdao::Document.find(opts[:document_id].to_i) |
|
end |
|
|
|
def display_text |
|
return annotation.content if annotation.persisted? |
|
|
|
title = document.short_title || document.title |
|
year_or_date = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year |
|
|
|
[title, document.clean_reference_number, year_or_date].join(", ") |
|
end |
|
|
|
def phil_rep |
|
return annotation.phil_rep if annotation.persisted? |
|
|
|
document.phil_rep |
|
end |
|
end |
|
|