diff --git a/app/components/annotation_marks_modal_form_component.rb b/app/components/annotation_marks_modal_form_component.rb index ce2e379..f5d7efe 100644 --- a/app/components/annotation_marks_modal_form_component.rb +++ b/app/components/annotation_marks_modal_form_component.rb @@ -14,7 +14,8 @@ class AnnotationMarksModalFormComponent < BaseComponent end def document_title - [document.title, document.reference_number, document_date_or_year].reject(&:blank?).join(", ") + title = document.short_title || document.title + [title, document.reference_number, document_date_or_year].reject(&:blank?).join(", ") end def citing_documents_reference_numbers diff --git a/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb b/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb index 85e1f54..9c99070 100644 --- a/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb +++ b/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb @@ -48,8 +48,8 @@
-
- <%= label_tag :phil_rep %> +
+ <%= label_tag :annotation_marks %> <%= text_field_tag :phil_rep, annotation.phil_rep, class: "form-control" %>
diff --git a/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb b/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb index 38abe31..1c3687f 100644 --- a/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb +++ b/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb @@ -11,16 +11,18 @@
<%= label_tag :subjects %> - <%= select_tag "subject_ids[]", options_from_collection_for_select(subjects, :id, :lineage_name, doctrine.subject_ids), class: "form-select default-selectize", multiple: true, prompt: "Please select" %> + <%= select_tag "subject_ids[]", options_from_collection_for_select(subjects, :id, :lineage_name, doctrine.subject_ids), class: "form-select subject-ids-selectize", multiple: true, prompt: "Please select" %>
-
-
- <%= label_tag :doctine_content_suggestions %> - <%= select_tag :doctine_content_suggestions, options_from_collection_for_select(Doctrine.all, :content, :plain_content), class: "form-select", prompt: "Please select" %> + <% if doctrine.new_record? %> +
+
+ <%= label_tag :doctine_content_suggestions %> + +
-
+ <% 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 53c8f85..481b215 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 @@ -14,16 +14,29 @@

<%= raw content.html_safe %>

-
+
<% annotations.each do |annotation| %> -

+ <% if opts[:is_doctrines_index].present? %> + <% document_title = annotation.doctrine.document.short_title || annotation.doctrine.document.title %> + <% date_or_year = annotation.doctrine.document.docdate.present? ? annotation.doctrine.document.docdate.to_date.strftime("%B %d, %Y") : annotation.document.year %> + <%= [document_title, annotation.document.reference_number, date_or_year].join(", ") %> + <% end %> + +

