- <% annotations.sort_by { |a| [a.document.library.rank, -a.document.year, -a.document.doc_date.strftime("%Y-%m-%d")] }.each do |annotation| %>
+ <% doctrine.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 = [] %>
diff --git a/app/javascript/controllers/doctrines_controller.js b/app/javascript/controllers/doctrines_controller.js
index 3cc0afe..42d4de3 100644
--- a/app/javascript/controllers/doctrines_controller.js
+++ b/app/javascript/controllers/doctrines_controller.js
@@ -49,9 +49,9 @@ export default class extends ApplicationController {
}
save () {
- var $modal = $("#doctrineModal"), document_id = this.document_idTarget.value, doctrine_id = this.doctrine_idTarget.value
- var params = { subject_ids: $modal.find("select[name='subject_ids[]']").val(), headnote: this.headnoteTarget.value,
- content: this.contentTarget.value }
+ var $this = this, $modal = $("#doctrineModal"), document_id = $this.document_idTarget.value, doctrine_id = $this.doctrine_idTarget.value
+ var params = { subject_ids: $modal.find("select[name='subject_ids[]']").val(), headnote: $this.headnoteTarget.value,
+ content: $this.contentTarget.value }
if (!params.subject_ids.length) {
@@ -73,28 +73,36 @@ export default class extends ApplicationController {
type: 'PUT',
data: params,
success: function() {
- $(".btn-close-x").trigger("click")
- $('.toast').addClass('bg-success').show()
- $( ".toast-body" ).html( "
Submitted Successfully" ),
+ $(".btn-close-x").trigger("click");
+ $('.toast').addClass('bg-success').show();
+ $( ".toast-body" ).html( "
Submitted Successfully" );
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine_id
},
error: function() {
- $(".btn-close-x").trigger("click"),
- $('.toast').addClass('bg-danger').show(),
- $( ".toast-body" ).html( "
Unexpected Error Problem Occurred" )
+ $(".btn-close-x").trigger("click");
+ $('.toast').addClass('bg-danger').show();
+ $( ".toast-body" ).html( "
Unexpected Error Problem Occurred" );
}
})
} else {
$.post("/api/doctrines", $.extend({ jurisprudence_ids: [document_id] }, params), function(data, status) {
if(status === 'success') {
- $(".btn-close-x").trigger("click")
- $('.toast').addClass('bg-success').show()
- $( ".toast-body" ).html( "
Submitted Successfully" ),
- location.pathname = "/documents/" + document_id + "/doctrines/" + data.id
- }else {
- $(".btn-close-x").trigger("click"),
- $('.toast').addClass('bg-danger').show(),
- $( ".toast-body" ).html( "
Unexpected Error Problem Occurred" )
+ $('.toast').addClass('bg-success').show();
+ $( ".toast-body" ).html( "
Submitted Successfully" );
+
+ const contrim_alert = confirm("Do you want to create an Annotation?")
+
+ if (contrim_alert) {
+ $this.stimulate("DoctrinesReflex#render_annotation_modal_form", document_id, data.id)
+ $('.toast').fadeOut(5000)
+ } else {
+ $(".btn-close-x").trigger("click")
+ location.pathname = "/documents/" + document_id + "/doctrines/" + data.id
+ }
+ } else {
+ $(".btn-close-x").trigger("click");
+ $('.toast').addClass('bg-danger').show();
+ $( ".toast-body" ).html( "
Unexpected Error Problem Occurred" );
}
})
}
@@ -111,11 +119,43 @@ export default class extends ApplicationController {
url: "/api/doctrines/" + doctrine_id,
type: 'DELETE',
success: function() {
- location.pathname = "/documents/" + document_id
- $('.toast').addClass('bg-danger').show()
+ $('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "
Deleted Successfully" );
+ location.pathname = "/documents/" + document_id
+ },
+ error: function () {
+ $('.toast').addClass('bg-danger').show();
+ $( ".toast-body" ).html( "
Unexpected Error Problem Occurred" );
}
})
}
}
+
+ saveAnnotation () {
+ var $modal = $("#doctrineModal")
+ const params = { doctrine_id: $modal.find("#doctrine_id").val(), document_id: $modal.find("#document_id").val(),
+ document_ids: $modal.find("#document_ids").val().split(","), content: $modal.find("#document_title").val(),
+ phil_rep: $modal.find("#phil_rep").val(), editor_notes: $modal.find("#editor_notes").val(),
+ annomark_ids: $modal.find("select[name='annomark_ids[]']").val() }
+
+ $.post("/api/doctrines/" + params.doctrine_id + "/annotations", params, function (result, status) {
+ if(status === "success") {
+ $(".btn-close-x").trigger("click");
+ $('.toast').addClass('bg-success').show();
+ $( ".toast-body" ).html( "
Submitted Successfully" );
+ location.pathname = "/documents/" + $modal.find("#current_document_id").val() + "/doctrines/" + params.doctrine_id
+ } else {
+ $(".btn-close-x").trigger("click")
+ $('.toast').addClass('bg-danger').show()
+ $( ".toast-body" ).html( "
Unexpected Error Problem Occurred" )
+ }
+ })
+ }
+
+ closeDoctrineAnnotationModalForm () {
+ var $current_document_id = $("#doctrineModal").find("#current_document_id").val()
+ var $doctrine_id = $("#doctrineModal").find("#doctrine_id").val()
+ $(".btn-close-x").trigger("click");
+ location.pathname = "/documents/" + $current_document_id + "/doctrines/" + $doctrine_id
+ }
}
diff --git a/app/models/cdao/document.rb b/app/models/cdao/document.rb
index 29bcd6c..893dd02 100644
--- a/app/models/cdao/document.rb
+++ b/app/models/cdao/document.rb
@@ -13,6 +13,15 @@ class Cdao::Document < Cdao::Base
def clean_reference_number
(reference_number.presence || "").gsub(//, "")
end
+
+ def doc_date_display
+ doc_date.present? ? doc_date.strftime("%B %d, %Y") : year
+ end
+
+ def display_text
+ title_display = short_title || title
+ [title_display, clean_reference_number, doc_date_display].join(", ")
+ end
def libraries
Cdao::DocumentLibrary.where(library_product_type: doc_type, library_product_id: doc_id).map(&:library)
diff --git a/app/reflexes/doctrines_reflex.rb b/app/reflexes/doctrines_reflex.rb
new file mode 100644
index 0000000..46ad6dc
--- /dev/null
+++ b/app/reflexes/doctrines_reflex.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class DoctrinesReflex < ApplicationReflex
+ include DoctrineSearch
+
+ def render_document_doctrines_index(search_params)
+ search = doctrine_search(search_params)
+ morph "#doctrinesIndexView", render(partial: "/shared/document_doctrines_index", locals: { doctrines: search.results, current_user: current_user, opts: { document_id: search_params[:jurisprudence_id], current_page: search_params[:page] } })
+ end
+
+ def render_annotation_modal_form(document_id, doctrine_id)
+ jurisprudence = Cdao::Jurisprudence.find(document_id)
+ document = Cdao::Document.where(reference_number: jurisprudence.reference_number).first
+ morph "#doctrineModal", render(partial: "/shared/annotation_modal_form", locals: { document: document, doctrine_id: doctrine_id, jurisprudence: jurisprudence })
+ end
+end
diff --git a/app/views/shared/_annotation_modal_form.html.erb b/app/views/shared/_annotation_modal_form.html.erb
index d8150fc..d233e79 100644
--- a/app/views/shared/_annotation_modal_form.html.erb
+++ b/app/views/shared/_annotation_modal_form.html.erb
@@ -1 +1,72 @@
-<%= render AnnotationMarksModalFormComponent.new(current_user: current_user, opts: { is_show: true }) %>
+