Browse Source

Fix search for `annotations`

pull/83/head
alexdbondoc17 4 years ago
parent
commit
724e16c4c3
  1. 2
      app/controllers/doctrines_controller.rb
  2. 2
      app/controllers/document/doctrines_controller.rb
  3. 2
      app/javascript/controllers/annotations_controller.js
  4. 3
      app/reflexes/annotation_reflex.rb

2
app/controllers/doctrines_controller.rb

@ -25,7 +25,7 @@ class DoctrinesController < ApplicationController
def show
@jurisprudence = @doctrine.doctrine_jurisprudences.present? ? @doctrine.doctrine_jurisprudences.first.jurisprudence : nil
search = annotation_search(params.permit(:page, :per_page))
search = annotation_search({ doctrine_id: @doctrine.id })
@annotations = search.results
end

2
app/controllers/document/doctrines_controller.rb

@ -6,7 +6,7 @@ class Document::DoctrinesController < ApplicationController
def show
search = annotation_search(params.permit(:page, :per_page))
search = annotation_search({ doctrine_id: @doctrine.id })
@annotations = search.results
end
end

2
app/javascript/controllers/annotations_controller.js

@ -110,6 +110,6 @@ export default class extends ApplicationController {
}
paginate () {
this.stimulate("AnnotationReflex#render_annotations_views", { page: this.element.dataset["page"] })
this.stimulate("AnnotationReflex#render_annotations_views", { doctrine_id: this.element.dataset["doctrineId"], page: this.element.dataset["page"] })
}
}

3
app/reflexes/annotation_reflex.rb

@ -14,6 +14,7 @@ class AnnotationReflex < ApplicationReflex
def render_annotations_views(search_params)
search = annotation_search(search_params)
@annotations = search.results
morph "#annotationsIndexView", render(partial: "/shared/annotations_index_view", locals: { annotations: @annotations, opts: { current_page: search_params[:page] } })
morph "#annotationsIndexView", render(partial: "/shared/annotations_index_view", locals: { annotations: @annotations,
opts: { doctrine_id: search_params[:doctrine_id], current_page: search_params[:page] } })
end
end

Loading…
Cancel
Save