diff --git a/app/components/annotation_form_component.rb b/app/components/annotation_form_component.rb new file mode 100644 index 0000000..390a211 --- /dev/null +++ b/app/components/annotation_form_component.rb @@ -0,0 +1,30 @@ +class AnnotationFormComponent < BaseComponent + attr_reader :annotation, :opts + + def initialize(current_user:, annotation:, opts: {}) + @annotation = annotation + @opts = opts + end + + def document + return annotation.document if annotation.persisted? + + Cdao::Document.find(opts[:document_id].to_i) + end + + def display_text + return annotation.content if annotation.persisted? + + title = document.short_title || document.title + year_or_date = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year + + [title, document.clean_reference_number, year_or_date].join(", ") + end + + def phil_rep + return annotation.phil_rep if annotation.persisted? + + document.phil_rep + end +end + \ No newline at end of file diff --git a/app/components/annotation_form_component/annotation_form_component.html.erb b/app/components/annotation_form_component/annotation_form_component.html.erb new file mode 100644 index 0000000..9520239 --- /dev/null +++ b/app/components/annotation_form_component/annotation_form_component.html.erb @@ -0,0 +1,51 @@ +
+
+ Annotation Marks + <%= hidden_field_tag :document_ids, annotation.citing_document_ids, data: { target: "annotations.document_ids" } %> + <%= select_tag "annomark_ids[]", options_from_collection_for_select(Annomark.all.order(name: :asc), :id, :name, annotation.annomark_ids), + class: "form-control default-selectize ps-0", multiple: true, prompt: "Please select" %> +
+
+ +
+
+ <%= label_tag :document_title %> + <%= rich_text_area_tag :content, display_text, placeholder: "Document Title" %> +
+
+ +
+
+
+ <%= 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, phil_rep, class: "form-control", data: { target: "annotations.phil_rep" } %> +
+
+ +
+
+ <%= label_tag :editor_notes %> + <%= rich_text_area_tag :editor_notes, annotation.editor_notes, placeholder: "Editor Notes", data: { target: "annotations.editor_notes" } %> +
+
diff --git a/app/components/doctrine_index_component.rb b/app/components/doctrine_index_component.rb index 50440b7..5f08712 100644 --- a/app/components/doctrine_index_component.rb +++ b/app/components/doctrine_index_component.rb @@ -60,6 +60,14 @@ class DoctrineIndexComponent < BaseComponent search.results end + def content_diplay_text(annotation) + return annotation.content.gsub("
", "").gsub("
", "") if annotation.content.include?("Phil") + + contents = annotation.content.gsub("
", "").gsub("
", "").split(" citing ") + contents[0] = [contents[0], clean_phil_rep(annotation)].reject(&:blank?).join(", ") + contents.join(" citing ") + end + def render? doctrine.present? && doctrine.persisted? end diff --git a/app/components/doctrine_index_component/doctrine_index_component.html.erb b/app/components/doctrine_index_component/doctrine_index_component.html.erb index 76c737e..54c5054 100644 --- a/app/components/doctrine_index_component/doctrine_index_component.html.erb +++ b/app/components/doctrine_index_component/doctrine_index_component.html.erb @@ -4,19 +4,20 @@ <% document_title = jurisprudence.short_title || jurisprudence.title %> <% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %> - + <% annotations.each do |annotation| %> -

- <% annotated_documents_title = [] %> - <% annotation.documents.each do |annotated_document| %> - <% ad_title = annotated_document.short_title || annotated_document.title %> - <% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %> - <% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %> - <% end %> + <% annotated_documents_title = [] %> + <% annotation.documents.each do |annotated_document| %> + <% ad_title = annotated_document.short_title || annotated_document.title %> + <% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %> + <% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %> + <% end %> + <% citing_document_title = [document_title, annotation.document.clean_reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %> - <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> - <%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ') %> -

+
+
<%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %>
+
<%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %>
+
<% if annotation.editor_notes.present? %>
-
+
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %>
@@ -92,24 +92,19 @@ <% annotation.documents.each do |annotated_document| %> <% ad_title = annotated_document.short_title || annotated_document.title %> <% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %> - <% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %> + <% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %> <% end %> - <% citing_document_title = [document_title, annotation.document.reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %> - -
-
-

- <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> - <%= raw annotation.content.present? ? annotation.content : citing_document_title %> -

-
+ <% citing_document_title = [document_title, annotation.document.clean_reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %> + +
+
<%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %>
+
<%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %>
diff --git a/app/controllers/api/doctrine/annotations_controller.rb b/app/controllers/api/doctrine/annotations_controller.rb index 80bd7f3..de9860f 100644 --- a/app/controllers/api/doctrine/annotations_controller.rb +++ b/app/controllers/api/doctrine/annotations_controller.rb @@ -42,8 +42,8 @@ module Api if @annotation.save @documents.each { |document| @annotation.add_document(document) } if @documents.present? - @annotation.index! respond_with @annotation + @annotation.index! else render errors: @annotation.errors, status: 422 end @@ -67,8 +67,8 @@ module Api @documents.each { |document| @annotation.add_document(document) } if @documents.present? - @annotation.index! respond_with @annotation + @annotation.index! else render errors: @annotation.errors, status: 422 end diff --git a/app/controllers/doctrine/annotations_controller.rb b/app/controllers/doctrine/annotations_controller.rb index 652e190..0bd3ddc 100644 --- a/app/controllers/doctrine/annotations_controller.rb +++ b/app/controllers/doctrine/annotations_controller.rb @@ -2,6 +2,10 @@ class Doctrine::AnnotationsController < ApplicationController load_and_authorize_resource :doctrine, class: "Doctrine" load_and_authorize_resource :annotation, class: "Annotation", through: :doctrine + def new; end + + def edit; end + def create attrs = resource_params.to_unsafe_h.deep_symbolize_keys document_id = attrs.delete(:document_id) diff --git a/app/javascript/controllers/annotations_controller.js b/app/javascript/controllers/annotations_controller.js index f98452b..3aad0aa 100644 --- a/app/javascript/controllers/annotations_controller.js +++ b/app/javascript/controllers/annotations_controller.js @@ -1,7 +1,6 @@ import ApplicationController from './application_controller' export default class extends ApplicationController { - static targets = ["q", "annotation_id", "doctrine_id", "document_id", "document_ids", "current_document_id", - "annomark_ids", "phil_rep", "editor_notes"] + static targets = ["q", "document_ids", "annomark_ids", "phil_rep", "editor_notes"] connect () { super.connect() @@ -47,8 +46,8 @@ export default class extends ApplicationController { addAnnotatedDocument () { var document_id = "", document_ref_no = "", document_date = "", document_title = "", - $modal = $("#annotationModal"), $doc_title = $modal.find("#document_title"), - $citing_document_ids = $modal.find("#document_ids") + $form = $("#annotationForm"), $doc_title = $form.find("trix-editor[placeholder='Document Title']"), + $citing_document_ids = $form.find("#document_ids") document_id = this.element.dataset["documentId"] document_ref_no = this.element.dataset["documentReferenceNumber"] @@ -69,11 +68,11 @@ export default class extends ApplicationController { } save () { - 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, + var $this = this, $form = $("#annotationForm"), annotation_id = $this.element.dataset["annotationId"], + jurisprudence_id = $this.element.dataset["jurisprudenceId"], doctrine_id = $this.element.dataset["doctrineId"] + 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 || "", - 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 !== "") { $.ajax({ @@ -82,23 +81,27 @@ export default class extends ApplicationController { data: params, success: function() { $(".btn-close-x").trigger("click") - $('.toast').addClass('bg-success').show() - $( ".toast-body" ).html( "Submitted Successfully" ), - location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id + $('.toast').addClass('bg-success').show(); + $( ".toast-body" ).html( "Submitted Successfully" ); + location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id }, error: function() { - $(".btn-close-x").trigger("click"), - $('.toast').addClass('bg-danger').show(), - $( ".toast-body" ).html( "Unexpected Error Problem Occurred" ) + $(".btn-close-x").trigger("click"); + $('.toast').addClass('bg-danger').show(); + $( ".toast-body" ).html( "Unexpected Error Problem Occurred" ); } }) } else { $.post("/api/doctrines/" + 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/" + current_document_id + "/doctrines/" + doctrine_id + $(".btn-close-x").trigger("click"); + $('.toast').addClass('bg-success').show(); + $( ".toast-body" ).html( "Submitted Successfully" ); + location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id + } else { + $(".btn-close-x").trigger("click"); + $('.toast').addClass('bg-danger').show(); + $( ".toast-body" ).html( "Unexpected Error Problem Occurred" ); } }) } @@ -106,7 +109,7 @@ export default class extends ApplicationController { delete(ev) { 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(); 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, type: 'DELETE', success: function() { - $('.toast').addClass('bg-danger').show() - $( ".toast-body" ).html( "Deleted Successfully" ) - location.pathname = "/documents/" + current_document_id + "/doctrines/" + doctrine_id + $('.toast').addClass('bg-danger').show(); + $( ".toast-body" ).html( "Deleted Successfully" ); + location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id } }) } diff --git a/app/javascript/controllers/doctrines_controller.js b/app/javascript/controllers/doctrines_controller.js index 205ecdb..39af2e0 100644 --- a/app/javascript/controllers/doctrines_controller.js +++ b/app/javascript/controllers/doctrines_controller.js @@ -76,11 +76,13 @@ export default class extends ApplicationController { $(".btn-close-x").trigger("click"); $('.toast').addClass('bg-success').show(); $( ".toast-body" ).html( "Submitted Successfully" ); + $('.toast').fadeOut(5000); location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine_id }, error: function() { $(".btn-close-x").trigger("click"); $('.toast').addClass('bg-danger').show(); + $('.toast').fadeOut(5000); $( ".toast-body" ).html( "Unexpected Error Problem Occurred" ); } }) @@ -99,7 +101,7 @@ export default class extends ApplicationController { $( ".toast-body" ).html( "Case Lists was successfully save" ); $('.toast').fadeOut(5000); - if ((index + 1) === annotations_attributes.length) { + if (index === annotations_attributes.length - 1) { location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine.id } } @@ -117,7 +119,7 @@ export default class extends ApplicationController { } delete(ev) { - var doctrine_id = this.element.dataset["doctrineId"], document_id = this.element.dataset["documentId"] + var doctrine_id = this.element.dataset["doctrineId"], jurisprudence_id = this.element.dataset["jurisprudenceId"] ev.preventDefault(); const contrim_alert = confirm("Are you sure to delete this record?") @@ -129,7 +131,7 @@ export default class extends ApplicationController { $('.toast').addClass('bg-danger').show(); $( ".toast-body" ).html( "Deleted Successfully" ); $('.toast').fadeOut(5000); - location.pathname = "/documents/" + document_id + location.pathname = "/documents/" + jurisprudence_id }, error: function () { $('.toast').addClass('bg-danger').show(); @@ -190,7 +192,8 @@ export default class extends ApplicationController { content: $modal.find("input[name='document_title']").val(), phil_rep: $modal.find("#phil_rep").val(), editor_notes: $modal.find("input[name='editor_notes']").val(), annomark_ids: $modal.find("select[name='annomark_ids[]']").val() } - if (annotaitons_attributes_index.length) { + console.log(annotaitons_attributes_index.length) + if (annotaitons_attributes_index.length > 0) { annotations_attributes.splice(annotaitons_attributes_index, 1, params) $( ".toast-body" ).html( "Case List is successfully updated." ); } else { @@ -201,6 +204,7 @@ export default class extends ApplicationController { $(".btn-close-x").trigger("click"); $('.toast').addClass('bg-success').show(); $('.toast').fadeOut(5000); + $modal.find("select[name='annomark_ids[]']")[0].selectize.setValue([]) this.stimulate("DoctrinesReflex#render_doctrine_form_annotations_view", annotations_attributes) this.stimulate("DoctrinesReflex#render_default_citing_documents") this.stimulate("DoctrinesReflex#render_default_case_lists") @@ -227,10 +231,10 @@ export default class extends ApplicationController { $modal.find(".modal-title").text("Edit Annotation") - $modal.find("select[name='annomark_ids[]']").val(annotation.annomark_ids) + $modal.find("select[name='annomark_ids[]']")[0].selectize.setValue(annotation.annomark_ids) $modal.find("trix-editor[placeholder='Document Title']").val(annotation.content) $modal.find("#document_id").val(annotation.document_id) - $modal.find("#annotaitons_attributes_index").val(annotations_attributes_index) + $modal.find("#annotaitons_attributes_index")[0].selectize.setValue(annotations_attributes_index) if (annotation.document_ids.length) { $modal.find("#document_ids").val(annotation.document_ids.join(",")) diff --git a/app/javascript/controllers/document_controller.js b/app/javascript/controllers/document_controller.js index d9e49e9..7691ee0 100644 --- a/app/javascript/controllers/document_controller.js +++ b/app/javascript/controllers/document_controller.js @@ -7,28 +7,28 @@ export default class extends ApplicationController { } search () { + console.log(this.element.dataset) this.stimulate("DocumentReflex#render_case_lists_search_results", { q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 }, - this.element.dataset["doctrineId"], this.element.dataset["currentDocumentId"]) + this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"]) } searchDoctrineFormCaseLists () { this.stimulate("DocumentReflex#render_doctrine_form_case_lists", - { q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 }, - this.element.dataset["jurisprudenceId"]) + { q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 }) } paginateDoctrineFormCaseLists () { this.stimulate("DocumentReflex#render_doctrine_form_case_lists", - { q: this.element.dataset["q"], citation_finder: this.element.dataset["citation_finder"], - page: this.element.dataset["page"] }, this.element.dataset["jurisprudenceId"]) + { q: this.element.dataset["q"], citation_finder: this.element.dataset["citationFinder"], + page: this.element.dataset["page"] }) } paginate () { this.stimulate("DocumentReflex#render_case_lists_search_results", - { q: this.element.dataset["q"], citation_finder: this.element.dataset["citation_finder"], + { q: this.element.dataset["q"], citation_finder: this.element.dataset["citationFinder"], page: this.element.dataset["page"] }, - this.element.dataset["doctrineId"]) + this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"]) } loadYears () { diff --git a/app/javascript/controllers/selectize_controller.js b/app/javascript/controllers/selectize_controller.js index c2912f7..6609c4b 100644 --- a/app/javascript/controllers/selectize_controller.js +++ b/app/javascript/controllers/selectize_controller.js @@ -18,9 +18,9 @@ export default class extends ApplicationController { $(".default-selectize").selectize(default_opts); - var $doctrine_modal = $("#doctrineModal") - var $doctrine_content = $doctrine_modal.find("input[name='content']"); - var $trix_content = $doctrine_modal.find(".trix-content"); + var $doctrine_form = $("#doctrineForm") + var $doctrine_content = $doctrine_form.find("input[name='content']"); + var $trix_content = $doctrine_form.find("trix-editor[placeholder='Doctrine Content']"); var doctrine_content_suggestions_opts = { onChange: function (value) { @@ -31,7 +31,7 @@ export default class extends ApplicationController { $.get("/api/doctrines/" + value + ".json", {}, function (doctrine, status) { if (status === "success") { $doctrine_content.val(doctrine.content); - $doctrine_modal.find("input[name='headnote']").val(doctrine.headnote) + $doctrine_form.find("input[name='headnote']").val(doctrine.headnote) $trix_content.val(doctrine.content); } }); @@ -49,7 +49,7 @@ export default class extends ApplicationController { }, onChange: function (value) { var selectize_options = [] - var $selectize = $("#doctrineModal").find("#doctine_content_suggestions").selectize($.extend({ options: selectize_options }, doctrine_content_suggestions_opts)); + var $selectize = $("#doctrineForm").find("#doctine_content_suggestions").selectize($.extend({ options: selectize_options }, doctrine_content_suggestions_opts)); if (value.length === 0) { if ($selectize.length) $selectize[0].selectize.clearOptions(); diff --git a/app/models/annotation.rb b/app/models/annotation.rb index d067d9d..acf06cb 100644 --- a/app/models/annotation.rb +++ b/app/models/annotation.rb @@ -13,8 +13,6 @@ class Annotation < ApplicationRecord validates :content, presence: true - before_save :parse_content - def documents annotation_documents.collect(&:document) end @@ -32,18 +30,6 @@ class Annotation < ApplicationRecord def citing_document_ids documents.map(&:id) end - - - def parse_content - pr = phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil") - pr = pr.gsub(/(PhilRep|Phil)\.?,?/i, "Phil") - annotated_doc_title = document.short_title || document.title - annotated_doc_date = document.doc_date.present? ? document.doc_date.try(:strftime, "%B %d, %Y") : document.year - contents = content.split(" citing ") - contents[0] = [annotated_doc_title, document.clean_reference_number, annotated_doc_date, pr].join(", ") - - self.content = contents.join(" citing ") - end searchable do integer :document_id diff --git a/app/reflexes/document_reflex.rb b/app/reflexes/document_reflex.rb index 12d601f..8cf08e1 100644 --- a/app/reflexes/document_reflex.rb +++ b/app/reflexes/document_reflex.rb @@ -3,10 +3,10 @@ class DocumentReflex < ApplicationReflex include DocumentSearch - def render_case_lists_search_results(search_params, doctrine_id, current_document_id) + def render_case_lists_search_results(search_params, doctrine_id, jurisprudence_id) search = document_search(search_params.merge(sort_by: %i[reference_number_texts title_texts short_title_texts])) @documents = search.results - opts = { doctrine_id: doctrine_id, current_document_id: current_document_id, current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] } + opts = { doctrine_id: doctrine_id, jurisprudence_id: jurisprudence_id, current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] } morph "#caseListsCollapse", render(partial: "/shared/case_lists_search_results", locals: { documents: @documents, opts: opts }) end @@ -20,10 +20,10 @@ class DocumentReflex < ApplicationReflex morph "tbody#modalDocumentSearchTable", render(partial: "document_search_results_table", locals: { search_results: @documents, opts: { is_citing_document: true } }) end - def render_doctrine_form_case_lists(search_params, jurisprudence_id) + def render_doctrine_form_case_lists(search_params) search = document_search(search_params.merge(sort_by: %i[reference_number_texts title_texts short_title_texts])) @documents = search.results - opts = { jurisprudence_id: jurisprudence_id, current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] } + opts = { current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] } morph "#caseListsCollapse", render(partial: "/shared/doctrine_form_case_lists", locals: { documents: @documents, opts: opts }) end end diff --git a/app/views/doctrine/annotations/edit.html.erb b/app/views/doctrine/annotations/edit.html.erb new file mode 100644 index 0000000..0ea7beb --- /dev/null +++ b/app/views/doctrine/annotations/edit.html.erb @@ -0,0 +1,15 @@ +
+
+

Edit Annotation

+
+ <%= render(AnnotationFormComponent.new(current_user: current_user, annotation: @annotation)) %> +
+ +
+
+
diff --git a/app/views/doctrine/annotations/new.html.erb b/app/views/doctrine/annotations/new.html.erb new file mode 100644 index 0000000..f030981 --- /dev/null +++ b/app/views/doctrine/annotations/new.html.erb @@ -0,0 +1,16 @@ +
+
+

New Annotation

+
+ <%= render(AnnotationFormComponent.new(current_user: current_user, annotation: @annotation, + opts: { document_id: params[:document_id] })) %> +
+ +
+
+
diff --git a/app/views/doctrines/show.html.erb b/app/views/doctrines/show.html.erb index 9b04d3d..742d690 100644 --- a/app/views/doctrines/show.html.erb +++ b/app/views/doctrines/show.html.erb @@ -20,7 +20,7 @@
- <%= render(DocumentDoctrineShowComponent.new(current_user: current_user, annotations: @annotations, doctrine: @doctrine, document_id: @jurisprudence.present? ? @jurisprudence.id : @jurisprudence, subjects: @subjects)) %> + <%= render(DocumentDoctrineShowComponent.new(current_user: current_user, annotations: @annotations, doctrine: @doctrine, jurisprudence_id: @jurisprudence.present? ? @jurisprudence.id : @jurisprudence, subjects: @subjects)) %>
diff --git a/app/views/document/doctrines/show.html.erb b/app/views/document/doctrines/show.html.erb index 1e7d41d..87311dd 100644 --- a/app/views/document/doctrines/show.html.erb +++ b/app/views/document/doctrines/show.html.erb @@ -52,7 +52,7 @@
- <%= render(DocumentDoctrineShowComponent.new(current_user: current_user, annotations: @annotations, doctrine: @doctrine, document_id: @document.id, subjects: @subjects)) %> + <%= render(DocumentDoctrineShowComponent.new(current_user: current_user, annotations: @annotations, doctrine: @doctrine, jurisprudence_id: @document.id, subjects: @subjects)) %>
diff --git a/app/views/shared/_case_lists_search_results.html.erb b/app/views/shared/_case_lists_search_results.html.erb index 9534fb1..8927c5d 100644 --- a/app/views/shared/_case_lists_search_results.html.erb +++ b/app/views/shared/_case_lists_search_results.html.erb @@ -1,4 +1,4 @@ -
+
<%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %> @@ -26,14 +26,17 @@ <% unless documents.first_page? %> + data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-q="<%= opts[:q] %>" + data-citation-finder="<%= opts[:citation_finder] %>" data-page="<%= 1 %>" + data-action="click->document#paginate"> @@ -47,7 +50,9 @@ <% else %> + data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-q="<%= opts[:q] %>" + data-citation-finder="<%= opts[:citation_finder] %>" data-page="<%= page + 1 %>" + data-action="click->document#paginate"> <%= page + 1 %> @@ -57,17 +62,17 @@ <% unless documents.last_page? %> - + - + @@ -96,12 +101,8 @@ <% date_or_year = document.doc_date.strftime("%B %d, %Y") || document.year %> <% title = document.short_title || document.title %> - - Add Annotation + + Add Annotation diff --git a/app/views/shared/_doctrine_form_case_lists.html.erb b/app/views/shared/_doctrine_form_case_lists.html.erb index 2e788d5..b19ed05 100644 --- a/app/views/shared/_doctrine_form_case_lists.html.erb +++ b/app/views/shared/_doctrine_form_case_lists.html.erb @@ -26,13 +26,14 @@ <% unless documents.first_page? %> - @@ -45,7 +46,7 @@ <%= page + 1 %> <% else %> - <%= page + 1 %> @@ -56,14 +57,14 @@ <% unless documents.last_page? %> - - @@ -94,9 +95,9 @@ <% date_or_year = document.doc_date.strftime("%B %d, %Y") || document.year %> <% title = document.short_title || document.title %> + data-document-id="<%= document.id %>" data-document-title="<%= title %>" data-document-reference-number="<%= document.clean_reference_number %>" + data-document-date-or-year="<%= date_or_year %>" data-document-phil-rep="<%= document.phil_rep %>" + data-action="click->doctrines#newAnnotation"> Add Annotation diff --git a/config/routes.rb b/config/routes.rb index 68d0fdf..5770f39 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,7 @@ Rails.application.routes.draw 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] + resources :annotations, only: %i[new edit create update destroy] end end