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 30c83a5..87f6037 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 @@ -11,6 +11,7 @@
<%= label_tag :annotation_marks %> <%= hidden_field_tag :annotation_id, nil, data: { target: "annotations.annotation_id" } %> + <%= hidden_field_tag :current_document_id, nil, data: { target: "annotations.current_document_id" } %> <%= hidden_field_tag :doctrine_id, nil, data: { target: "annotations.doctrine_id" } %> <%= hidden_field_tag :document_id, nil, data: { target: "annotations.document_id" } %> <%= hidden_field_tag :document_ids, nil, data: { target: "annotations.document_ids" } %> 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 bf9132e..0c6d2a4 100644 --- a/app/components/doctrine_index_component/doctrine_index_component.html.erb +++ b/app/components/doctrine_index_component/doctrine_index_component.html.erb @@ -1,13 +1,12 @@
+ <%= headnote %>
<% document_title = jurisprudence.short_title || jurisprudence.title %> <% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %> -

<%= headnote %>

- <% annotations.order(created_at: :desc).each do |annotation| %>
- <%= text_field_tag :title, params[:short_title], class: "form-control mb-0" %> + <%= text_field_tag :title, params[:title], class: "form-control mb-0" %>
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 f51bcdf..0d559d0 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,12 +14,11 @@ <% end %>
+ <%= headnote %>

<%= raw content.html_safe %>

-

<%= headnote %>

