From 9179060672974dae483928663dcbc9f6c2819972 Mon Sep 17 00:00:00 2001 From: alexdbondoc17 Date: Tue, 1 Mar 2022 02:20:26 +0000 Subject: [PATCH 1/2] Add back button to `subject_indexes#show` --- app/views/subject_indexes/show.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/subject_indexes/show.html.erb b/app/views/subject_indexes/show.html.erb index 4818332..c921df3 100644 --- a/app/views/subject_indexes/show.html.erb +++ b/app/views/subject_indexes/show.html.erb @@ -24,6 +24,7 @@
+ Edit <% if !@subject_index.has_children? %> From 9b63b2293eae212be3b76e0fe9a85d92fd32b4ac Mon Sep 17 00:00:00 2001 From: alexdbondoc17 Date: Tue, 1 Mar 2022 02:21:14 +0000 Subject: [PATCH 2/2] Add Component for `doctrines#index` --- app/components/doctrine_index_component.rb | 46 +++++++++++++++++++ .../doctrine_index_component.html.erb | 45 ++++++++++++++++++ app/views/doctrines/search.html.erb | 4 +- 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 app/components/doctrine_index_component.rb create mode 100644 app/components/doctrine_index_component/doctrine_index_component.html.erb diff --git a/app/components/doctrine_index_component.rb b/app/components/doctrine_index_component.rb new file mode 100644 index 0000000..60bfc60 --- /dev/null +++ b/app/components/doctrine_index_component.rb @@ -0,0 +1,46 @@ +class DoctrineIndexComponent < 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 :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 render? + doctrine.present? && doctrine.persisted? + end +end diff --git a/app/components/doctrine_index_component/doctrine_index_component.html.erb b/app/components/doctrine_index_component/doctrine_index_component.html.erb new file mode 100644 index 0000000..203832a --- /dev/null +++ b/app/components/doctrine_index_component/doctrine_index_component.html.erb @@ -0,0 +1,45 @@ + diff --git a/app/views/doctrines/search.html.erb b/app/views/doctrines/search.html.erb index 2ca4a61..54f2a62 100644 --- a/app/views/doctrines/search.html.erb +++ b/app/views/doctrines/search.html.erb @@ -3,9 +3,9 @@
<% if params[:is_index_table].to_s.eql?("true") %>
- <%= render(DoctrineIndexTableComponent.new(current_user: current_user, search_results: @doctrines)) %> + <%= render(DoctrineIndexTableComponent.new(current_user: current_user, search_results: @doctrines, opts: { is_index_table: params[:is_index_table].to_s.eql?("true") })) %>
<% else %> - <%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_doctrines_index: true, subject_ids: params[:subject_ids] })) %> + <%= render(DoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { subject_ids: params[:subject_ids] })) %> <% end %>