diff --git a/app/components/annotation_marks_modal_form_component.rb b/app/components/annotation_marks_modal_form_component.rb index 5c613b9..de475c8 100644 --- a/app/components/annotation_marks_modal_form_component.rb +++ b/app/components/annotation_marks_modal_form_component.rb @@ -14,7 +14,7 @@ class AnnotationMarksModalFormComponent < BaseComponent end def document_title - [document.title, document.reference_number, document_date_or_year].join(", ") + [document.title, document.reference_number, document_date_or_year].reject(&:blank?).join(", ") end def render? diff --git a/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb b/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb index f045b98..77b1be7 100644 --- a/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb +++ b/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb @@ -10,14 +10,39 @@
<%= label_tag :annotation_marks %> - <%= hidden_field_tag :document_id, opts[:document_id] %> + <%= hidden_field_tag :document_id, document.id %> <%= select_tag "annomark_ids[]", options_from_collection_for_select(Annomark.all, :id, :name, annotation.annomark_ids), class: "form-select annomark-ids-select2", multiple: true, prompt: "Please select" %>
+
<%= label_tag :document_title %> - <%= text_area_tag :document_title, document_date_or_year, class: "form-control" %> + <%= text_area_tag :document_title, document_title, class: "form-control" %> +
+
+ +
+
+
+ <%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number", data: { target: "document.input" } %> +
+
+ <%= button_tag "Search", class: "btn btn-primary", data: { action: "click->document#modalDocumentSearch" } %> +
+
+ +
+ + + + + + + + + +
Reference No. Date Title
diff --git a/app/components/document_index_table_component.rb b/app/components/document_index_table_component.rb index 8a50cd2..e333ce3 100644 --- a/app/components/document_index_table_component.rb +++ b/app/components/document_index_table_component.rb @@ -9,6 +9,7 @@ class DocumentIndexTableComponent < BaseComponent delegate :reference_number, to: :search_result delegate :title, to: :search_result + delegate :short_title, to: :search_result def date_or_year return search_result.docdate.strftime("%m/%d/%Y") if search_result.docdate.present? diff --git a/app/components/document_index_table_component/document_index_table_component.html.erb b/app/components/document_index_table_component/document_index_table_component.html.erb index 15fa650..546b891 100644 --- a/app/components/document_index_table_component/document_index_table_component.html.erb +++ b/app/components/document_index_table_component/document_index_table_component.html.erb @@ -1,5 +1,5 @@ - + <%= reference_number %> - <%= title %> + <%= short_title || title %> <%= date_or_year %> diff --git a/app/components/documents_years_component.rb b/app/components/documents_years_component.rb new file mode 100644 index 0000000..9f9479f --- /dev/null +++ b/app/components/documents_years_component.rb @@ -0,0 +1,12 @@ +class DocumentsYearsComponent < BaseComponent + attr_reader :years, :opts + + def initialize(current_user:, years:, opts: {}) + @years = years + @opts = opts + end + + def render? + years.reject(&:blank?).present? + end +end \ No newline at end of file diff --git a/app/components/documents_years_component/documents_years_component.html.erb b/app/components/documents_years_component/documents_years_component.html.erb new file mode 100644 index 0000000..12c47f6 --- /dev/null +++ b/app/components/documents_years_component/documents_years_component.html.erb @@ -0,0 +1,13 @@ + + + <% years.each_slice(10).to_a.each do |year_arr| %> + + <% end %> + +
+
+ <% year_arr.each do |year| %> + <%= link_to year, documents_path(year: year.to_i), class: "text-decoration-none text-dark d-block" %> + <% end %> +
+
diff --git a/app/controllers/decisions_controller.rb b/app/controllers/decisions_controller.rb index e60b5cd..0a649f9 100644 --- a/app/controllers/decisions_controller.rb +++ b/app/controllers/decisions_controller.rb @@ -10,6 +10,10 @@ class DecisionsController < ApplicationController @jurisprudences = search.results @years = (1901..Time.zone.today.year).entries.reverse + + respond_to do |format| + format.html + end end private diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 4c9978b..4d56949 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -33,6 +33,6 @@ class DocumentsController < ApplicationController private def search_params params.permit(:reference_number, :title, :short_title, :q, :page, :per_page, - :subject_ids) + :subject_ids, :year) end end diff --git a/app/javascript/controllers/document_controller.js b/app/javascript/controllers/document_controller.js index b8b0fde..acf11e3 100644 --- a/app/javascript/controllers/document_controller.js +++ b/app/javascript/controllers/document_controller.js @@ -2,16 +2,34 @@ import { end } from '@popperjs/core' import ApplicationController from './application_controller' export default class extends ApplicationController { static targets = ["input"] + connect () { super.connect() } search () { - const $this = this + var $this = this $.get("/api/jurisprudences/", { q: this.inputTarget.value }, function (data, status) { if (status === "success") { $this.stimulate("DocumentReflex#render_index_table", data) } }); } + + modalDocumentSearch () { + var $this = this + $.get("/api/jurisprudences/", { q: this.inputTarget.value }, function (data, status) { + if (status === "success") { + $this.stimulate("DocumentReflex#render_moda_document_search_table", data) + } + }); + } + + loadYears () { + $.get("/api/jurisprudences/years", {}, function (data, status) { + if (status === "success") { + $this.stimulate("DocumentReflex#render_years", data) + } + }); + } } diff --git a/app/reflexes/application_reflex.rb b/app/reflexes/application_reflex.rb index 554cca0..1fee00d 100644 --- a/app/reflexes/application_reflex.rb +++ b/app/reflexes/application_reflex.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class ApplicationReflex < StimulusReflex::Reflex + delegate :current_user, to: :connection # Put application-wide Reflex behavior and callbacks in this file. # # Example: diff --git a/app/reflexes/document_reflex.rb b/app/reflexes/document_reflex.rb index 2bcb288..94c9ffc 100644 --- a/app/reflexes/document_reflex.rb +++ b/app/reflexes/document_reflex.rb @@ -5,8 +5,14 @@ class DocumentReflex < ApplicationReflex def render_index_table(results) @results = results - morph "tbody#documentIndexTable", render(DocumentIndexTableBodyComponent.with_collection(@results, current_user: User.first, opts: { is_case_lists: true })) - # render(DocumentIndexTableBodyComponent.with_collection(@results, current_user: current_user, opts: { is_case_lists: true })) - # " 1 2 3 " + morph "tbody#documentIndexTable", render(DocumentIndexTableBodyComponent.with_collection(@results, current_user: current_user, opts: { is_case_lists: true })) + end + + def render_years(results) + morph "tbody#yearsIndex", render(DocumentsYearsComponent.new(current_user: current_user, years: results)) + end + + def render_moda_document_search_table(results) + morph "tbody#modalDocumentSearchTable", render(DocumentIndexTableBodyComponent.with_collection(@results, current_user: current_user, opts: { is_case_lists: true })) end end diff --git a/app/views/decisions/index.html.erb b/app/views/decisions/index.html.erb index e69de29..c125eeb 100644 --- a/app/views/decisions/index.html.erb +++ b/app/views/decisions/index.html.erb @@ -0,0 +1,6 @@ +
+