- <% if opts[:is_doctrines_index].present? %> <% document_title = jurisprudence.short_title || jurisprudence.title %> <% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %> 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 9ed4042..77d4821 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 @@ -56,7 +56,7 @@
-
+
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %>
@@ -88,8 +88,7 @@
Annotations
- <%= render(partial: "/shared/annotations_pagination", locals: { annotations: annotations, opts: { current_page: 1 } }) %> - <% annotations.order(created_at: :desc).each do |annotation| %> + <% doctrine.annotations.order(created_at: :desc).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 = [] %> @@ -111,9 +110,9 @@
diff --git a/app/controllers/api/doctrine/annotations_controller.rb b/app/controllers/api/doctrine/annotations_controller.rb index 7a542d6..654d3ab 100644 --- a/app/controllers/api/doctrine/annotations_controller.rb +++ b/app/controllers/api/doctrine/annotations_controller.rb @@ -54,10 +54,10 @@ module Api document_ids = params[:document_ids].split(",") if document_ids.present? - @documents = Cdao::Jurisprudence.where(id: document_ids) + @documents = Cdao::Document.where(id: document_ids) end - attrs[:document] = Cdao::Jurisprudence.find(document_id) if document_id.present? + attrs[:document] = Cdao::Document.find(document_id) if document_id.present? if @annotation.update(attrs) @annotation.annotation_documents.each do |annotation_document| diff --git a/app/javascript/controllers/annotations_controller.js b/app/javascript/controllers/annotations_controller.js index f395ca2..67f1156 100644 --- a/app/javascript/controllers/annotations_controller.js +++ b/app/javascript/controllers/annotations_controller.js @@ -1,6 +1,6 @@ import ApplicationController from './application_controller' export default class extends ApplicationController { - static targets = ["q", "annotation_id", "doctrine_id", "document_id", "document_ids", + static targets = ["q", "annotation_id", "doctrine_id", "document_id", "document_ids", "current_document_id", "annomark_ids", "phil_rep", "editor_notes"] connect () { @@ -19,13 +19,15 @@ export default class extends ApplicationController { var $this = this, annotation_id = $this.element.dataset["annotationId"], doctrine_id = $this.element.dataset["doctrineId"], document_title = "", document_ref_no = "", document_date_or_year = "", $modal = $("#annotationModal") + console.log($this.element.dataset["currentDocumentId"]) + $modal.find("#current_document_id").val($this.element.dataset["currentDocumentId"]) if(annotation_id !== null && annotation_id !== undefined && annotation_id !== "") { $modal.find(".modal-title").text("Edit Annotation") $.get("/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id + ".json", {}, function(result, status) { $modal.find("#annotation_id").val(annotation_id) $modal.find("#doctrine_id").val(doctrine_id) - $modal.find("#document_id").val(result.citing_document_ids) - $modal.find("#document_ids").val(result.document_id) + $modal.find("#document_id").val(result.document_id) + $modal.find("#document_ids").val(result.citing_document_ids) $modal.find("#phil_rep").val(result.phil_rep) $modal.find("#document_title").val($this.element.dataset["documentTitle"]) $modal.find("select[name='annomark_ids[]']")[0].selectize.setValue(result.annomark_ids) @@ -45,7 +47,7 @@ export default class extends ApplicationController { } addAnnotatedDocument () { - var document_id = "", document_ref_no = "", document_date = "", document_title = "", + var document_id = "", document_ref_no = "", document_date = "", document_title = "", $modal = $("#annotationModal"), $doc_title = $modal.find("#document_title"), $citing_document_ids = $modal.find("#document_ids") @@ -68,7 +70,8 @@ export default class extends ApplicationController { } save () { - var $this = this, $modal = $("#annotationModal"), annotation_id = $this.annotation_idTarget.value, doctrine_id = $this.doctrine_idTarget.value + var $this = this, $modal = $("#annotationModal"), annotation_id = $this.annotation_idTarget.value, + current_document_id = $this.current_document_idTarget.value, doctrine_id = $this.doctrine_idTarget.value const params = { annomark_ids: $modal.find("select[name='annomark_ids[]']").val(), document_id: $this.document_idTarget.value, document_ids: $this.document_idsTarget.value || "", phil_rep: $this.phil_repTarget.value || "", editor_notes: $this.editor_notesTarget.value || "" } @@ -79,23 +82,22 @@ export default class extends ApplicationController { type: 'PUT', data: params, success: function() { - $(".btn-close-x").trigger("click") - $this.stimulate("AnnotationReflex#render_annotations_views", { page: 1 }) + location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id } }) } else { $.post("/api/doctrines/" + doctrine_id + "/annotations", params, function(result, status) { if(status === "success") { $(".btn-close-x").trigger("click") - $this.stimulate("AnnotationReflex#render_annotations_views", { doctrine_id: doctrine_id, page: 1 }) - $this.stimulate("AnnotationReflex#render_default_case_lists_search", doctrine_id) + location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id } }) } } delete(ev) { - var $this = this, doctrine_id = $this.element.dataset["doctrineId"], annotation_id = this.element.dataset["annotationId"] + var $this = this, doctrine_id = $this.element.dataset["doctrineId"], annotation_id = this.element.dataset["annotationId"], + current_document_id = $this.element.dataset["currentDocumentId"] ev.preventDefault(); const contrim_alert = confirm("Are you sure to delete this record?") @@ -104,7 +106,7 @@ export default class extends ApplicationController { url: "/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id, type: 'DELETE', success: function() { - $this.stimulate("AnnotationReflex#render_annotations_views", { doctrine_id: doctrine_id, page: 1 }) + location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id } }) } diff --git a/app/javascript/controllers/document_controller.js b/app/javascript/controllers/document_controller.js index 9f4454c..4f819d7 100644 --- a/app/javascript/controllers/document_controller.js +++ b/app/javascript/controllers/document_controller.js @@ -9,7 +9,7 @@ export default class extends ApplicationController { search () { this.stimulate("DocumentReflex#render_case_lists_search_results", { q: this.inputTarget.value, citation_finder: this.element.dataset["citation_finder"], page: 1 }, - this.element.dataset["doctrineId"]) + this.element.dataset["doctrineId"], this.element.dataset["currentDocumentId"]) } paginate () { diff --git a/app/reflexes/document_reflex.rb b/app/reflexes/document_reflex.rb index 84e49f5..0ca3e82 100644 --- a/app/reflexes/document_reflex.rb +++ b/app/reflexes/document_reflex.rb @@ -3,10 +3,10 @@ class DocumentReflex < ApplicationReflex include DocumentSearch - def render_case_lists_search_results(search_params, doctrine_id) + def render_case_lists_search_results(search_params, doctrine_id, current_document_id) search = document_search(search_params.merge(sort_by: %i[reference_number_texts title_texts short_title_texts])) @documents = search.results - opts = { doctrine_id: doctrine_id, current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] } + opts = { doctrine_id: doctrine_id, current_document_id: current_document_id, current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] } morph "#caseListsCollapse", render(partial: "/shared/case_lists_search_results", locals: { documents: @documents, opts: opts }) end diff --git a/app/views/shared/_case_lists_search_results.html.erb b/app/views/shared/_case_lists_search_results.html.erb index 0aafd1e..9d5990f 100644 --- a/app/views/shared/_case_lists_search_results.html.erb +++ b/app/views/shared/_case_lists_search_results.html.erb @@ -1,4 +1,4 @@ -