From 7b4d5481aeb1f665e693bd511372d8fdf92f4798 Mon Sep 17 00:00:00 2001 From: alexdbondoc17 Date: Mon, 7 Mar 2022 06:22:25 +0000 Subject: [PATCH] Enhance UI for `doctrines` and `annotations` --- .../doctrine_index_component.html.erb | 4 ++-- .../document_doctrine_index_component.html.erb | 4 ++-- .../document_doctrine_show_component.html.erb | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) 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 0c6d2a4..a6a0794 100644 --- a/app/components/doctrine_index_component/doctrine_index_component.html.erb +++ b/app/components/doctrine_index_component/doctrine_index_component.html.erb @@ -8,7 +8,7 @@ <% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %> - <% annotations.order(created_at: :desc).each do |annotation| %> + <% annotations.sort_by { |a| [a.document.library.rank, -a.document.year, -a.document.doc_date.strftime("%Y-%m-%d")] }.each do |annotation| %> <% if annotation.editor_notes.present? %> 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 0d559d0..ba7e5a7 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 @@ -25,7 +25,7 @@
<%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %>
<% end %> - <% annotations.order(created_at: :desc).each do |annotation| %> + <% annotations.sort_by { |a| [a.document.library.rank, -a.document.year, -a.document.doc_date.strftime('%Y-%m-%d')] }.each do |annotation| %>

<% annotated_documents_title = [] %> <% annotation.documents.each do |annotated_document| %> @@ -35,7 +35,7 @@ <% end %> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> - <%= raw [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), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %>

<% if annotation.editor_notes.present? %> 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 e87bacc..0a8c293 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 @@ -85,7 +85,7 @@
Annotations
- <% doctrine.annotations.order(created_at: :desc).each do |annotation| %> + <% annotations.sort_by { |a| [a.document.library.rank, -a.document.year, -a.document.doc_date.strftime("%Y-%m-%d")] }.each do |annotation| %> <% document_title = annotation.document.short_title || annotation.document.title %> <% date_or_year = annotation.document.docdate.present? ? annotation.document.docdate.strftime("%B %d, %Y") : annotation.document.year %> <% annotated_documents_title = [] %> @@ -100,14 +100,14 @@

<%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> - <%= raw citing_document_title %> + <%= raw annotation.content.present? ? annotation.content : citing_document_title %>