From 2ab170544b27f0584cd42ae9a677dc13e501af38 Mon Sep 17 00:00:00 2001 From: Yuichiro Makita Date: Mon, 13 Jan 2025 10:40:49 +0900 Subject: [PATCH] =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E6=A9=9F=E8=83=BD=E3=82=92?= =?UTF-8?q?=E6=8B=A1=E5=85=85=EF=BC=9A=E8=87=AA=E5=88=86=E3=81=AE=E3=81=BF?= =?UTF-8?q?=E3=81=AE=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=83=9C=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=B9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/searchables_controller.rb | 3 +++ app/views/application/header/_header_search.html.slim | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/app/controllers/api/searchables_controller.rb b/app/controllers/api/searchables_controller.rb index 0dee32ffb02..97f322f75fc 100644 --- a/app/controllers/api/searchables_controller.rb +++ b/app/controllers/api/searchables_controller.rb @@ -5,6 +5,9 @@ class API::SearchablesController < API::BaseController def index result = Searcher.search(params[:word], document_type: document_type_param) + + result = result.select { |record| record.user_id == current_user.id } if params[:only_logged_in_user] + @searchables = Kaminari.paginate_array(result).page(params[:page]).per(PAGER_NUMBER) end diff --git a/app/views/application/header/_header_search.html.slim b/app/views/application/header/_header_search.html.slim index bd5c37e5c49..5762d176b9a 100644 --- a/app/views/application/header/_header_search.html.slim +++ b/app/views/application/header/_header_search.html.slim @@ -2,6 +2,11 @@ .header-search__select.a-button.is-sm.is-secondary.is-select.is-block = select_tag 'document_type', options_for_select(Searcher::DOCUMENT_TYPES, params[:document_type]), id: select_id = text_field_tag 'word', params[:word], class: 'a-xs-text-input header-search__text-input', id: text_field_id, placeholder: '検索ワード' + + .header-search__checkbox + = check_box_tag 'only_logged_in_user', '1', params[:only_logged_in_user].present?, id: 'only_logged_in_user' + = label_tag 'only_logged_in_user', '自分のみ' + button.a-button.is-sm.is-secondary.is-icon.header-search__submit(id="#{submit_id}" type='submit') i.fa-solid.fa-search span