35 changed files with 457 additions and 112 deletions
@ -1,4 +1,18 @@
|
||||
module ApplicationCable |
||||
class Connection < ActionCable::Connection::Base |
||||
identified_by :current_user |
||||
|
||||
def connect |
||||
self.current_user = find_verified_user |
||||
end |
||||
|
||||
private |
||||
def find_verified_user |
||||
if verified_user = User.find_by(id: cookies.encrypted[:user_id]) |
||||
verified_user |
||||
else |
||||
reject_unauthorized_connection |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
@ -0,0 +1,9 @@
|
||||
class DesicionsIndexComponent < BaseComponent |
||||
with_collection_parameter :search_result |
||||
attr_reader :search_result, :opts |
||||
|
||||
def initialize(search_result:, current_user:, opts: {}) |
||||
@search_result = search_result |
||||
@opts = opts |
||||
end |
||||
end |
||||
@ -0,0 +1,31 @@
|
||||
class DocumentIndexTableBodyComponent < BaseComponent |
||||
with_collection_parameter :search_result |
||||
attr_reader :search_result, :opts |
||||
|
||||
def initialize(search_result:, current_user:, opts: {}) |
||||
@search_result = search_result |
||||
@opts = opts |
||||
end |
||||
|
||||
def reference_number |
||||
search_result["reference_number"] |
||||
end |
||||
|
||||
def title |
||||
search_result["title"] |
||||
end |
||||
|
||||
def date_or_year |
||||
return search_result["docdate"].to_date.strftime("%m/%d/%Y") if search_result["docdate"].present? |
||||
|
||||
search_result["year"] |
||||
end |
||||
|
||||
def form_url |
||||
doctrine_annotations_path(doctrine_id: opts[:doctrine_id]) |
||||
end |
||||
|
||||
def render? |
||||
search_result.present? |
||||
end |
||||
end |
||||
@ -0,0 +1,5 @@
|
||||
<tr> |
||||
<td> <%= reference_number %> </td> |
||||
<td> <%= title %> </td> |
||||
<td> <%= date_or_year %> </td> |
||||
</tr> |
||||
@ -1,60 +1,5 @@
|
||||
<tr href="<%= document_path(search_result) %>" class="<%= opts.reject{ |k, v| v.blank? }.blank? ? 'clickable-tr' : ''%>"> |
||||
<tr href="<%= document_path(search_result.id) %>" class="<%= opts.reject{ |k, v| v.blank? }.blank? ? 'clickable-tr' : ''%>"> |
||||
<td> <%= reference_number %> </td> |
||||
<td> <%= title %> </td> |
||||
<td> <%= date_or_year %> </td> |
||||
<% if opts[:is_case_lists].present? && opts[:form_url].present? && opts[:document_id].present? %> |
||||
<td> |
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#annotationModal<%= search_result.id %>"> |
||||
<i class="fas fa-plus-circle" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Add"></i> |
||||
</a> |
||||
|
||||
<div class="modal fade" id="annotationModal<%= search_result.id %>" tabindex="-1" aria-labelledby="annotationModal" aria-hidden="true"> |
||||
<%= form_tag(opts[:form_url], method: :post) do%> |
||||
<div class="modal-dialog modal-lg modal-dialog-scrollable"> |
||||
<div class="modal-content"> |
||||
<div class="modal-header"> |
||||
<h5 class="modal-title">New Annotation Marks</h5> |
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
||||
</div> |
||||
|
||||
<div class="modal-body"> |
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<%= label_tag :annotation_marks %> |
||||
<%= hidden_field_tag :document_id, opts[:document_id] %> |
||||
<%= select_tag "annomark_ids[]", options_from_collection_for_select(Annomark.all, :id, :name, params[:annomark_ids]), class: "form-select i-chosen", multiple: true, prompt: "Please select" %> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<%= label_tag :document_title %> |
||||
<%= text_area_tag :document_title, [title, reference_number, date_or_year].join(", "), class: "form-control" %> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<%= label_tag :phil_rep %> |
||||
<%= text_field_tag :phil_rep, params[:phil_rep], class: "form-control" %> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<%= label_tag :editor_notes %> |
||||
<trix-editor id="editor_notes" placeholder="Doctrine Content"> <%= params[:editor_notes] %> </trix-editor> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="modal-footer"> |
||||
<%= submit_tag "Save", class: "btn btn-primary" %> |
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
</div> |
||||
</td> |
||||
<% end %> |
||||
</tr> |
||||
|
||||
@ -0,0 +1,66 @@
|
||||
import { Controller } from 'stimulus' |
||||
import StimulusReflex from 'stimulus_reflex' |
||||
import $ from 'jquery'; |
||||
|
||||
require("select2/dist/css/select2") |
||||
require("select2-bootstrap-theme/dist/select2-bootstrap") |
||||
|
||||
import Select2 from "select2" |
||||
|
||||
/* This is your ApplicationController. |
||||
* All StimulusReflex controllers should inherit from this class. |
||||
* |
||||
* Example: |
||||
* |
||||
* import ApplicationController from './application_controller' |
||||
* |
||||
* export default class extends ApplicationController { ... } |
||||
* |
||||
* Learn more at: https://docs.stimulusreflex.com
|
||||
*/ |
||||
export default class extends Controller { |
||||
connect () { |
||||
StimulusReflex.register(this) |
||||
} |
||||
|
||||
/* Application-wide lifecycle methods |
||||
* |
||||
* Use these methods to handle lifecycle concerns for the entire application. |
||||
* Using the lifecycle is optional, so feel free to delete these stubs if you don't need them. |
||||
* |
||||
* Arguments: |
||||
* |
||||
* element - the element that triggered the reflex |
||||
* may be different than the Stimulus controller's this.element |
||||
* |
||||
* reflex - the name of the reflex e.g. "Example#demo" |
||||
* |
||||
* error/noop - the error message (for reflexError), otherwise null |
||||
* |
||||
* reflexId - a UUID4 or developer-provided unique identifier for each Reflex |
||||
*/ |
||||
|
||||
beforeReflex (element, reflex, noop, reflexId) { |
||||
// document.body.classList.add('wait')
|
||||
} |
||||
|
||||
reflexSuccess (element, reflex, noop, reflexId) { |
||||
// show success message
|
||||
} |
||||
|
||||
reflexError (element, reflex, error, reflexId) { |
||||
// show error message
|
||||
} |
||||
|
||||
reflexHalted (element, reflex, error, reflexId) { |
||||
// handle aborted Reflex action
|
||||
} |
||||
|
||||
afterReflex (element, reflex, noop, reflexId) { |
||||
// document.body.classList.remove('wait')
|
||||
} |
||||
|
||||
finalizeReflex (element, reflex, noop, reflexId) { |
||||
// all operations have completed, animation etc is now safe
|
||||
} |
||||
} |
||||
@ -0,0 +1,17 @@
|
||||
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 |
||||
$.get("/api/jurisprudences/", { q: this.inputTarget.value }, function (data, status) { |
||||
if (status === "success") { |
||||
$this.stimulate("DocumentReflex#render_index_table", data) |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
@ -0,0 +1,73 @@
|
||||
import ApplicationController from './application_controller' |
||||
|
||||
/* This is the custom StimulusReflex controller for the Example Reflex. |
||||
* Learn more at: https://docs.stimulusreflex.com
|
||||
*/ |
||||
export default class extends ApplicationController { |
||||
/* |
||||
* Regular Stimulus lifecycle methods |
||||
* Learn more at: https://stimulusjs.org/reference/lifecycle-callbacks
|
||||
* |
||||
* If you intend to use this controller as a regular stimulus controller as well, |
||||
* make sure any Stimulus lifecycle methods overridden in ApplicationController call super. |
||||
* |
||||
* Important: |
||||
* By default, StimulusReflex overrides the -connect- method so make sure you |
||||
* call super if you intend to do anything else when this controller connects. |
||||
*/ |
||||
|
||||
connect () { |
||||
super.connect() |
||||
// add your code here, if applicable
|
||||
} |
||||
|
||||
/* Reflex specific lifecycle methods. |
||||
* |
||||
* For every method defined in your Reflex class, a matching set of lifecycle methods become available |
||||
* in this javascript controller. These are optional, so feel free to delete these stubs if you don't |
||||
* need them. |
||||
* |
||||
* Important: |
||||
* Make sure to add data-controller="example" to your markup alongside |
||||
* data-reflex="Example#dance" for the lifecycle methods to fire properly. |
||||
* |
||||
* Example: |
||||
* |
||||
* <a href="#" data-reflex="click->Example#dance" data-controller="example">Dance!</a> |
||||
* |
||||
* Arguments: |
||||
* |
||||
* element - the element that triggered the reflex |
||||
* may be different than the Stimulus controller's this.element |
||||
* |
||||
* reflex - the name of the reflex e.g. "Example#dance" |
||||
* |
||||
* error/noop - the error message (for reflexError), otherwise null |
||||
* |
||||
* reflexId - a UUID4 or developer-provided unique identifier for each Reflex |
||||
*/ |
||||
|
||||
// Assuming you create a "Example#dance" action in your Reflex class
|
||||
// you'll be able to use the following lifecycle methods:
|
||||
|
||||
// beforeDance(element, reflex, noop, reflexId) {
|
||||
// element.innerText = 'Putting dance shoes on...'
|
||||
// }
|
||||
|
||||
// danceSuccess(element, reflex, noop, reflexId) {
|
||||
// element.innerText = '\nDanced like no one was watching! Was someone watching?'
|
||||
// }
|
||||
|
||||
// danceError(element, reflex, error, reflexId) {
|
||||
// console.error('danceError', error);
|
||||
// element.innerText = "\nCouldn\'t dance!"
|
||||
// }
|
||||
|
||||
// afterDance(element, reflex, noop, reflexId) {
|
||||
// element.innerText = '\nWhatever that was, it\'s over now.'
|
||||
// }
|
||||
|
||||
// finalizeDance(element, reflex, noop, reflexId) {
|
||||
// element.innerText = '\nNow, the cleanup can begin!'
|
||||
// }
|
||||
} |
||||
@ -0,0 +1,18 @@
|
||||
// Visit The Stimulus Handbook for more details
|
||||
// https://stimulusjs.org/handbook/introduction
|
||||
//
|
||||
// This example controller works with specially annotated HTML like:
|
||||
//
|
||||
// <div data-controller="hello">
|
||||
// <h1 data-target="hello.output"></h1>
|
||||
// </div>
|
||||
|
||||
import { Controller } from "stimulus" |
||||
|
||||
export default class extends Controller { |
||||
static targets = [ "output" ] |
||||
|
||||
connect() { |
||||
this.outputTarget.textContent = 'Hello, Stimulus!' |
||||
} |
||||
} |
||||
@ -0,0 +1,14 @@
|
||||
// Load all the controllers within this directory and all subdirectories.
|
||||
// Controller files must be named *_controller.js.
|
||||
|
||||
import { Application } from "stimulus" |
||||
import { definitionsFromContext } from "stimulus/webpack-helpers" |
||||
import StimulusReflex from 'stimulus_reflex' |
||||
import consumer from '../channels/consumer' |
||||
import controller from '../controllers/application_controller' |
||||
|
||||
const application = Application.start() |
||||
const context = require.context("controllers", true, /_controller\.js$/) |
||||
application.load(definitionsFromContext(context)) |
||||
StimulusReflex.initialize(application, { consumer, controller }) |
||||
StimulusReflex.debug = process.env.RAILS_ENV === 'development' |
||||
@ -0,0 +1,11 @@
|
||||
import ApplicationController from './application_controller' |
||||
|
||||
export default class extends ApplicationController { |
||||
connect() { |
||||
super.connect() |
||||
|
||||
$(".subjects-select2").select2({ tags: true, width: "100%" }) |
||||
$(".annomark-ids-select2").select2({ width: "100%", dropdownParent: $("#editAnnotation11") }) |
||||
$(".subject-ids-modal-select2").select2({ width: "100%", dropdownParent: $("#doctrineModal") }) |
||||
} |
||||
} |
||||
@ -0,0 +1,10 @@
|
||||
import ApplicationController from './application_controller' |
||||
export default class extends ApplicationController { |
||||
connect () { |
||||
super.connect() |
||||
} |
||||
|
||||
load_roots() { |
||||
this.stimulate("SubjectsReflex#load_roots") |
||||
} |
||||
} |
||||
@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true |
||||
|
||||
class ApplicationReflex < StimulusReflex::Reflex |
||||
# Put application-wide Reflex behavior and callbacks in this file. |
||||
# |
||||
# Example: |
||||
# |
||||
# # If your ActionCable connection is: `identified_by :current_user` |
||||
# delegate :current_user, to: :connection |
||||
# |
||||
# Learn more at: https://docs.stimulusreflex.com/reflexes#reflex-classes |
||||
end |
||||
@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true |
||||
|
||||
class DocumentReflex < ApplicationReflex |
||||
include JurisprudenceSearch |
||||
|
||||
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 })) |
||||
# "<tr> <td> 1 </td> <td> 2 </td> <td> 3</td> </tr>" |
||||
end |
||||
end |
||||
@ -0,0 +1,35 @@
|
||||
# frozen_string_literal: true |
||||
|
||||
class ExampleReflex < ApplicationReflex |
||||
# Add Reflex methods in this file. |
||||
# |
||||
# All Reflex instances include CableReady::Broadcaster and expose the following properties: |
||||
# |
||||
# - connection - the ActionCable connection |
||||
# - channel - the ActionCable channel |
||||
# - request - an ActionDispatch::Request proxy for the socket connection |
||||
# - session - the ActionDispatch::Session store for the current visitor |
||||
# - flash - the ActionDispatch::Flash::FlashHash for the current request |
||||
# - url - the URL of the page that triggered the reflex |
||||
# - params - parameters from the element's closest form (if any) |
||||
# - element - a Hash like object that represents the HTML element that triggered the reflex |
||||
# - signed - use a signed Global ID to map dataset attribute to a model eg. element.signed[:foo] |
||||
# - unsigned - use an unsigned Global ID to map dataset attribute to a model eg. element.unsigned[:foo] |
||||
# - cable_ready - a special cable_ready that can broadcast to the current visitor (no brackets needed) |
||||
# - reflex_id - a UUIDv4 that uniquely identies each Reflex |
||||
# |
||||
# Example: |
||||
# |
||||
# before_reflex do |
||||
# # throw :abort # this will prevent the Reflex from continuing |
||||
# # learn more about callbacks at https://docs.stimulusreflex.com/lifecycle |
||||
# end |
||||
# |
||||
# def example(argument=true) |
||||
# # Your logic here... |
||||
# # Any declared instance variables will be made available to the Rails controller and view. |
||||
# end |
||||
# |
||||
# Learn more at: https://docs.stimulusreflex.com/reflexes#reflex-classes |
||||
|
||||
end |
||||
@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true |
||||
|
||||
class SubjectsReflex < ApplicationReflex |
||||
def load_roots |
||||
@roots = "Hello!!!" |
||||
end |
||||
end |
||||
@ -1696,6 +1696,13 @@ [email protected]:
|
||||
dependencies: |
||||
morphdom "^2.6.1" |
||||
|
||||
cable_ready@^5.0.0-pre8: |
||||
version "5.0.0-pre8" |
||||
resolved "https://registry.yarnpkg.com/cable_ready/-/cable_ready-5.0.0-pre8.tgz#fa1b4d6f980f631ff3c895f3007a6789b2e47de7" |
||||
integrity sha512-5TyAp0DcYiv15YGlAI4WqEBw8Mz/lARSz/pIwEEVWWUnqWQhbsMqCIYIsQoV3IXudKOowaSbukbPRYFN0PYzKg== |
||||
dependencies: |
||||
morphdom "^2.6.1" |
||||
|
||||
cacache@^12.0.2: |
||||
version "12.0.4" |
||||
resolved "https://registry.yarnpkg.com/cacache/-/cacache-12.0.4.tgz#668bcbd105aeb5f1d92fe25570ec9525c8faa40c" |
||||
@ -5952,6 +5959,11 @@ select-hose@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" |
||||
integrity sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo= |
||||
|
||||
select2-bootstrap-theme@^0.1.0-beta.10: |
||||
version "0.1.0-beta.10" |
||||
resolved "https://registry.yarnpkg.com/select2-bootstrap-theme/-/select2-bootstrap-theme-0.1.0-beta.10.tgz#b9426ecfc03bf4a235e76a132377574310469ac0" |
||||
integrity sha1-uUJuz8A79KI152oTI3dXQxBGmsA= |
||||
|
||||
select2@^4.1.0-rc.0: |
||||
version "4.1.0-rc.0" |
||||
resolved "https://registry.yarnpkg.com/select2/-/select2-4.1.0-rc.0.tgz#ba3cd3901dda0155e1c0219ab41b74ba51ea22d8" |
||||
|
||||
Loading…
Reference in new issue