|
|
|
@ -1,6 +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", |
|
|
|
static targets = ["q", "annotation_id", "doctrine_id", "document_id", "document_ids", "current_document_id", |
|
|
|
"annomark_ids", "phil_rep", "editor_notes"] |
|
|
|
"annomark_ids", "phil_rep", "editor_notes"] |
|
|
|
|
|
|
|
|
|
|
|
connect () { |
|
|
|
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"],
|
|
|
|
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") |
|
|
|
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 !== "") { |
|
|
|
if(annotation_id !== null && annotation_id !== undefined && annotation_id !== "") { |
|
|
|
$modal.find(".modal-title").text("Edit Annotation") |
|
|
|
$modal.find(".modal-title").text("Edit Annotation") |
|
|
|
$.get("/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id + ".json", {}, function(result, status) { |
|
|
|
$.get("/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id + ".json", {}, function(result, status) { |
|
|
|
$modal.find("#annotation_id").val(annotation_id) |
|
|
|
$modal.find("#annotation_id").val(annotation_id) |
|
|
|
$modal.find("#doctrine_id").val(doctrine_id) |
|
|
|
$modal.find("#doctrine_id").val(doctrine_id) |
|
|
|
$modal.find("#document_id").val(result.citing_document_ids) |
|
|
|
$modal.find("#document_id").val(result.document_id) |
|
|
|
$modal.find("#document_ids").val(result.document_id) |
|
|
|
$modal.find("#document_ids").val(result.citing_document_ids) |
|
|
|
$modal.find("#phil_rep").val(result.phil_rep) |
|
|
|
$modal.find("#phil_rep").val(result.phil_rep) |
|
|
|
$modal.find("#document_title").val($this.element.dataset["documentTitle"]) |
|
|
|
$modal.find("#document_title").val($this.element.dataset["documentTitle"]) |
|
|
|
$modal.find("select[name='annomark_ids[]']")[0].selectize.setValue(result.annomark_ids) |
|
|
|
$modal.find("select[name='annomark_ids[]']")[0].selectize.setValue(result.annomark_ids) |
|
|
|
@ -45,7 +47,7 @@ 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"),
|
|
|
|
$modal = $("#annotationModal"), $doc_title = $modal.find("#document_title"),
|
|
|
|
$citing_document_ids = $modal.find("#document_ids") |
|
|
|
$citing_document_ids = $modal.find("#document_ids") |
|
|
|
|
|
|
|
|
|
|
|
@ -68,7 +70,8 @@ export default class extends ApplicationController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
save () { |
|
|
|
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, |
|
|
|
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 || "",
|
|
|
|
document_ids: $this.document_idsTarget.value || "", phil_rep: $this.phil_repTarget.value || "",
|
|
|
|
editor_notes: $this.editor_notesTarget.value || "" } |
|
|
|
editor_notes: $this.editor_notesTarget.value || "" } |
|
|
|
@ -79,23 +82,22 @@ export default class extends ApplicationController { |
|
|
|
type: 'PUT', |
|
|
|
type: 'PUT', |
|
|
|
data: params, |
|
|
|
data: params, |
|
|
|
success: function() { |
|
|
|
success: function() { |
|
|
|
$(".btn-close-x").trigger("click") |
|
|
|
location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id |
|
|
|
$this.stimulate("AnnotationReflex#render_annotations_views", { page: 1 }) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} 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") |
|
|
|
$this.stimulate("AnnotationReflex#render_annotations_views", { doctrine_id: doctrine_id, page: 1 }) |
|
|
|
location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id |
|
|
|
$this.stimulate("AnnotationReflex#render_default_case_lists_search", doctrine_id) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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"] |
|
|
|
|
|
|
|
|
|
|
|
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?") |
|
|
|
@ -104,7 +106,7 @@ 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() { |
|
|
|
$this.stimulate("AnnotationReflex#render_annotations_views", { doctrine_id: doctrine_id, page: 1 }) |
|
|
|
location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|