diff --git a/app/components/doctrine_index_component.rb b/app/components/doctrine_index_component.rb
index b466d8f..b8b9908 100644
--- a/app/components/doctrine_index_component.rb
+++ b/app/components/doctrine_index_component.rb
@@ -47,6 +47,12 @@ class DoctrineIndexComponent < BaseComponent
doctrine_path(id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?))
end
+ def clean_phil_rep(annotation)
+ return if annotation.phil_rep.blank?
+
+ annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
+ end
+
def render?
doctrine.present? && doctrine.persisted?
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
index a6a0794..fcf0e04 100644
--- a/app/components/doctrine_index_component/doctrine_index_component.html.erb
+++ b/app/components/doctrine_index_component/doctrine_index_component.html.erb
@@ -18,7 +18,7 @@
<% end %>
<%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %>
- <%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %>
+ <%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ') %>
<% if annotation.editor_notes.present? %>
diff --git a/app/components/document_doctrine_index_component.rb b/app/components/document_doctrine_index_component.rb
index 879a29a..e075d40 100644
--- a/app/components/document_doctrine_index_component.rb
+++ b/app/components/document_doctrine_index_component.rb
@@ -41,6 +41,12 @@ class DocumentDoctrineIndexComponent < BaseComponent
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 render?
doctrine.present? && doctrine.persisted?
end
diff --git a/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb b/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
index ba7e5a7..6888568 100644
--- a/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
+++ b/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
@@ -35,7 +35,7 @@
<% end %>
<%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %>
- <%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %>
+ <%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ') %>
<% if annotation.editor_notes.present? %>
diff --git a/app/components/document_doctrine_show_component.rb b/app/components/document_doctrine_show_component.rb
index 9808d52..82099e2 100644
--- a/app/components/document_doctrine_show_component.rb
+++ b/app/components/document_doctrine_show_component.rb
@@ -35,4 +35,10 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.document.year
end
+
+ def clean_phil_rep(annotation)
+ return if annotation.phil_rep.blank?
+
+ annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
+ end
end
\ No newline at end of file
diff --git a/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb b/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
index 0a8c293..c9657f8 100644
--- a/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
+++ b/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
@@ -94,7 +94,7 @@
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %>
<% end %>
- <% citing_document_title = [document_title, annotation.document.reference_number, date_or_year, annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
+ <% citing_document_title = [document_title, annotation.document.reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb
index 52e0926..8a9d514 100644
--- a/app/controllers/documents_controller.rb
+++ b/app/controllers/documents_controller.rb
@@ -1,5 +1,6 @@
class DocumentsController < ApplicationController
include JurisprudenceSearch
+ include DoctrineSearch
load_and_authorize_resource :document, class: "Cdao::Jurisprudence"
@@ -16,7 +17,7 @@ class DocumentsController < ApplicationController
def show
@subjects = Cdao::Subject.all
- @doctrines = @document.doctrines
+ @doctrines = @document.doctrines.sort_by { |doctrine| @doctrines.sort_by { |doctrine| [-doctrine.jurisprudences.first.year, -doctrine.jurisprudences.first.docdate] }
where = { enabled: true, state: "published" }
@cited_in_documents = @document.class.citing_docs_of(@document, where)
diff --git a/app/models/doctrine.rb b/app/models/doctrine.rb
index d3baf04..a2470a7 100644
--- a/app/models/doctrine.rb
+++ b/app/models/doctrine.rb
@@ -19,6 +19,10 @@ class Doctrine < ApplicationRecord
DoctrineSubject.where(doctrine_id: self.id)
end
+ def jurisprudences
+ Cdao::Jurisprudence.where(id: doctrine_jurisprudences.map(&:jurisprudence_id)).order(year: :desc, docdate: :desc)
+ end
+
def subjects
Cdao::Subject.where(id: doctrine_subjects.map(&:subject_id))
end
diff --git a/app/views/doctrines/search.html.erb b/app/views/doctrines/search.html.erb
index d3ae91b..1123ba8 100644
--- a/app/views/doctrines/search.html.erb
+++ b/app/views/doctrines/search.html.erb
@@ -6,6 +6,6 @@
<%= render(DoctrineIndexTableComponent.new(current_user: current_user, search_results: @doctrines, opts: { is_index_table: true, subject_ids: params[:subject_ids].map(&:to_i) })) %>
<% else %>
- <%= render(DoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_index_table: false, subject_ids: params[:subject_ids].map(&:to_i) })) %>
+ <%= render(DoctrineIndexComponent.with_collection(@doctrines.sort_by { |doctrine| [-doctrine.jurisprudences.first.year, -doctrine.jurisprudences.first.docdate.strftime("%Y-%m-%d")] }, current_user: current_user, opts: { is_index_table: false, subject_ids: params[:subject_ids].map(&:to_i) })) %>
<% end %>
diff --git a/app/views/documents/show.html.erb b/app/views/documents/show.html.erb
index dab52c2..aa78199 100644
--- a/app/views/documents/show.html.erb
+++ b/app/views/documents/show.html.erb
@@ -72,8 +72,8 @@
-
- <%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { document_id: @document.id })) %>
+
+ <%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines.sort_by { |doctrine| [-doctrine.doctrine_jurisprudences.first.jurisprudence.doc_date.strftime("%Y-%m-%d")] }, current_user: current_user, opts: { document_id: @document.id })) %>
diff --git a/app/views/shared/_annotated_documents_search_results.html.erb b/app/views/shared/_annotated_documents_search_results.html.erb
index b82d440..9f5cce4 100644
--- a/app/views/shared/_annotated_documents_search_results.html.erb
+++ b/app/views/shared/_annotated_documents_search_results.html.erb
@@ -81,11 +81,11 @@
| <%= document.clean_reference_number %> |
<%= document.short_title || document.title %> |
- <%= document.doc_date.present? ? document.doc_date : document.year %> |
+ <%= document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year %> |
"
data-document-title="<%= document.short_title || document.title %>"
data-action="click->annotations#addAnnotatedDocument" >
Add
diff --git a/app/views/shared/_case_lists_search_results.html.erb b/app/views/shared/_case_lists_search_results.html.erb
index 7d580a9..9534fb1 100644
--- a/app/views/shared/_case_lists_search_results.html.erb
+++ b/app/views/shared/_case_lists_search_results.html.erb
@@ -92,9 +92,9 @@
| <%= document.clean_reference_number %> |
<%= document.short_title || document.title %> |
- <%= document.doc_date.present? ? document.doc_date : document.year %> |
+ <%= document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year %> |
- <% date_or_year = document.doc_date || document.year %>
+ <% date_or_year = document.doc_date.strftime("%B %d, %Y") || document.year %>
<% title = document.short_title || document.title %>
+
+ ">
+
+ <%= page_entries_info doctrines, entry_name: 'records' if doctrines.present? %>
+
+
+ ">
+
+
+
+
diff --git a/app/views/shared/_document_doctrines_index.html.erb b/app/views/shared/_document_doctrines_index.html.erb
new file mode 100644
index 0000000..dbdde0e
--- /dev/null
+++ b/app/views/shared/_document_doctrines_index.html.erb
@@ -0,0 +1,4 @@
+
+ <%= render(partial: "/shared/doctrines_pagination", locals: { doctrines: doctrines, opts: opts }) %>
+ <%= render(DocumentDoctrineIndexComponent.with_collection(doctrines, current_user: current_user, opts: { document_id: opts[:document_id] })) %>
+
| |