-
- <%= submit_tag "Save", class: "btn btn-primary text-dark" %>
+
+ <%= submit_tag "Save", class: "btn btn-primary" %>
<% end %>
\ No newline at end of file
diff --git a/app/components/subjects_sidenav_sub_menu_component.rb b/app/components/subjects_sidenav_sub_menu_component.rb
index 13900bc..cb3e738 100644
--- a/app/components/subjects_sidenav_sub_menu_component.rb
+++ b/app/components/subjects_sidenav_sub_menu_component.rb
@@ -8,6 +8,6 @@ class SubjectsSidenavSubMenuComponent < BaseComponent
def index_url(subject_id)
return search_doctrines_path(subject_ids: [subject_id]) if opts[:is_doctrines_index].present?
- doctrines_subject_index_path(subject_id)
+ search_documents_path(subject_ids: subject_id)
end
end
diff --git a/app/controllers/doctrine/annotations_controller.rb b/app/controllers/doctrine/annotations_controller.rb
index f607911..5c6d087 100644
--- a/app/controllers/doctrine/annotations_controller.rb
+++ b/app/controllers/doctrine/annotations_controller.rb
@@ -14,9 +14,10 @@ class Doctrine::AnnotationsController < ApplicationController
respond_to do |format|
if @annotation.save
- format.html { redirect_to document_path(@doctrine.document) , notice: "Doctrine Annotation was successfully created." }
+ format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine),
+ notice: "Doctrine Annotation was successfully created." }
else
- format.html { redirect_to document_path(@doctrine.document) }
+ format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine) }
end
end
end
@@ -29,19 +30,23 @@ class Doctrine::AnnotationsController < ApplicationController
respond_to do |format|
if @annotation.update(attrs)
- format.html { redirect_to document_path(@doctrine.document), notice: "Doctrine Annotation was successfully updated." }
+ format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine),
+ notice: "Doctrine Annotation was successfully updated." }
else
- format.html { redirect_to document_path(@doctrine.document) }
+ format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine) }
end
end
end
def destroy
+ document_id = @doctrine.document_id
respond_to do |format|
if @annotation.destroy
- format.html { redirect_to subject_indexes_path, notice: "Doctrine Annotation was successfully destroyed." }
+ format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine),
+ notice: "Doctrine Annotation was successfully destroyed." }
else
- format.html { redirect_to document_path(@doctrine.document), alert: @annotation.errors.full_messages }
+ format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine),
+ alert: @annotation.errors.full_messages }
end
end
end
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb
index 4d56949..8a3d67d 100644
--- a/app/controllers/documents_controller.rb
+++ b/app/controllers/documents_controller.rb
@@ -4,7 +4,8 @@ class DocumentsController < ApplicationController
load_and_authorize_resource :document, class: "Cdao::Jurisprudence"
def index
- search = jurisprudence_search(search_params)
+ @search_params = search_params
+ search = jurisprudence_search(@search_params)
@jurisprudences = search.results
diff --git a/app/controllers/subject_indexes_controller.rb b/app/controllers/subject_indexes_controller.rb
index 97bceec..eed2a83 100644
--- a/app/controllers/subject_indexes_controller.rb
+++ b/app/controllers/subject_indexes_controller.rb
@@ -86,7 +86,7 @@ class SubjectIndexesController < ApplicationController
end
def resource_params
- params.permit(:name, parent_id)
+ params.permit(:name, :parent_id, library_ids: [])
end
def search_params
diff --git a/app/javascript/controllers/application_controller.js b/app/javascript/controllers/application_controller.js
index 2e6ce4c..aa2eac9 100644
--- a/app/javascript/controllers/application_controller.js
+++ b/app/javascript/controllers/application_controller.js
@@ -5,7 +5,11 @@ import $ from 'jquery';
require("select2/dist/css/select2")
require("select2-bootstrap-theme/dist/select2-bootstrap")
+require("selectize/dist/js/selectize.min")
+require("selectize/dist/css/selectize")
+
import Select2 from "select2"
+import Selectize from "selectize";
/* This is your ApplicationController.
* All StimulusReflex controllers should inherit from this class.
diff --git a/app/javascript/controllers/document_controller.js b/app/javascript/controllers/document_controller.js
index acf11e3..ba6ffc4 100644
--- a/app/javascript/controllers/document_controller.js
+++ b/app/javascript/controllers/document_controller.js
@@ -9,27 +9,52 @@ export default class extends ApplicationController {
search () {
var $this = this
- $.get("/api/jurisprudences/", { q: this.inputTarget.value }, function (data, status) {
+
+ $.get("/api/jurisprudences.json", { q: $this.inputTarget.value }, function (data, status) {
if (status === "success") {
- $this.stimulate("DocumentReflex#render_index_table", data)
+ $this.stimulate("DocumentReflex#render_index_table", data, $this.element.dataset["documentId"], $this.element.dataset["doctrineId"])
}
});
}
modalDocumentSearch () {
var $this = this
- $.get("/api/jurisprudences/", { q: this.inputTarget.value }, function (data, status) {
+ $.get("/api/jurisprudences.json", { q: $this.inputTarget.value }, function (data, status) {
if (status === "success") {
- $this.stimulate("DocumentReflex#render_moda_document_search_table", data)
+ $this.stimulate("DocumentReflex#render_modal_document_search_table", data)
}
});
}
loadYears () {
- $.get("/api/jurisprudences/years", {}, function (data, status) {
+ var $this = this
+ $.get("/api/jurisprudences/years.json", {}, function (data, status) {
if (status === "success") {
$this.stimulate("DocumentReflex#render_years", data)
}
});
}
+
+ loadFormDocumentDetais () {
+ var document_id = "", document_title = "", document_ref_no = "", document_date_or_year = "", $modal = $("#newAnnotationModal")
+
+ document_id = this.element.dataset["documentId"]
+ document_title = this.element.dataset["documentTitle"]
+ document_ref_no = this.element.dataset["documentReferenceNumber"]
+ document_date_or_year = this.element.dataset["documentDateOrYear"]
+
+ $modal.find("#document_title").val([document_title, document_ref_no, document_date_or_year].join(", "))
+ $modal.find("#document_id").val(document_id)
+ }
+
+ addCitingDocument () {
+ var document_id = "", document_ref_no = "", $modal = $("#newAnnotationModal"), $doc_title = $modal.find("#document_title"),
+ $doc_id = $modal.find("#document_id")
+
+ document_id = this.element.dataset["documentId"]
+ document_ref_no = this.element.dataset["documentReferenceNumber"]
+
+ console.log($doc_id.val())
+ console.log($doc_title.val())
+ }
}
diff --git a/app/javascript/controllers/select2_controller.js b/app/javascript/controllers/select2_controller.js
index 21cf4c8..d8c9325 100644
--- a/app/javascript/controllers/select2_controller.js
+++ b/app/javascript/controllers/select2_controller.js
@@ -4,8 +4,10 @@ export default class extends ApplicationController {
connect() {
super.connect()
+ $("#cdao_subject_parent_id").select2({ tags: true, width: "100%" })
$(".subjects-select2").select2({ tags: true, width: "100%" })
- $(".annomark-ids-select2").select2({ width: "100%", dropdownParent: $("#editAnnotation11") })
+ $(".annomark-ids-select2").select2({ width: "100%", dropdownParent: $("#edit-annotation-modal") })
+ $(".new-annotation-annomark-ids").select2({ width: "100%", dropdownParent: $("#new-annotation-modal") })
$(".subject-ids-modal-select2").select2({ width: "100%", dropdownParent: $("#doctrineModal") })
}
}
diff --git a/app/javascript/controllers/selectize_controller.js b/app/javascript/controllers/selectize_controller.js
new file mode 100644
index 0000000..e564f7b
--- /dev/null
+++ b/app/javascript/controllers/selectize_controller.js
@@ -0,0 +1,20 @@
+import ApplicationController from './application_controller'
+
+export default class extends ApplicationController {
+ connect() {
+ super.connect()
+
+ var default_opts = {
+ plugins: ['restore_on_backspace', 'remove_button'],
+ searchField: ['text', 'optgroup'],
+ valueField: "id",
+ allowEmptyOption: false,
+ showEmptyOptionInDropdown: true,
+ emptyOptionLabel: true,
+ hideSelected: true,
+ placeholder: "Please Select"
+ }
+
+ $(".default-selectize").selectize(default_opts)
+ }
+}
diff --git a/app/javascript/src/application.scss b/app/javascript/src/application.scss
index 030447e..1af5fdd 100644
--- a/app/javascript/src/application.scss
+++ b/app/javascript/src/application.scss
@@ -18,10 +18,10 @@
left: 0;
}
-.clickable-link, .clickable-tr {
+.clickable-link, .clickable-tr, .accordion-button {
cursor: pointer;
}
.current {
- background-color: #535353;
+ background-color: #535353 !important;
}
diff --git a/app/reflexes/document_reflex.rb b/app/reflexes/document_reflex.rb
index 3d580a8..a084725 100644
--- a/app/reflexes/document_reflex.rb
+++ b/app/reflexes/document_reflex.rb
@@ -3,15 +3,16 @@
class DocumentReflex < ApplicationReflex
include JurisprudenceSearch
- def render_index_table(results)
- morph "tbody#documentIndexTable", render(DocumentIndexTableBodyComponent.with_collection(results, current_user: current_user, opts: { is_case_lists: true }))
+ def render_index_table(results, document_id, doctrine_id)
+ opts = { is_case_lists: true, document_id: document_id, doctrine_id: doctrine_id, form_method: :post }
+ morph "tbody#documentIndexTable", render(partial: "document_search_results_table", locals: { search_results: results, opts: opts })
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 }))
+ def render_modal_document_search_table(results)
+ morph "tbody#modalDocumentSearchTable", render(partial: "document_search_results_table", locals: { search_results: results, opts: { is_citing_document: true } })
end
end
diff --git a/app/views/document/doctrines/_document_search_results_table.html.erb b/app/views/document/doctrines/_document_search_results_table.html.erb
new file mode 100644
index 0000000..accc68e
--- /dev/null
+++ b/app/views/document/doctrines/_document_search_results_table.html.erb
@@ -0,0 +1,28 @@
+<% search_results.each do |search_result| %>
+
+ <%= search_result["reference_number"] %>
+ <%= search_result["short_title"] || search_result["title"] %>
+ <%= search_result["docdate"].present? ? search_result["docdate"].to_date.strftime("%m/%d/%Y") : search_result["year"] %>
+
+ <% if opts[:is_case_lists].present? && opts[:document_id].present? && opts[:doctrine_id].present? %>
+
+ <% date_or_year = search_result["docdate"].present? ? search_result["docdate"].to_date.strftime("%B %d, %Y") : search_result["year"] %>
+ <% title = search_result["short_title"].present? ? search_result["short_title"] : search_result["title"] %>
+ " data-document-reference-number="<%= search_result["reference_number"] %>"
+ data-document-date-or-year="<%= date_or_year %>" data-action="click->document#loadFormDocumentDetais">
+ Add Annotation Marks
+
+
+ <% end %>
+
+ <% if opts[:is_citing_document].present? %>
+
+ "
+ data-document-reference-number="<%= search_result["reference_number"] %>">
+ Add
+
+
+ <% end %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/documents/index.html.erb b/app/views/documents/index.html.erb
index a565676..94bd593 100644
--- a/app/views/documents/index.html.erb
+++ b/app/views/documents/index.html.erb
@@ -8,24 +8,57 @@
<%= submit_tag "Search", class: "btn btn-primary text-dark" %>
-
Advanced Search
+
Citation Finder
+
+
+ <%= form_tag(documents_path, method: :get) do %>
+
<% end %>
-
<%= render PaginationComponent.new(data: @jurisprudences) %>
-
-
- Reference No.
- Title
- Date
-
+ <% if @search_params.reject { |k, v| v.blank? }.present? %>
+ <%= render PaginationComponent.new(data: @jurisprudences) %>
+
+
+ Reference No.
+ Title
+ Date
+
-
- <%= render(DocumentIndexTableComponent.with_collection(@jurisprudences, current_user: current_user, opts: {})) %>
-
-
+
+ <%= render(DocumentIndexTableComponent.with_collection(@jurisprudences, current_user: current_user, opts: {})) %>
+
+
+ <% end %>