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.
41 lines
1.1 KiB
41 lines
1.1 KiB
class DocumentDoctrineShowComponent < BaseComponent |
|
attr_reader :current_user, :doctrine, :subjects |
|
|
|
def initialize(current_user:, doctrine:, subjects:, opts: {}) |
|
@doctrine = doctrine |
|
@current_user = current_user |
|
@subjects = subjects |
|
end |
|
|
|
delegate :id, to: :doctrine |
|
delegate :subject_ids, to: :doctrine |
|
delegate :content, to: :doctrine |
|
delegate :document_id, to: :doctrine |
|
delegate :document, to: :doctrine |
|
delegate :annotations, to: :doctrine |
|
delegate :subjects, to: :doctrine |
|
|
|
def doctrine_form_url |
|
jurisprudence_doctrines_path(jurisprudence_id: document_id) |
|
end |
|
|
|
def edit_doctrine_form_url |
|
jurisprudence_doctrines_path(jurisprudence_id: document_id, id: id) |
|
end |
|
|
|
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 date_or_year(annotation) |
|
return annotation.document.docdate.to_date.strftime("%B %d, %Y") if annotation.document.docdate.present? |
|
|
|
annotation.document.year |
|
end |
|
end |