<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %>
@@ -92,24 +92,19 @@
<% 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(", ") %>
+ <% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% end %>
- <% citing_document_title = [document_title, annotation.document.reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
-
-
-
-
- <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %>
- <%= raw annotation.content.present? ? annotation.content : citing_document_title %>
-
-
+ <% citing_document_title = [document_title, annotation.document.clean_reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
+
+
+
<%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %>
+
<%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %>
diff --git a/app/controllers/api/doctrine/annotations_controller.rb b/app/controllers/api/doctrine/annotations_controller.rb
index 80bd7f3..de9860f 100644
--- a/app/controllers/api/doctrine/annotations_controller.rb
+++ b/app/controllers/api/doctrine/annotations_controller.rb
@@ -42,8 +42,8 @@ module Api
if @annotation.save
@documents.each { |document| @annotation.add_document(document) } if @documents.present?
- @annotation.index!
respond_with @annotation
+ @annotation.index!
else
render errors: @annotation.errors, status: 422
end
@@ -67,8 +67,8 @@ module Api
@documents.each { |document| @annotation.add_document(document) } if @documents.present?
- @annotation.index!
respond_with @annotation
+ @annotation.index!
else
render errors: @annotation.errors, status: 422
end
diff --git a/app/controllers/doctrine/annotations_controller.rb b/app/controllers/doctrine/annotations_controller.rb
index 652e190..0bd3ddc 100644
--- a/app/controllers/doctrine/annotations_controller.rb
+++ b/app/controllers/doctrine/annotations_controller.rb
@@ -2,6 +2,10 @@ class Doctrine::AnnotationsController < ApplicationController
load_and_authorize_resource :doctrine, class: "Doctrine"
load_and_authorize_resource :annotation, class: "Annotation", through: :doctrine
+ def new; end
+
+ def edit; end
+
def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
document_id = attrs.delete(:document_id)
diff --git a/app/javascript/controllers/annotations_controller.js b/app/javascript/controllers/annotations_controller.js
index f98452b..3aad0aa 100644
--- a/app/javascript/controllers/annotations_controller.js
+++ b/app/javascript/controllers/annotations_controller.js
@@ -1,7 +1,6 @@
import ApplicationController from './application_controller'
export default class extends ApplicationController {
- static targets = ["q", "annotation_id", "doctrine_id", "document_id", "document_ids", "current_document_id",
- "annomark_ids", "phil_rep", "editor_notes"]
+ static targets = ["q", "document_ids", "annomark_ids", "phil_rep", "editor_notes"]
connect () {
super.connect()
@@ -47,8 +46,8 @@ export default class extends ApplicationController {
addAnnotatedDocument () {
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")
+ $form = $("#annotationForm"), $doc_title = $form.find("trix-editor[placeholder='Document Title']"),
+ $citing_document_ids = $form.find("#document_ids")
document_id = this.element.dataset["documentId"]
document_ref_no = this.element.dataset["documentReferenceNumber"]
@@ -69,11 +68,11 @@ export default class extends ApplicationController {
}
save () {
- 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,
+ var $this = this, $form = $("#annotationForm"), annotation_id = $this.element.dataset["annotationId"],
+ jurisprudence_id = $this.element.dataset["jurisprudenceId"], doctrine_id = $this.element.dataset["doctrineId"]
+ const params = { annomark_ids: $form.find("select[name='annomark_ids[]']").val(), document_id: $this.element.dataset["documentId"],
document_ids: $this.document_idsTarget.value || "", phil_rep: $this.phil_repTarget.value || "",
- editor_notes: $this.editor_notesTarget.value || "", content: $modal.find("#document_title").val() }
+ editor_notes: $this.editor_notesTarget.value || "", content: $form.find("input[name='content']").val() }
if (annotation_id !== null && annotation_id !== undefined && annotation_id !== "") {
$.ajax({
@@ -82,23 +81,27 @@ export default class extends ApplicationController {
data: params,
success: function() {
$(".btn-close-x").trigger("click")
- $('.toast').addClass('bg-success').show()
- $( ".toast-body" ).html( "
Submitted Successfully" ),
- location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id
+ $('.toast').addClass('bg-success').show();
+ $( ".toast-body" ).html( "
Submitted Successfully" );
+ location.pathname = "/documents/" + jurisprudence_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/" + 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/" + current_document_id + "/doctrines/" + doctrine_id
+ $(".btn-close-x").trigger("click");
+ $('.toast').addClass('bg-success').show();
+ $( ".toast-body" ).html( "
Submitted Successfully" );
+ location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id
+ } else {
+ $(".btn-close-x").trigger("click");
+ $('.toast').addClass('bg-danger').show();
+ $( ".toast-body" ).html( "
Unexpected Error Problem Occurred" );
}
})
}
@@ -106,7 +109,7 @@ export default class extends ApplicationController {
delete(ev) {
var $this = this, doctrine_id = $this.element.dataset["doctrineId"], annotation_id = this.element.dataset["annotationId"],
- current_document_id = $this.element.dataset["currentDocumentId"]
+ jurisprudence_id = $this.element.dataset["jurisprudenceId"]
ev.preventDefault();
const contrim_alert = confirm("Are you sure to delete this record?")
@@ -115,9 +118,9 @@ export default class extends ApplicationController {
url: "/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id,
type: 'DELETE',
success: function() {
- $('.toast').addClass('bg-danger').show()
- $( ".toast-body" ).html( "
Deleted Successfully" )
- location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id
+ $('.toast').addClass('bg-danger').show();
+ $( ".toast-body" ).html( "
Deleted Successfully" );
+ location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id
}
})
}
diff --git a/app/javascript/controllers/doctrines_controller.js b/app/javascript/controllers/doctrines_controller.js
index 205ecdb..39af2e0 100644
--- a/app/javascript/controllers/doctrines_controller.js
+++ b/app/javascript/controllers/doctrines_controller.js
@@ -76,11 +76,13 @@ export default class extends ApplicationController {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "
Submitted Successfully" );
+ $('.toast').fadeOut(5000);
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine_id
},
error: function() {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-danger').show();
+ $('.toast').fadeOut(5000);
$( ".toast-body" ).html( "
Unexpected Error Problem Occurred" );
}
})
@@ -99,7 +101,7 @@ export default class extends ApplicationController {
$( ".toast-body" ).html( "
Case Lists was successfully save" );
$('.toast').fadeOut(5000);
- if ((index + 1) === annotations_attributes.length) {
+ if (index === annotations_attributes.length - 1) {
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine.id
}
}
@@ -117,7 +119,7 @@ export default class extends ApplicationController {
}
delete(ev) {
- var doctrine_id = this.element.dataset["doctrineId"], document_id = this.element.dataset["documentId"]
+ var doctrine_id = this.element.dataset["doctrineId"], jurisprudence_id = this.element.dataset["jurisprudenceId"]
ev.preventDefault();
const contrim_alert = confirm("Are you sure to delete this record?")
@@ -129,7 +131,7 @@ export default class extends ApplicationController {
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "
Deleted Successfully" );
$('.toast').fadeOut(5000);
- location.pathname = "/documents/" + document_id
+ location.pathname = "/documents/" + jurisprudence_id
},
error: function () {
$('.toast').addClass('bg-danger').show();
@@ -190,7 +192,8 @@ export default class extends ApplicationController {
content: $modal.find("input[name='document_title']").val(), phil_rep: $modal.find("#phil_rep").val(),
editor_notes: $modal.find("input[name='editor_notes']").val(), annomark_ids: $modal.find("select[name='annomark_ids[]']").val() }
- if (annotaitons_attributes_index.length) {
+ console.log(annotaitons_attributes_index.length)
+ if (annotaitons_attributes_index.length > 0) {
annotations_attributes.splice(annotaitons_attributes_index, 1, params)
$( ".toast-body" ).html( "
Case List is successfully updated." );
} else {
@@ -201,6 +204,7 @@ export default class extends ApplicationController {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show();
$('.toast').fadeOut(5000);
+ $modal.find("select[name='annomark_ids[]']")[0].selectize.setValue([])
this.stimulate("DoctrinesReflex#render_doctrine_form_annotations_view", annotations_attributes)
this.stimulate("DoctrinesReflex#render_default_citing_documents")
this.stimulate("DoctrinesReflex#render_default_case_lists")
@@ -227,10 +231,10 @@ export default class extends ApplicationController {
$modal.find(".modal-title").text("Edit Annotation")
- $modal.find("select[name='annomark_ids[]']").val(annotation.annomark_ids)
+ $modal.find("select[name='annomark_ids[]']")[0].selectize.setValue(annotation.annomark_ids)
$modal.find("trix-editor[placeholder='Document Title']").val(annotation.content)
$modal.find("#document_id").val(annotation.document_id)
- $modal.find("#annotaitons_attributes_index").val(annotations_attributes_index)
+ $modal.find("#annotaitons_attributes_index")[0].selectize.setValue(annotations_attributes_index)
if (annotation.document_ids.length) {
$modal.find("#document_ids").val(annotation.document_ids.join(","))
diff --git a/app/javascript/controllers/document_controller.js b/app/javascript/controllers/document_controller.js
index d9e49e9..7691ee0 100644
--- a/app/javascript/controllers/document_controller.js
+++ b/app/javascript/controllers/document_controller.js
@@ -7,28 +7,28 @@ export default class extends ApplicationController {
}
search () {
+ console.log(this.element.dataset)
this.stimulate("DocumentReflex#render_case_lists_search_results",
{ q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 },
- this.element.dataset["doctrineId"], this.element.dataset["currentDocumentId"])
+ this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"])
}
searchDoctrineFormCaseLists () {
this.stimulate("DocumentReflex#render_doctrine_form_case_lists",
- { q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 },
- this.element.dataset["jurisprudenceId"])
+ { q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 })
}
paginateDoctrineFormCaseLists () {
this.stimulate("DocumentReflex#render_doctrine_form_case_lists",
- { q: this.element.dataset["q"], citation_finder: this.element.dataset["citation_finder"],
- page: this.element.dataset["page"] }, this.element.dataset["jurisprudenceId"])
+ { q: this.element.dataset["q"], citation_finder: this.element.dataset["citationFinder"],
+ page: this.element.dataset["page"] })
}
paginate () {
this.stimulate("DocumentReflex#render_case_lists_search_results",
- { q: this.element.dataset["q"], citation_finder: this.element.dataset["citation_finder"],
+ { q: this.element.dataset["q"], citation_finder: this.element.dataset["citationFinder"],
page: this.element.dataset["page"] },
- this.element.dataset["doctrineId"])
+ this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"])
}
loadYears () {
diff --git a/app/javascript/controllers/selectize_controller.js b/app/javascript/controllers/selectize_controller.js
index c2912f7..6609c4b 100644
--- a/app/javascript/controllers/selectize_controller.js
+++ b/app/javascript/controllers/selectize_controller.js
@@ -18,9 +18,9 @@ export default class extends ApplicationController {
$(".default-selectize").selectize(default_opts);
- var $doctrine_modal = $("#doctrineModal")
- var $doctrine_content = $doctrine_modal.find("input[name='content']");
- var $trix_content = $doctrine_modal.find(".trix-content");
+ var $doctrine_form = $("#doctrineForm")
+ var $doctrine_content = $doctrine_form.find("input[name='content']");
+ var $trix_content = $doctrine_form.find("trix-editor[placeholder='Doctrine Content']");
var doctrine_content_suggestions_opts = {
onChange: function (value) {
@@ -31,7 +31,7 @@ export default class extends ApplicationController {
$.get("/api/doctrines/" + value + ".json", {}, function (doctrine, status) {
if (status === "success") {
$doctrine_content.val(doctrine.content);
- $doctrine_modal.find("input[name='headnote']").val(doctrine.headnote)
+ $doctrine_form.find("input[name='headnote']").val(doctrine.headnote)
$trix_content.val(doctrine.content);
}
});
@@ -49,7 +49,7 @@ export default class extends ApplicationController {
},
onChange: function (value) {
var selectize_options = []
- var $selectize = $("#doctrineModal").find("#doctine_content_suggestions").selectize($.extend({ options: selectize_options }, doctrine_content_suggestions_opts));
+ var $selectize = $("#doctrineForm").find("#doctine_content_suggestions").selectize($.extend({ options: selectize_options }, doctrine_content_suggestions_opts));
if (value.length === 0) {
if ($selectize.length) $selectize[0].selectize.clearOptions();
diff --git a/app/models/annotation.rb b/app/models/annotation.rb
index d067d9d..acf06cb 100644
--- a/app/models/annotation.rb
+++ b/app/models/annotation.rb
@@ -13,8 +13,6 @@ class Annotation < ApplicationRecord
validates :content, presence: true
- before_save :parse_content
-
def documents
annotation_documents.collect(&:document)
end
@@ -32,18 +30,6 @@ class Annotation < ApplicationRecord
def citing_document_ids
documents.map(&:id)
end
-
-
- def parse_content
- pr = phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
- pr = pr.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
- annotated_doc_title = document.short_title || document.title
- annotated_doc_date = document.doc_date.present? ? document.doc_date.try(:strftime, "%B %d, %Y") : document.year
- contents = content.split(" citing ")
- contents[0] = [annotated_doc_title, document.clean_reference_number, annotated_doc_date, pr].join(", ")
-
- self.content = contents.join(" citing ")
- end
searchable do
integer :document_id
diff --git a/app/reflexes/document_reflex.rb b/app/reflexes/document_reflex.rb
index 12d601f..8cf08e1 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, current_document_id)
+ def render_case_lists_search_results(search_params, doctrine_id, jurisprudence_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_document_id: current_document_id, current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] }
+ opts = { doctrine_id: doctrine_id, jurisprudence_id: jurisprudence_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
@@ -20,10 +20,10 @@ class DocumentReflex < ApplicationReflex
morph "tbody#modalDocumentSearchTable", render(partial: "document_search_results_table", locals: { search_results: @documents, opts: { is_citing_document: true } })
end
- def render_doctrine_form_case_lists(search_params, jurisprudence_id)
+ def render_doctrine_form_case_lists(search_params)
search = document_search(search_params.merge(sort_by: %i[reference_number_texts title_texts short_title_texts]))
@documents = search.results
- opts = { jurisprudence_id: jurisprudence_id, current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] }
+ opts = { current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] }
morph "#caseListsCollapse", render(partial: "/shared/doctrine_form_case_lists", locals: { documents: @documents, opts: opts })
end
end
diff --git a/app/views/doctrine/annotations/edit.html.erb b/app/views/doctrine/annotations/edit.html.erb
new file mode 100644
index 0000000..0ea7beb
--- /dev/null
+++ b/app/views/doctrine/annotations/edit.html.erb
@@ -0,0 +1,15 @@
+
+
diff --git a/app/views/doctrine/annotations/new.html.erb b/app/views/doctrine/annotations/new.html.erb
new file mode 100644
index 0000000..f030981
--- /dev/null
+++ b/app/views/doctrine/annotations/new.html.erb
@@ -0,0 +1,16 @@
+