From 724e16c4c362bd9c2e2e9acafe8754c92859cacf Mon Sep 17 00:00:00 2001 From: alexdbondoc17 Date: Tue, 1 Mar 2022 03:54:06 +0000 Subject: [PATCH] Fix search for `annotations` --- app/controllers/doctrines_controller.rb | 2 +- app/controllers/document/doctrines_controller.rb | 2 +- app/javascript/controllers/annotations_controller.js | 2 +- app/reflexes/annotation_reflex.rb | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/doctrines_controller.rb b/app/controllers/doctrines_controller.rb index 5d8a2fa..1c47891 100644 --- a/app/controllers/doctrines_controller.rb +++ b/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 diff --git a/app/controllers/document/doctrines_controller.rb b/app/controllers/document/doctrines_controller.rb index 14f4349..0b767a3 100644 --- a/app/controllers/document/doctrines_controller.rb +++ b/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 diff --git a/app/javascript/controllers/annotations_controller.js b/app/javascript/controllers/annotations_controller.js index 7663531..50a2119 100644 --- a/app/javascript/controllers/annotations_controller.js +++ b/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"] }) } } diff --git a/app/reflexes/annotation_reflex.rb b/app/reflexes/annotation_reflex.rb index 88b5386..dfff1c0 100644 --- a/app/reflexes/annotation_reflex.rb +++ b/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