+
+ <%= rich_text_area_tag :content, nil, placeholder: "Doctrine Content", required: true, data: { target: "doctrines.content" } %>
+
Content cannot be blank.
+
+
\ No newline at end of file
diff --git a/app/controllers/doctrines_controller.rb b/app/controllers/doctrines_controller.rb
index d8835de..12818a7 100644
--- a/app/controllers/doctrines_controller.rb
+++ b/app/controllers/doctrines_controller.rb
@@ -4,6 +4,10 @@ class DoctrinesController < ApplicationController
load_and_authorize_resource :doctrine, class: "Doctrine"
+ def new; end
+
+ def edit; end
+
def index
@search = doctrine_search(search_params)
@doctrines = @search.results
diff --git a/app/javascript/controllers/doctrines_controller.js b/app/javascript/controllers/doctrines_controller.js
index 42d4de3..2be808a 100644
--- a/app/javascript/controllers/doctrines_controller.js
+++ b/app/javascript/controllers/doctrines_controller.js
@@ -49,21 +49,22 @@ export default class extends ApplicationController {
}
save () {
- 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,
+ var $this = this, $form = $("#doctrineForm"), document_id = $this.document_idTarget.value, doctrine_id = $this.doctrine_idTarget.value
+ var params = { subject_ids: $form.find("select[name='subject_ids[]']").val(), headnote: $this.headnoteTarget.value,
content: $this.contentTarget.value }
+ console.log(params)
if (!params.subject_ids.length) {
- $("#subjects-blank-message").show()
+ $form.find("#subjects-blank-message").show()
}
if (!params.headnote.length) {
- $("#headnote-blank-message").show()
+ $form.find("#headnote-blank-message").show()
}
if (!params.content.length) {
- $("#content-blank-message").show()
+ $form.find("#content-blank-message").show()
}
if (params.subject_ids.length && params.headnote.length && params.content.length) {
@@ -93,7 +94,7 @@ export default class extends ApplicationController {
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)
+ $this.stimulate("DoctrinesReflex#render_annotation_form", document_id, data.id)
$('.toast').fadeOut(5000)
} else {
$(".btn-close-x").trigger("click")
@@ -132,18 +133,18 @@ export default class extends ApplicationController {
}
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() }
+ var $form = $("#doctrineForm")
+ const params = { doctrine_id: $form.find("#doctrine_id").val(), document_id: $form.find("#document_id").val(),
+ document_ids: $form.find("#document_ids").val().split(","), content: $form.find("#document_title").val(),
+ phil_rep: $form.find("#phil_rep").val(), editor_notes: $form.find("#editor_notes").val(),
+ annomark_ids: $form.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
+ location.pathname = "/documents/" + $form.find("#current_document_id").val() + "/doctrines/" + params.doctrine_id
} else {
$(".btn-close-x").trigger("click")
$('.toast').addClass('bg-danger').show()
diff --git a/app/reflexes/doctrines_reflex.rb b/app/reflexes/doctrines_reflex.rb
index 46ad6dc..df77e8f 100644
--- a/app/reflexes/doctrines_reflex.rb
+++ b/app/reflexes/doctrines_reflex.rb
@@ -13,4 +13,10 @@ class DoctrinesReflex < ApplicationReflex
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
+
+ def render_annotation_form(document_id, doctrine_id)
+ jurisprudence = Cdao::Jurisprudence.find(document_id)
+ document = Cdao::Document.where(reference_number: jurisprudence.reference_number).first
+ morph "#doctrineForm", render(partial: "/shared/annotation_form", locals: { annotation: Annotation.new, document: document, doctrine_id: doctrine_id, jurisprudence: jurisprudence })
+ end
end
diff --git a/app/views/doctrines/edit.html.erb b/app/views/doctrines/edit.html.erb
new file mode 100644
index 0000000..9ed4d71
--- /dev/null
+++ b/app/views/doctrines/edit.html.erb
@@ -0,0 +1,12 @@
+
+
+
+
+ <%= render(DoctrineFormComponent.new(current_user: current_user, doctrine: @doctrine)) %>
+
+
+
+
diff --git a/app/views/doctrines/new.html.erb b/app/views/doctrines/new.html.erb
new file mode 100644
index 0000000..f0820f4
--- /dev/null
+++ b/app/views/doctrines/new.html.erb
@@ -0,0 +1,17 @@
+
+
diff --git a/app/views/document/doctrines/show.html.erb b/app/views/document/doctrines/show.html.erb
index 1b2b2e4..1e7d41d 100644
--- a/app/views/document/doctrines/show.html.erb
+++ b/app/views/document/doctrines/show.html.erb
@@ -47,7 +47,7 @@
diff --git a/app/views/documents/show.html.erb b/app/views/documents/show.html.erb
index 045181f..4c3ca3e 100644
--- a/app/views/documents/show.html.erb
+++ b/app/views/documents/show.html.erb
@@ -65,7 +65,7 @@
<%= render(DoctrineModalFormComponent.new(current_user: current_user)) %>
diff --git a/app/views/shared/_annotation_form.html.erb b/app/views/shared/_annotation_form.html.erb
new file mode 100644
index 0000000..4cfb823
--- /dev/null
+++ b/app/views/shared/_annotation_form.html.erb
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+ <%= label_tag :annotation_marks %>
+ <%= hidden_field_tag :doctrine_id, doctrine_id %>
+ <%= hidden_field_tag :current_document_id, jurisprudence.id %>
+ <%= hidden_field_tag :document_id, document.id %>
+ <%= hidden_field_tag :document_ids, nil %>
+ <%= select_tag "annomark_ids[]", options_from_collection_for_select(Annomark.all.order(name: :asc), :id, :name),
+ class: "form-control default-selectize ps-0", multiple: true, prompt: "Please select" %>
+
+
+
+
+
+ <%= label_tag :document_title %>
+ <%= text_area_tag :document_title, document.display_text, class: "form-control selected-citing-docs" %>
+
+
+
+
+
+
+ <%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "annotations.q" } %>
+
+
+
+
+
+
+
+
+
+ | Reference No. |
+ Title |
+ Date |
+ |
+
+
+
+
+
+
+
+ <%= label_tag :phil_rep %>
+ <%= text_field_tag :phil_rep, document.phil_rep, class: "form-control" %>
+
+
+
+
+
+ <%= label_tag :editor_notes %>
+ <%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor Notes" %>
+
+
+
+
+
diff --git a/config/routes.rb b/config/routes.rb
index 18439bd..68d0fdf 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -3,7 +3,7 @@ Rails.application.routes.draw do
root to: "documents#index"
- resources :doctrines, only: %i[index show] do
+ resources :doctrines, only: %i[index show new edit] do
get :search, on: :collection
scope module: :doctrine do
resources :annotations, only: %i[create update destroy]
@@ -27,6 +27,10 @@ Rails.application.routes.draw do
resources :reports, only: %i[index]
+ namespace :api, defaults: { format: :html } do
+ resources :doctrines, only: %i[new edit]
+ end
+
namespace :api, defaults: { format: :json } do
resources :doctrines do
scope module: :doctrine do