Skip to content

Commit

Permalink
fix search
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Jul 5, 2024
1 parent b6ea656 commit cc0987d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
10 changes: 1 addition & 9 deletions app/controllers/people_skills/filter_form_controller.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
# frozen_string_literal: true

class PeopleSkills::FilterFormController < CrudController
class PeopleSkills::FilterFormController < ApplicationController
include ParamConverters

helper_method :filter_params

def self.model_class
PeopleSkill
end

def self.controller_path
'people_skills/filter_form'
end

private

def filter_params
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/people_skills/filter_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def interests
end

def rows
[@params[:rows].to_i, 1].max
@params[:rows].to_i
end

def rows_count
Expand Down
11 changes: 0 additions & 11 deletions app/views/people_skills/filter_form/_index.html.haml

This file was deleted.

14 changes: 13 additions & 1 deletion app/views/people_skills/filter_form/index.html.haml
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
= render "people_skills/filter_form/index"
%turbo-frame{id: "search-filters"}
%div{"data-controller": "people-skills-filter"}
= form_with(url: people_skills_path, method: :get, class: "filter-form", data: {"people-skills-filter-target": "form"}) do |form|
%div.filter-container.me-1#filter-row-0
= render("people_skills/search_form", form: form, row_number: 0, filter_params: filter_params)
- filter_params.rows.times do |i|
%div.d-flex.flex-row.align-items-center{"data-people-skills-filter-target": "filter", id: "filter-row-#{i+ 1}"}
%div.filter-container.me-1
= render("people_skills/search_form", form: form, row_number: i + 1)
= close_action_link "#", {data: {action: "click->people-skills-filter#remove", "people-skills-filter-id-param": i}, id: "remove-row-#{i+1}"}
- if filter_params.rows < 4
- path = filter_form_people_skills_path(rows: filter_params.rows + 1) + "&#{filter_params.query_params}"
= add_action_link path, {}, {data: {"turbo-frame": "search-filters"}, id: "add-row-button"}
12 changes: 11 additions & 1 deletion app/views/people_skills/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
%div.mt-3{"data-controller": "people-skills-filter"}
= render "people_skills/filter_form/index"
%turbo-frame{id: "search-filters"}
= form_with(url: people_skills_path, method: :get, class: "filter-form", data: {"people-skills-filter-target": "form"}) do |form|
- filter_params.rows_count.times do |i|
%div.d-flex.flex-row.align-items-center{"data-people-skills-filter-target": "filter", id: "filter-row-#{i}"}
%div.filter-container.me-1
= render("search_form", form: form, row_number: i, filter_params: filter_params)
- if i != 0
= close_action_link "#", {data: {action: "click->people-skills-filter#remove", "people-skills-filter-id-param": i}, id: "remove-row-#{i+1}"}
- if filter_params.rows_count < 5
- path = filter_form_people_skills_path(rows: filter_params.rows + 1) + "&#{filter_params.query_params}"
= add_action_link path, {}, {data: {"turbo-frame": "search-filters"}, id: "add-row-button"}
%div.profile-header.mw-100.border-bottom.mt-4.fw-normal
= ti "search.search_results"
%turbo-frame{id: "search-results"}
Expand Down
4 changes: 3 additions & 1 deletion spec/features/people_skill_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
visit(people_skills_path)
fill_out_row("JUnit", 5, 3)
add_and_fill_out_row("Rails", 4, 5)
require 'pry'; binding.pry # rubocop:disable Style/Semicolon,Lint/Debugger
add_and_fill_out_row("ember", 5, 4)
add_and_fill_out_row("Bash", 5, 2)
add_and_fill_out_row("cunit", 5, 2)
Expand Down Expand Up @@ -66,7 +67,8 @@


# remove skill filter
page.find('#remove-row-1').click
require 'pry'; binding.pry # rubocop:disable Style/Semicolon,Lint/Debugger
page.find('#remove-row-2').click
expect(page).to have_text("Alice Mante")
expect(page).to have_text("Wally Allround")
expect(page).to have_text("Hope Sunday")
Expand Down
1 change: 0 additions & 1 deletion spec/features/skills_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def fill_out_form

it 'can save edited skill' do
visit skills_path
require 'pry'; binding.pry # rubocop:disable Style/Semicolon,Lint/Debugger
page.all('.icon.icon-pencil')[1].click
fill_out_form
save_button = page.find("input[type='image']")
Expand Down

0 comments on commit cc0987d

Please sign in to comment.