<%= subjects.where(id: opts[:subject_ids].map(&:to_i)).map(&:lineage_name).join(" ") %>
- <% elsif subjects.present? %> - <% subjects.each do |subject| %> -<%= subject.lineage_name %>
+ <% if opts[:is_doctrines_index].blank? %> + <% 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(" ") %>
+ <% elsif subjects.present? %> + <% subjects.each do |subject| %> +<%= subject.lineage_name %>
+ <% end %> + <% else %> +(No Subjects Provided)
<% end %> - <% else %> -(No Subjects Provided)
<% end %> <% end %><%= raw content.html_safe %>
-<%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %>
+ <% end %> + <% annotations.each do |annotation| %><% annotated_documents_title = [] %> <% annotation.documents.each do |annotated_document| %> diff --git a/app/components/reports_search_results_component/reports_search_results_component.html.erb b/app/components/reports_search_results_component/reports_search_results_component.html.erb index 287f910..6e0bea1 100644 --- a/app/components/reports_search_results_component/reports_search_results_component.html.erb +++ b/app/components/reports_search_results_component/reports_search_results_component.html.erb @@ -4,11 +4,11 @@
<%= [document_title, annotation.document.reference_number, date_or_year].join(", ") %>
+ <% document_title = jurisprudence.short_title || jurisprudence.title %> + <% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.strftime : jurisprudence.year %> +<%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %>
+ <% annotations.each do |annotation| %><% annotated_documents_title = [] %> <% annotation.documents.each do |annotated_document| %> diff --git a/app/javascript/controllers/application_controller.js b/app/javascript/controllers/application_controller.js index 56ece23..d72ce9d 100644 --- a/app/javascript/controllers/application_controller.js +++ b/app/javascript/controllers/application_controller.js @@ -5,8 +5,10 @@ import { end } from '@popperjs/core' require("selectize/dist/js/selectize.min"); require("selectize/dist/css/selectize"); +require("bootstrap/dist/js/bootstrap") import Selectize from "selectize"; +import Bootstrap from 'bootstrap'; /* 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 fdab576..1b35a96 100644 --- a/app/javascript/controllers/document_controller.js +++ b/app/javascript/controllers/document_controller.js @@ -4,154 +4,6 @@ export default class extends ApplicationController { connect () { super.connect() - - $.fn.footnotes = function () { - var a, b, c; - a = $(this), b = a.find('a[href^="#footnote"]') - - c = a.find('p>span, p>a[href^="#fn"]>span').filter(function() { - return ($(this).css('color') == 'rgb(255, 0, 0)') - }) - - b.each(function(){ - var $this = $(this); - if($this.anchor_check()) { - if(!$this.parent('span.footnote-x').length) { - // Wrap the anchor with 'footnote-x' - $this.wrap('') - } - } - }) - - // Append index to every anchor - b = a.find('span.footnote-x a[href^="#footnote"]') - b.each(function() { - var $this = $(this); - var $matches = $($this.prop("tagName") + '#' + $this.attr("id") + ':not([data-index])') - var index = 0; - - $matches.each(function(){ - $(this).attr('id', $(this).attr('id') + '_' + index) - $(this).attr('name', $(this).attr('name') + '_' + index) - $(this).attr('href', $(this).attr('href') + '_' + index) - $(this).attr('data-index', index) - index = index + 1; - }) - }) - - c.each(function(){ - var $this = $(this) - $this.footnote_check() - }) - - c = a.find('a[href^="#fn"]') - - c.each(function() { - var $this = $(this); - var $matches = $($this.prop("tagName") + '#' + $this.attr("id") + ':not([data-index])') - var index = 0; - $matches.each(function(){ - var self, parent - self = $(this), parent = self.parent() - self.closest('p').find('#cdasiatab').detach() - self.attr('id', self.attr('id') + '_' + index) - self.attr('name', self.attr('name') + '_' + index) - self.attr('href', self.attr('href') + '_' + index) - self.attr('data-index', index) - parent.is('a') ? parent.replaceWith(self) : parent.closest('a').replaceWith(parent) // Remove parent its parent 'a' tag - index = index + 1; - }) - }) - } - - $.fn.anchor_check = function () { - var a, b, c, d; - a = $(this), b = a.attr('href'), c = $.trim(a.text()) - if (!$.isNumeric($.trim(c)) && c != '*' && c != 'n') { return false } - - if($.trim(b) && a.is('[href^="#footnote"]')){ - // Check whether href, name and text is valid - var a_href_id = a.attr('href').substring(9) // Get only the value after '#footnote' - var a_name_id = a.attr('name') ? a.attr('name').substring(2) : a_href_id // Get only the value after 'fn' if name attr is present if not return a_href_id - var a_id = a.attr('id') ? a.attr('id').substring(2) : '' - if(a_href_id != a_name_id || a_href_id != c || a_id != c || a_name_id != c){ - a.attr('href', '#footnote' + c), a.attr('id', 'fn' + c), a.attr('name', 'fn' + c) - } - } else { - // If anchor to footnote is invalid by href=#footnote*** or no href - // the text inside the 'a' tag will use as a reference - a.attr('href', '#footnote' + c), a.attr('id', 'fn' + c), a.attr('name', 'fn' + c) - } - return true; - } - - $.fn.footnote_check = function () { - var a, b, c, d; - a = $(this), d = null - - if (a.find('a:not([href^="#footnote"])').size()) { - a.find('a').each(function(){ - b = $.trim($(this).text()), c = b.match(/([\*]{1,3}|[\d]{1,3})/) - if (c!= null) { - c = c[0] - d = $(document.createElement('a')) - d.text(b), d.attr('href', '#fn' + c), d.attr('id', 'footnote' + c), d.attr('name', 'footnote' + c), d.addClass('m-r-lg'), d.css('color', 'red') - a.html(''), a.append(d) - return true; - } - }) - - if (d=null) { - return false - } - } else if (!a.find('a').size()) { - b = $.trim(a.text()), c = b.match(/([\*]{1,3}|[\d]{1,3})/) - if(c!= null){ - c = c[0] - d = $(document.createElement('a')) - d.text(b), d.attr('href', '#fn' + c), d.attr('id', 'footnote' + c), d.attr('name', 'footnote' + c), d.addClass('m-r-lg'), d.css('color', 'red') - a.html(''), a.append(d) - }else{ - return false - } - } - return true - } - - $.fn.footnote = function () { - var a = $(this) - var b, c, d; - b = $(a.attr('href')) - - if (b.length<=0 && a.data('index')>0) { - var a_id = a.attr('id').substring(0, a.attr('id').indexOf('_')) - var a_like = $('a[href^="#footnote"][id^="' + a_id + '"]') - var a_found = false; - a_like.each(function() { - if(!a_found){ b = $($(this).attr('href')) } - a_found = b.length > 0 - }) - } - - if (b.length>0) { - c = b.closest('p') - d = c.footnote_text(b.parent('span') || b), d = d.substring(0,499) + (d.length > 500 ? '...' : '') - a.attr('data-original-title', d), a.attr('data-toggle', 'tooltip') - a.tooltip({title: d}), a.tooltip('show') - } - - return a - } - - $.fn.footnote_text = function (except) { - var a = ''; - $(this).children().not(except).each(function() { - // Check first if the current select element not equal to except - var self = $(this) - a += self.text() - }) - return a; - } } search () { diff --git a/app/javascript/controllers/subjects_controller.js b/app/javascript/controllers/subjects_controller.js index fa4e6b5..c505d17 100644 --- a/app/javascript/controllers/subjects_controller.js +++ b/app/javascript/controllers/subjects_controller.js @@ -5,7 +5,7 @@ export default class extends ApplicationController { } loadSubjectsAccordion () { - var $this = this, params = { per_page: 200 }, parent_id = $this.element.dataset["subjectParentId"], + var $this = this, params = { per_page: 10000 }, parent_id = $this.element.dataset["subjectParentId"], opts = { parent_accordion_id: $this.element.dataset["accordionId"], accordionTarget: $this.element.dataset["accordionTarget"], accordionFor: $this.element.dataset["accordionFor"] } diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 4989aab..46dd728 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -19,6 +19,7 @@ import "chosen-js"; import 'trix/dist/trix.css'; import 'trix/dist/trix.js'; import "cable_ready"; +import "flatpickr/dist/flatpickr"; window.jQuery = $; window.$ = $; @@ -50,7 +51,31 @@ $(document).on("ready turbolinks:load", function () { window.open($href); } }) + + var default_config = { altFormat: "m/d/Y", altInput: true, enableTime: false, dateFormat: "Y-m-d", isMobile: true }; + $('.default-flatpickr').flatpickr(default_config); + + if ($.fn.footnotes) { + $('#documentTabContent').footnotes() + } + + $(document).on('click', 'a[href="#footnotes"]', function(event){ + event.preventDefault(); + $(this).each(function(){ + var a, b, c, d; + a = $(this), b = a.attr('href'), c = a.text(), d = '#footnote' + c + a.attr('href', d), a.attr('id', 'fn' + c) + a.trigger('click') + }) + }).on('click', 'a[href^="#footnote"], a[href^="#fn"]', function(event){ + var a, b; + a = $(this), b = $(a.attr('href')) + if(b.length<=0)return + event.preventDefault() + $(document).wrap('') + }) }); import "channels" import "controllers" +import "./application/footnotes" diff --git a/app/javascript/packs/application/footnotes.js b/app/javascript/packs/application/footnotes.js new file mode 100644 index 0000000..9801bb3 --- /dev/null +++ b/app/javascript/packs/application/footnotes.js @@ -0,0 +1,145 @@ +(function ($) { + 'use strict'; + $.fn.footnotes = function () { + var a, b, c; + a = $(this), b = a.find('a[href^="#footnote"]') + c = a.find('p>span, p>a[href^="#fn"]>span').filter(function() { + return ($(this).css('color') == 'rgb(255, 0, 0)') + }) + + b.each(function(){ + var $this = $(this); + console.log($this) + if($this.anchor_check()){ + if(!$this.parent('span.footnote-x').length){ + // Wrap the anchor with 'footnote-x' + $this.wrap('') + } + } + }) + // Append index to every anchor + b = a.find('span.footnote-x a[href^="#footnote"]') + b.each(function(){ + var $this = $(this); + var $matches = $($this.prop("tagName") + '#' + $this.attr("id") + ':not([data-index])') + var index = 0; + $matches.each(function(){ + $(this).attr('id', $(this).attr('id') + '_' + index) + $(this).attr('name', $(this).attr('name') + '_' + index) + $(this).attr('href', $(this).attr('href') + '_' + index) + $(this).attr('data-index', index) + index = index + 1; + }) + }) + c.each(function(){ + var $this = $(this) + $this.footnote_check() + }) + c = a.find('a[href^="#fn"]') + c.each(function(){ + var $this = $(this); + var $matches = $($this.prop("tagName") + '#' + $this.attr("id") + ':not([data-index])') + var index = 0; + $matches.each(function(){ + var self, parent + self = $(this), parent = self.parent() + self.closest('p').find('#cdasiatab').detach() + self.attr('id', self.attr('id') + '_' + index) + self.attr('name', self.attr('name') + '_' + index) + self.attr('href', self.attr('href') + '_' + index) + self.attr('data-index', index) + parent.is('a') ? parent.replaceWith(self) : parent.closest('a').replaceWith(parent) // Remove parent its parent 'a' tag + index = index + 1; + }) + }) + } + $.fn.anchor_check = function () { + var a, b, c, d; + a = $(this), b = a.attr('href'), c = $.trim(a.text()) + if(!$.isNumeric($.trim(c)) && c != '*' && c != 'n'){return false} + if($.trim(b) && a.is('[href^="#footnote"]')){ + // Check whether href, name and text is valid + var a_href_id = a.attr('href').substring(9) // Get only the value after '#footnote' + var a_name_id = a.attr('name') ? a.attr('name').substring(2) : a_href_id // Get only the value after 'fn' if name attr is present if not return a_href_id + var a_id = a.attr('id') ? a.attr('id').substring(2) : '' + if(a_href_id != a_name_id || a_href_id != c || a_id != c || a_name_id != c){ + a.attr('href', '#footnote' + c), a.attr('id', 'fn' + c), a.attr('name', 'fn' + c) + } + }else{ + // If anchor to footnote is invalid by href=#footnote*** or no href + // the text inside the 'a' tag will use as a reference + a.attr('href', '#footnote' + c), a.attr('id', 'fn' + c), a.attr('name', 'fn' + c) + } + return true; + } + $.fn.footnote_check = function () { + var a, b, c, d; + a = $(this), d = null + if(a.find('a:not([href^="#footnote"])').length){ + a.find('a').each(function(){ + b = $.trim($(this).text()), c = b.match(/([\*]{1,3}|[\d]{1,3})/) + if(c!= null){ + c = c[0] + d = $(document.createElement('a')) + d.text(b), d.attr('href', '#fn' + c), d.attr('id', 'footnote' + c), d.attr('name', 'footnote' + c), d.addClass('m-r-lg'), d.css('color', 'red') + a.html(''), a.append(d) + return true; + } + }) + if(d=null){ + return false + } + }else if(!a.find('a').length){ + b = $.trim(a.text()), c = b.match(/([\*]{1,3}|[\d]{1,3})/) + if(c!= null){ + c = c[0] + d = $(document.createElement('a')) + d.text(b), d.attr('href', '#fn' + c), d.attr('id', 'footnote' + c), d.attr('name', 'footnote' + c), d.addClass('m-r-lg'), d.css('color', 'red') + a.html(''), a.append(d) + }else{ + return false + } + } + return true + } + $.fn.footnote = function () { + var a = $(this) + // Validation of footnote + var b, c, d; + b = $(a.attr('href')) + if(b.length<=0 && a.data('index')>0){ + var a_id = a.attr('id').substring(0, a.attr('id').indexOf('_')) + var a_like = $('a[href^="#footnote"][id^="' + a_id + '"]') + var a_found = false; + a_like.each(function(){ + if(!a_found){b = $($(this).attr('href'))} + a_found = b.length>0 + }) + } + if(b.length>0){ + c = b.closest('p') + d = c.footnote_text(b.parent('span') || b), d = d.substring(0,499) + (d.length > 500 ? '...' : '') + a.attr('data-original-title', d), a.attr('data-toggle', 'tooltip') + a.tooltip({title: d}), a.tooltip('show') + }else{ + // typeof a._errorReport === "function" && a._errorReport({ + // type: 'footnote', + // details: 'Footnote not found @ ' + a.attr('href') + // }) + } + return a + } + $.fn.footnote_text = function (except) { + var a = ''; + $(this).children().not(except).each(function(){ + // Check first if the current select element not equal to except + var self = $(this) + a += self.text() + }) + return a; + } + $(document).on('mouseover mouseenter focus', 'a[href^="#footnote"]', function(event){ + event.preventDefault() + $(this).footnote() + }) +}(jQuery)) diff --git a/app/javascript/src/application.scss b/app/javascript/src/application.scss index b72fcff..65a6314 100644 --- a/app/javascript/src/application.scss +++ b/app/javascript/src/application.scss @@ -1,4 +1,6 @@ @import "~bootstrap/scss/bootstrap"; +@import '~flatpickr/dist/flatpickr.min'; +@import '~flatpickr/dist/themes/airbnb'; @import "./application/sidenav"; @import "./application/sessions"; @import "./application/pagination"; diff --git a/app/views/reports/index.html.erb b/app/views/reports/index.html.erb index 4baedcd..4626fa5 100644 --- a/app/views/reports/index.html.erb +++ b/app/views/reports/index.html.erb @@ -10,6 +10,10 @@