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