Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

検索機能を拡充:自分のみのチェックボックスを追加 #8277

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/controllers/api/searchables_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions app/views/application/header/_header_search.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading