|
|
|
@ -1,7 +1,6 @@ |
|
|
|
import ApplicationController from './application_controller' |
|
|
|
import ApplicationController from './application_controller' |
|
|
|
export default class extends ApplicationController { |
|
|
|
export default class extends ApplicationController { |
|
|
|
static targets = ["q", "annotation_id", "doctrine_id", "document_id", "document_ids", "current_document_id", |
|
|
|
static targets = ["q", "document_ids", "annomark_ids", "phil_rep", "editor_notes"] |
|
|
|
"annomark_ids", "phil_rep", "editor_notes"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect () { |
|
|
|
connect () { |
|
|
|
super.connect() |
|
|
|
super.connect() |
|
|
|
@ -47,8 +46,8 @@ export default class extends ApplicationController { |
|
|
|
|
|
|
|
|
|
|
|
addAnnotatedDocument () { |
|
|
|
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"),
|
|
|
|
$form = $("#annotationForm"), $doc_title = $form.find("trix-editor[placeholder='Document Title']"),
|
|
|
|
$citing_document_ids = $modal.find("#document_ids") |
|
|
|
$citing_document_ids = $form.find("#document_ids") |
|
|
|
|
|
|
|
|
|
|
|
document_id = this.element.dataset["documentId"] |
|
|
|
document_id = this.element.dataset["documentId"] |
|
|
|
document_ref_no = this.element.dataset["documentReferenceNumber"] |
|
|
|
document_ref_no = this.element.dataset["documentReferenceNumber"] |
|
|
|
@ -69,11 +68,11 @@ export default class extends ApplicationController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
save () { |
|
|
|
save () { |
|
|
|
var $this = this, $modal = $("#annotationModal"), annotation_id = $this.annotation_idTarget.value,
|
|
|
|
var $this = this, $form = $("#annotationForm"), annotation_id = $this.element.dataset["annotationId"],
|
|
|
|
current_document_id = $this.current_document_idTarget.value, doctrine_id = $this.doctrine_idTarget.value |
|
|
|
jurisprudence_id = $this.element.dataset["jurisprudenceId"], doctrine_id = $this.element.dataset["doctrineId"] |
|
|
|
const params = { annomark_ids: $modal.find("select[name='annomark_ids[]']").val(), document_id: $this.document_idTarget.value, |
|
|
|
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 || "",
|
|
|
|
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 !== "") { |
|
|
|
if (annotation_id !== null && annotation_id !== undefined && annotation_id !== "") { |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
@ -82,23 +81,27 @@ export default class extends ApplicationController { |
|
|
|
data: params, |
|
|
|
data: params, |
|
|
|
success: function() { |
|
|
|
success: function() { |
|
|
|
$(".btn-close-x").trigger("click") |
|
|
|
$(".btn-close-x").trigger("click") |
|
|
|
$('.toast').addClass('bg-success').show() |
|
|
|
$('.toast').addClass('bg-success').show(); |
|
|
|
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" ), |
|
|
|
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" ); |
|
|
|
location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id |
|
|
|
location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id |
|
|
|
}, |
|
|
|
}, |
|
|
|
error: function() {
|
|
|
|
error: function() {
|
|
|
|
$(".btn-close-x").trigger("click"), |
|
|
|
$(".btn-close-x").trigger("click"); |
|
|
|
$('.toast').addClass('bg-danger').show(), |
|
|
|
$('.toast').addClass('bg-danger').show(); |
|
|
|
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" ) |
|
|
|
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" ); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$.post("/api/doctrines/" + doctrine_id + "/annotations", params, function(result, status) { |
|
|
|
$.post("/api/doctrines/" + doctrine_id + "/annotations", params, function(result, status) { |
|
|
|
if(status === "success") { |
|
|
|
if(status === "success") { |
|
|
|
$(".btn-close-x").trigger("click") |
|
|
|
$(".btn-close-x").trigger("click"); |
|
|
|
$('.toast').addClass('bg-success').show() |
|
|
|
$('.toast').addClass('bg-success').show(); |
|
|
|
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" ), |
|
|
|
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" ); |
|
|
|
location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id |
|
|
|
location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$(".btn-close-x").trigger("click"); |
|
|
|
|
|
|
|
$('.toast').addClass('bg-danger').show(); |
|
|
|
|
|
|
|
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" ); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -106,7 +109,7 @@ export default class extends ApplicationController { |
|
|
|
|
|
|
|
|
|
|
|
delete(ev) { |
|
|
|
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"] |
|
|
|
jurisprudence_id = $this.element.dataset["jurisprudenceId"] |
|
|
|
|
|
|
|
|
|
|
|
ev.preventDefault(); |
|
|
|
ev.preventDefault(); |
|
|
|
const contrim_alert = confirm("Are you sure to delete this record?") |
|
|
|
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, |
|
|
|
url: "/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id, |
|
|
|
type: 'DELETE', |
|
|
|
type: 'DELETE', |
|
|
|
success: function() { |
|
|
|
success: function() { |
|
|
|
$('.toast').addClass('bg-danger').show() |
|
|
|
$('.toast').addClass('bg-danger').show(); |
|
|
|
$( ".toast-body" ).html( "<span><b>Deleted Successfully</b></span>" ) |
|
|
|
$( ".toast-body" ).html( "<span><b>Deleted Successfully</b></span>" ); |
|
|
|
location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id |
|
|
|
location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|