<%= rich_text_area_tag :content, nil, placeholder: "Doctrine Content", data: { target: "doctrines.content" } %>
diff --git a/app/components/document_doctrine_index_component.rb b/app/components/document_doctrine_index_component.rb
index e62e32c..663b5bc 100644
--- a/app/components/document_doctrine_index_component.rb
+++ b/app/components/document_doctrine_index_component.rb
@@ -12,6 +12,7 @@ class DocumentDoctrineIndexComponent < BaseComponent
delegate :content, to: :doctrine
delegate :annotations, to: :doctrine
delegate :subjects, to: :doctrine
+ delegate :doctrine_jurisprudences, to: :doctrine
def annotation_form_url
doctrine_annotations_path(doctrine_id: id)
@@ -21,6 +22,12 @@ class DocumentDoctrineIndexComponent < BaseComponent
"(No Subjects Provided)"
end
+ def jurisprudence
+ return nil if doctrine_jurisprudences.blank?
+
+ doctrine_jurisprudences.first.jurisprudence
+ end
+
def document_title(annotation)
return annotation.document.short_title if annotation.document.short_title.present?
diff --git a/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb b/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
index 1e90379..8d8257d 100644
--- a/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
+++ b/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
@@ -1,4 +1,4 @@
-
+
<% if opts[:is_subjects_index].blank? %>
<% if opts[:is_doctrines_index].present? && opts[:subject_ids].reject(&:blank?).present? %>
<%= subjects.where(id: opts[:subject_ids].map(&:to_i)).map(&:lineage_name).join(" ") %>
diff --git a/app/components/document_doctrine_show_component.rb b/app/components/document_doctrine_show_component.rb
index 9450950..18ae583 100644
--- a/app/components/document_doctrine_show_component.rb
+++ b/app/components/document_doctrine_show_component.rb
@@ -9,6 +9,7 @@ class DocumentDoctrineShowComponent < BaseComponent
end
delegate :id, to: :doctrine
+ delegate :headnote, to: :doctrine
delegate :subject_ids, to: :doctrine
delegate :content, to: :doctrine
delegate :annotations, to: :doctrine
@@ -24,10 +25,6 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.document.title
end
- def all_subjects
- Cdao::Subject.all.order(name: :asc)
- end
-
def document
Document.find(document_id)
end
diff --git a/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb b/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
index bb7a9a8..5c9d420 100644
--- a/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
+++ b/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
@@ -5,9 +5,9 @@
Doctrine Details
-
@@ -19,7 +19,7 @@
-
+
Subjects:
@@ -29,7 +29,17 @@
-
+
+ Head Note:
+
+
+
+ <%= headnote %>
+
+
+
+
+
Content:
diff --git a/app/controllers/api/doctrines_controller.rb b/app/controllers/api/doctrines_controller.rb
index 72f7b84..7979c65 100644
--- a/app/controllers/api/doctrines_controller.rb
+++ b/app/controllers/api/doctrines_controller.rb
@@ -28,7 +28,6 @@ module Api
respond_with @doctrine
else
- raise @doctrine.errors.full_messages.inspect
render errors: @doctrine.errors, status: 422
end
end
diff --git a/app/controllers/doctrines_controller.rb b/app/controllers/doctrines_controller.rb
index f3f7f39..91ef2d3 100644
--- a/app/controllers/doctrines_controller.rb
+++ b/app/controllers/doctrines_controller.rb
@@ -21,7 +21,9 @@ class DoctrinesController < ApplicationController
end
end
- def show; end
+ def show
+ @jurisprudence = @doctrine.doctrine_jurisprudences.present? ? @doctrine.doctrine_jurisprudences.first.jurisprudence : nil
+ end
def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
diff --git a/app/javascript/controllers/doctrines_controller.js b/app/javascript/controllers/doctrines_controller.js
index 289d9f9..69ff602 100644
--- a/app/javascript/controllers/doctrines_controller.js
+++ b/app/javascript/controllers/doctrines_controller.js
@@ -1,6 +1,6 @@
import ApplicationController from './application_controller'
export default class extends ApplicationController {
- static targets = ["input", "document_id", "doctrine_id", "content"]
+ static targets = ["input", "document_id", "doctrine_id", "headnote", "content"]
connect () {
super.connect()
@@ -32,6 +32,7 @@ export default class extends ApplicationController {
});
$modal.find(".trix-content").val(doctrine.content)
+ $modal.find("#headnote").val(doctrine.headnote)
}
})
@@ -43,12 +44,14 @@ export default class extends ApplicationController {
$modal.find(".trix-content").val("")
$subject_ids_selectize.setValue([])
$modal.find("#doctrine_id").val('')
+ $modal.find("#headnote").val('')
}
}
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(), content: this.contentTarget.value }
+ var params = { subject_ids: $modal.find("select[name='subject_ids[]']").val(), headnote: this.headnoteTarget.value,
+ content: this.contentTarget.value }
if (doctrine_id !== null && doctrine_id !== undefined && doctrine_id !== "") {
$.ajax({
@@ -67,4 +70,20 @@ export default class extends ApplicationController {
})
}
}
+
+ delete(ev) {
+ var doctrine_id = this.element.dataset["doctrineId"], document_id = this.element.dataset["documentId"]
+
+ ev.preventDefault();
+ const contrim_alert = confirm("Are you sure to delete this record?")
+ if (contrim_alert) {
+ $.ajax({
+ url: "/api/doctrines/" + doctrine_id,
+ type: 'DELETE',
+ success: function() {
+ location.pathname = "/documents/" + document_id
+ }
+ })
+ }
+ }
}
diff --git a/app/views/api/doctrines/destroy.json.jbuilder b/app/views/api/doctrines/destroy.json.jbuilder
new file mode 100644
index 0000000..7250a98
--- /dev/null
+++ b/app/views/api/doctrines/destroy.json.jbuilder
@@ -0,0 +1 @@
+json.(@doctrine, *%i[id subject_ids headnote content plain_content created_at updated_at])
diff --git a/app/views/api/doctrines/update.json.jbuilder b/app/views/api/doctrines/update.json.jbuilder
new file mode 100644
index 0000000..7250a98
--- /dev/null
+++ b/app/views/api/doctrines/update.json.jbuilder
@@ -0,0 +1 @@
+json.(@doctrine, *%i[id subject_ids headnote content plain_content created_at updated_at])
diff --git a/app/views/doctrines/search.html.erb b/app/views/doctrines/search.html.erb
index 5c45a4d..ad0304f 100644
--- a/app/views/doctrines/search.html.erb
+++ b/app/views/doctrines/search.html.erb
@@ -8,5 +8,4 @@
<% else %>
<%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_doctrines_index: true, subject_ids: params[:subject_ids] })) %>
<% end %>
-
diff --git a/app/views/doctrines/show.html.erb b/app/views/doctrines/show.html.erb
index 42777d1..ee350fd 100644
--- a/app/views/doctrines/show.html.erb
+++ b/app/views/doctrines/show.html.erb
@@ -4,28 +4,23 @@
| Reference Number: |
- <%= @document.reference_number %> |
+ <%= @jurisprudence.present? ? @jurisprudence.reference_number : "(No Document Reference NUmber)" %> |
Date: |
- <%= @document.docdate.present? ? @document.docdate.strftime("%m/%d/%Y") : @document.year %> |
+ <%= @jurisprudence.present? ? @jurisprudence.docdate : "(No Document Date)" %> |
| Title: |
- <%= @document.title %> |
+ <%= @jurisprudence.present? ? @jurisprudence.short_title || @jurisprudence.title : "(No Document Date)" %> |
-
- <%= render(DocumentDoctrineShowComponent.new(current_user: current_user, doctrine: @doctrine, document_id: @document.id, subjects: @subjects)) %>
+ <%= render(DocumentDoctrineShowComponent.new(current_user: current_user, doctrine: @doctrine, document_id: @jurisprudence.present? ? @jurisprudence.id : @jurisprudence, subjects: @subjects)) %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 3012ab6..cbcd93b 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -16,7 +16,7 @@
<% if current_user.present? %>
- <%= render(SidenavComponent.new(current_user: current_user))%>
+ <%= render(SidenavComponent.new(current_user: current_user, opts: { is_sidenav: true }))%>
<% end %>