+ <% annotated_documents_title = [] %> + <% annotation.documents.each do |annotated_document| %> + <% ad_title = annotated_document.short_title || annotated_document.title %> + <% 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 %> + <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> - <%= raw [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep].reject(&:blank?).join(', ') %> + <%= raw [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? %> -
-
+
+
Editors Note:
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 a1ecff6..bb7ee09 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 @@ -148,9 +148,21 @@ <% doctrine.annotations.order(rank: :asc).each do |annotation| %>
-

+ <% document_title = annotation.doctrine.document.short_title || annotation.doctrine.document.title %> + <% date_or_year = annotation.doctrine.document.docdate.present? ? annotation.doctrine.document.docdate.to_date.strftime("%B %d, %Y") : annotation.document.year %> + <%= [document_title, annotation.document.reference_number, date_or_year].join(", ") %> + +

<%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> - <%= raw [annotation.document.title, annotation.document.reference_number, annotation.document.docdate.strftime("%B %d, %Y"), annotation.phil_rep].reject(&:blank?).join(', ').html_safe %> + <% 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 = [] %> + <% annotation.documents.each do |annotated_document| %> + <% ad_title = annotated_document.short_title || annotated_document.title %> + <% 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 %> + <%= raw [document_title, annotation.document.reference_number, date_or_year, annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ').html_safe %>

diff --git a/app/components/pagination_component.rb b/app/components/pagination_component.rb index 5dffaeb..61d33ee 100644 --- a/app/components/pagination_component.rb +++ b/app/components/pagination_component.rb @@ -1,5 +1,13 @@ class PaginationComponent < BaseComponent - def initialize(data:) + attr_reader :data, :opts + def initialize(data:, opts: {}) @data = data + @opts = opts + end + + def subjects + return [] if opts[:subject_ids].blank? + + Cdao::Subject.where(id: opts[:subject_ids].map(&:to_i)) end end diff --git a/app/components/pagination_component/pagination_component.html.erb b/app/components/pagination_component/pagination_component.html.erb index a6d0775..1625876 100644 --- a/app/components/pagination_component/pagination_component.html.erb +++ b/app/components/pagination_component/pagination_component.html.erb @@ -1,15 +1,31 @@
-
-

Search Results

- - <%= page_entries_info @data, entry_name: 'records' if @data.present? %> - +
+ <% if opts[:is_subject_breadcrums].present? && subjects.present? %> + + <% else %> +

Search Results

+ + <%= page_entries_info data, entry_name: 'records' if data.present? %> + + <% end %>
-
+
diff --git a/app/components/subject_accordion_component/subject_accordion_component.html.erb b/app/components/subject_accordion_component/subject_accordion_component.html.erb index 047c6af..e51103b 100644 --- a/app/components/subject_accordion_component/subject_accordion_component.html.erb +++ b/app/components/subject_accordion_component/subject_accordion_component.html.erb @@ -5,11 +5,11 @@ <% if sub1.children.present? %> <% else %> <%= link_to sub1.name, subject_index_path(sub1.id), class: "accordion-link text-decoration-none text-dark d-block sub2 clickable-link" %> - <%= link_to "Add Sub Subject", new_subject_index_path(parent_id: sub1.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %> + <%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub1.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %> <% end %>
@@ -22,11 +22,11 @@ <% if sub1.children.present? %> <% else %> <%= link_to sub2.name, subject_index_path(sub2.id), class: "accordion-link text-decoration-none text-dark d-block sub3 clickable-link" %> - <%= link_to "Add Sub Subject", new_subject_index_path(parent_id: sub2.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %> + <%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub2.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %> <% end %>
@@ -39,11 +39,11 @@ <% if sub3.children.present? %> <% else %> <%= link_to sub3.name, subject_index_path(sub3.id), class: "accordion-link text-decoration-none text-dark d-block sub4 clickable-link" %> - <%= link_to "Add Sub Subject", new_subject_index_path(parent_id: sub3.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %> + <%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub3.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %> <% end %>
@@ -54,7 +54,7 @@
<%= link_to sub4.name, subject_index_path(sub4.id), class: "accordion-link text-decoration-none text-dark d-block sub5 clickable-link" %> - <%= link_to "Add Sub Subject", new_subject_index_path(parent_id: sub4.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %> + <%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub4.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %>
diff --git a/app/controllers/doctrine/annotations_controller.rb b/app/controllers/doctrine/annotations_controller.rb index 391540e..cd1ad5b 100644 --- a/app/controllers/doctrine/annotations_controller.rb +++ b/app/controllers/doctrine/annotations_controller.rb @@ -47,9 +47,8 @@ class Doctrine::AnnotationsController < ApplicationController @annotation.remove_document(annotation_document.document) end - @documents.each do |document| - @annotation.add_document(document) - end + @documents.each { |document| @annotation.add_document(document) } if @documents.present? + format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine), notice: "Doctrine Annotation was successfully updated." } else diff --git a/app/javascript/controllers/application_controller.js b/app/javascript/controllers/application_controller.js index aa2eac9..9a073a7 100644 --- a/app/javascript/controllers/application_controller.js +++ b/app/javascript/controllers/application_controller.js @@ -5,8 +5,8 @@ import $ from 'jquery'; require("select2/dist/css/select2") require("select2-bootstrap-theme/dist/select2-bootstrap") -require("selectize/dist/js/selectize.min") -require("selectize/dist/css/selectize") +require("selectize.js/dist/js/selectize.min") +require("selectize.js/dist/css/selectize") import Select2 from "select2" import Selectize from "selectize"; diff --git a/app/javascript/controllers/document_controller.js b/app/javascript/controllers/document_controller.js index 5bdd1c0..9fc6119 100644 --- a/app/javascript/controllers/document_controller.js +++ b/app/javascript/controllers/document_controller.js @@ -36,15 +36,17 @@ export default class extends ApplicationController { } loadFormDocumentDetais () { - var document_id = "", document_title = "", document_ref_no = "", document_date_or_year = "", $modal = $("#newAnnotationModal") + var document_id = "", document_title = "", document_ref_no = "", document_date_or_year = "", document_phil_rep = "", $modal = $("#newAnnotationModal") document_id = this.element.dataset["documentId"] document_title = this.element.dataset["documentTitle"] document_ref_no = this.element.dataset["documentReferenceNumber"] document_date_or_year = this.element.dataset["documentDateOrYear"] + document_phil_rep = this.element.dataset["documentPhilRep"] $modal.find("#document_title").val([document_title, document_ref_no, document_date_or_year].join(", ")) $modal.find("#document_id").val(document_id) + $modal.find("#phil_rep").val(document_phil_rep) } addCitingDocument () { @@ -52,6 +54,8 @@ export default class extends ApplicationController { document_id = this.element.dataset["documentId"] document_ref_no = this.element.dataset["documentReferenceNumber"] + document_date = this.element.dataset["documentDate"] + document_title = this.element.dataset["documentTitle"] var document_ids = [] @@ -68,6 +72,6 @@ export default class extends ApplicationController { var doc_title = $doc_title.val() - $doc_title.val(doc_title + " citing " + document_ref_no) + $doc_title.val(doc_title + " citing " + [document_title, document_ref_no, document_date].join(", ")) } } diff --git a/app/javascript/controllers/selectize_controller.js b/app/javascript/controllers/selectize_controller.js index f147161..cdbdfd1 100644 --- a/app/javascript/controllers/selectize_controller.js +++ b/app/javascript/controllers/selectize_controller.js @@ -3,6 +3,7 @@ import ApplicationController from './application_controller' export default class extends ApplicationController { connect() { super.connect() + var $this = this var default_opts = { plugins: ['restore_on_backspace', 'remove_button'], @@ -26,12 +27,40 @@ export default class extends ApplicationController { $doctrine_content.val("") $trix_content.val("") } else { - $doctrine_content.val(value) + $doctrine_content.val(value.text()) $trix_content.val(value) } } }; + var subject_ids_opts = { + onChange: function (value) { + console.log(value) + var selectize_options = [] + var $selectize = $("#doctrineModal").find("#doctine_content_suggestions").selectize($.extend({ options: selectize_options }, doctrine_content_suggestions_opts)) + + if (value.length === 0) { + console.log("Here!!!") + $selectize[0].selectize.clearOptions(); + } else { + $.get("/api/doctrines.json", { subject_ids: value }, function(data, status) { + if (status === "success") { + $.each(data, function (i, doctrine) { + selectize_options.push({ id: doctrine.id, value: doctrine.content, text: doctrine.plain_content }) + }) + + $selectize[0].selectize.addOption(selectize_options) + } + }); + } + + $selectize[0].selectize.refreshOptions() + + console.log(selectize_options) + } + }; + + $(".subject-ids-selectize").selectize($.extend(subject_ids_opts, default_opts)) $("#doctine_content_suggestions").selectize($.extend(doctrine_content_suggestions_opts, default_opts)) } } diff --git a/app/views/doctrines/search.html.erb b/app/views/doctrines/search.html.erb index 8c71a3f..f1be41e 100644 --- a/app/views/doctrines/search.html.erb +++ b/app/views/doctrines/search.html.erb @@ -1,5 +1,5 @@
-
<%= render PaginationComponent.new(data: @doctrines) %>
+
<%= render PaginationComponent.new(data: @doctrines, opts: { is_subject_breadcrums: true, subject_ids: params[:subject_ids] }) %>
<% if params[:is_index_table].to_s.eql?("true") %>
diff --git a/app/views/document/doctrines/_document_search_results_table.html.erb b/app/views/document/doctrines/_document_search_results_table.html.erb index 252f0d7..ee4c564 100644 --- a/app/views/document/doctrines/_document_search_results_table.html.erb +++ b/app/views/document/doctrines/_document_search_results_table.html.erb @@ -10,8 +10,9 @@ <% title = search_result["short_title"].present? ? search_result["short_title"] : search_result["title"] %> " data-document-reference-number="<%= search_result["reference_number"] %>" - data-document-date-or-year="<%= date_or_year %>" data-action="click->document#loadFormDocumentDetais"> - Add Annotations + data-document-date-or-year="<%= date_or_year %>" data-document-phil-rep="<%= search_result["phil_rep"] %>" + data-action="click->document#loadFormDocumentDetais"> + Add Annotations <% end %> @@ -19,7 +20,9 @@ <% if opts[:is_citing_document].present? %> " - data-document-reference-number="<%= search_result["reference_number"] %>"> + data-document-reference-number="<%= search_result["reference_number"] %>" + data-document-date="<%= search_result["docdate"].present? ? search_result["docdate"].to_date.strftime("%B %d, %Y") : search_result["year"] %>" + data-document-title="<%= search_result["short_title"] || search_result["title"] %>"> Add diff --git a/app/views/documents/index.html.erb b/app/views/documents/index.html.erb index 08bfaff..b90e4ea 100644 --- a/app/views/documents/index.html.erb +++ b/app/views/documents/index.html.erb @@ -22,13 +22,7 @@ diff --git a/app/views/subject_indexes/show.html.erb b/app/views/subject_indexes/show.html.erb index 67abd45..1cb51d7 100644 --- a/app/views/subject_indexes/show.html.erb +++ b/app/views/subject_indexes/show.html.erb @@ -1,30 +1,39 @@
-

Subject Details

+
+ <% if @subject_index.is_root? %> + + <% else %> + + <% end %> +
+ +
- - - - - - - - - -
Name: <%= @subject_index.name %> Parent Subject: <%= @subject_index.is_root? ? "N/A" : @subject_index.parent.lineage_name %>
-
-

Sub Subjects

+

Sub Levels