From 5d14333c33c1675708e663a53346d3963e7a6e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Mon, 27 Feb 2023 10:34:02 +0800 Subject: [PATCH] add backend search feature --- app/controllers/admin/journal_papers_controller.rb | 9 ++++++++- app/views/admin/journal_papers/index.html.erb | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/journal_papers_controller.rb b/app/controllers/admin/journal_papers_controller.rb index 9c656fc..098cff4 100644 --- a/app/controllers/admin/journal_papers_controller.rb +++ b/app/controllers/admin/journal_papers_controller.rb @@ -47,7 +47,14 @@ class Admin::JournalPapersController < OrbitMemberController end end def index - @writing_journals = JournalPaper.sort_year_date.page(params[:page]).per(10) + @writing_journals = JournalPaper.sort_year_date + if params[:keywords] + @writing_journals = search_data(@writing_journals,[:slug_title]) + end + @writing_journals = @writing_journals.page(params[:page]).per(10) + if request.xhr? + render :partial => "writing_journal" + end end def new diff --git a/app/views/admin/journal_papers/index.html.erb b/app/views/admin/journal_papers/index.html.erb index bf1d22f..7572e16 100644 --- a/app/views/admin/journal_papers/index.html.erb +++ b/app/views/admin/journal_papers/index.html.erb @@ -4,6 +4,7 @@ function MergeUrl(){ location.href = '<%= merge_admin_journal_papers_path %>' } +<%= render_filter nil, "tbody_writing_journals" %>