Skip to content

Commit

Permalink
hide filter link
Browse files Browse the repository at this point in the history
  • Loading branch information
usernaimandrey committed Dec 27, 2023
1 parent 5d48f46 commit 2ee5f25
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
12 changes: 9 additions & 3 deletions app/controllers/web/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

class Web::HomeController < Web::ApplicationController
def index
form = Web::Resumes::SearchForm.new(params[:q])
query = { s: 'id desc' }.merge(params.permit![:q] || {})
sanitize_query = if current_user_or_guest.admin?
query
else
query.except('answers_count_eq', 'answers_count_in', 'answers_user_id_eq')
end
form = Web::Resumes::SearchForm.new(sanitize_query)
@bot = AiBotHelper.ai_bot_user
@q = Resume.web.with_locale.ransack(form.to_h)
@resumes = @q.result(distinct: true).includes(:user, :skills).page(params[:page]).order(id: :desc)
@search = Resume.web.with_locale.ransack(form.to_h)
@resumes = @search.result(distinct: true).includes(:user, :skills).page(params[:page])
@page = params[:page]
@tags = Resume.directions_tags

Expand Down
7 changes: 4 additions & 3 deletions app/views/web/home/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
- content_for :header do
= t('.header')

= render partial: 'web/shared/resume_filter', locals: { query: @q, tags: @tags }
= render partial: 'web/shared/resume_filter', locals: { search: @search, tags: @tags }

.p-3.nav.nav-pills.mb-3.justify-content-center
= filter_link(t('.all'), {}, class: 'nav-item nav-link')
= filter_link(t('.popular'), { created_at_gteq: Date.current - 1.week, popular_gteq: Date.current - 1.week, s: 'impressions_count desc' }, class: 'nav-item nav-link')
= filter_link(t('.newest'), { created_at_gteq: Date.current - 1.day, s: 'created_at desc' }, class: 'nav-item nav-link')
= filter_link(t('.without_answers'), { answers_count_eq: 0 }, class: 'nav-item nav-link')
= filter_link(t('.without_answers_human'), { answers_count_in: [0, 1], answers_user_id_eq: @bot.id }, class: 'nav-item nav-link')
- if current_user_or_guest.admin?
= filter_link(t('.without_answers'), { answers_count_eq: 0 }, class: 'nav-item nav-link')
= filter_link(t('.without_answers_human'), { answers_count_in: [0, 1], answers_user_id_eq: @bot.id }, class: 'nav-item nav-link')

.mb-5
- @resumes.each_with_index do |resume, i|
Expand Down
2 changes: 1 addition & 1 deletion app/views/web/shared/_resume_filter.html.slim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.p-3.mb-3.bg-light.rounded-3
= search_form_for query, url: root_path, html: { novalidate: true, class: 'row row-cols-1 row-cols-sm-2 row-cols-lg-3 row-cols-xl-4 g-2 g-lg-3' } do |f|
= search_form_for search, url: root_path, html: { novalidate: true, class: 'row row-cols-1 row-cols-sm-2 row-cols-lg-3 row-cols-xl-4 g-2 g-lg-3' } do |f|
= f.input :name_cont, label: false, placeholder: t('.name')
= f.input :user_first_name_or_user_last_name_or_user_email_cont, label: false, placeholder: t('.user')
= f.input :directions_name_cont, as: :select_with_search, collection: tags, label: false, prompt: t('.directions')
Expand Down

0 comments on commit 2ee5f25

Please sign in to comment.