From d4456f337fa6a3d0e1d573d6fea6cef945adf9ee Mon Sep 17 00:00:00 2001 From: alexdbondoc17 Date: Thu, 17 Feb 2022 00:34:33 +0000 Subject: [PATCH] Implement \`API\` request of CRUD in \`doctrines\` --- .../doctrine_index_table_component.rb | 6 +++++ .../doctrine_index_table_component.html.erb | 10 ++++---- .../doctrine_modal_form_component.html.erb | 5 ++++ .../document_doctrine_index_component.rb | 7 ++++++ ...document_doctrine_index_component.html.erb | 2 +- .../document_doctrine_show_component.rb | 5 +--- .../document_doctrine_show_component.html.erb | 20 ++++++++++++---- app/controllers/api/doctrines_controller.rb | 1 - app/controllers/doctrines_controller.rb | 4 +++- .../controllers/doctrines_controller.js | 23 +++++++++++++++++-- app/views/api/doctrines/destroy.json.jbuilder | 1 + app/views/api/doctrines/update.json.jbuilder | 1 + app/views/doctrines/search.html.erb | 1 - app/views/doctrines/show.html.erb | 13 ++++------- app/views/layouts/application.html.erb | 2 +- 15 files changed, 71 insertions(+), 30 deletions(-) create mode 100644 app/views/api/doctrines/destroy.json.jbuilder create mode 100644 app/views/api/doctrines/update.json.jbuilder diff --git a/app/components/doctrine_index_table_component.rb b/app/components/doctrine_index_table_component.rb index be454d2..27b37da 100644 --- a/app/components/doctrine_index_table_component.rb +++ b/app/components/doctrine_index_table_component.rb @@ -6,6 +6,12 @@ class DoctrineIndexTableComponent < BaseComponent @opts = opts end + def jurisprudence(search_result) + return "(No Assigned Document)" if search_result.doctrine_jurisprudences.blank? + + search_result.doctrine_jurisprudences.first.jurisprudence + end + def document_reference_number(document) document.reference_number end diff --git a/app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb b/app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb index 676ab1a..f884981 100644 --- a/app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb +++ b/app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb @@ -7,11 +7,11 @@ <% search_results.each do |search_result| %> - - <%= document_reference_number(search_result.document) %> - <%= document_title(search_result.document) %> - <%= date_or_year(search_result.document) %> + + <%= document_reference_number(jurisprudence(search_result)) %> + <%= document_title(jurisprudence(search_result)) %> + <%= date_or_year(jurisprudence(search_result)) %> <% end %> - \ No newline at end of file + diff --git a/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb b/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb index 1715641..de157f1 100644 --- a/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb +++ b/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb @@ -19,6 +19,11 @@ +
+ + <%= text_field_tag :headnote, nil, class: "form-control", placeholder: "Head note", data: { target: "doctrines.headnote" } %> +
+
<%= 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 @@ -