Select Year

+
+ <%= render(DocumentsYearsComponent.new(current_user: current_user, years: @years)) %> +
+
diff --git a/app/views/doctrines/index.html.erb b/app/views/doctrines/index.html.erb index af9baea..03e59ad 100644 --- a/app/views/doctrines/index.html.erb +++ b/app/views/doctrines/index.html.erb @@ -1,3 +1,4 @@
+
<%= render PaginationComponent.new(data: @doctrines) %>
<%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_disable_clickable_link: true, is_doctrines_index: true, subject_ids: params[:subject_ids] })) %>
diff --git a/app/views/documents/index.html.erb b/app/views/documents/index.html.erb index ab9a3a2..a565676 100644 --- a/app/views/documents/index.html.erb +++ b/app/views/documents/index.html.erb @@ -15,7 +15,7 @@
-
<%= render PaginationComponent.new(data: @jurisprudences) %>
+
<%= render PaginationComponent.new(data: @jurisprudences) %>
diff --git a/app/views/documents/search.html.erb b/app/views/documents/search.html.erb index 038b260..81147a0 100644 --- a/app/views/documents/search.html.erb +++ b/app/views/documents/search.html.erb @@ -3,8 +3,10 @@
<%= subject.path.map(&:name).join(' > ') %>
- <% end %> + <% end if %> +
+
<%= render PaginationComponent.new(data: @jurisprudences) %>
Reference No.
diff --git a/app/views/documents/show.html.erb b/app/views/documents/show.html.erb index e0f3e2f..dc37939 100644 --- a/app/views/documents/show.html.erb +++ b/app/views/documents/show.html.erb @@ -33,18 +33,13 @@
-
- - - -
- <%= render(DoctrineModalFormComponent.new(current_user: current_user, doctrine: @document.doctrines.new, subjects: @subjects, opts: { form_url: jurisprudence_doctrines_path(jurisprudence_id: @document.id), form_method: :post })) %> +
+ <%= render(DoctrineModalFormComponent.new(current_user: current_user, doctrine: @document.doctrines.new, subjects: @subjects, opts: { form_url: jurisprudence_doctrines_path(jurisprudence_id: @document.id), form_method: :post })) %> +
@@ -53,13 +48,24 @@
-
+
<%= raw @document.content.html_safe%>
- Citator +

Cited Ins Documents

+
Reference No.
+ + + + + + + + <%= render(DocumentIndexTableComponent.with_collection(@cited_in_documents, current_user: current_user)) %> + +
Reference No. Title Date