Skip to content

Commit 183bc61

Browse files
author
Dave Newman
committed
Merge branch 'master' into job-board
2 parents dd970a4 + 5237313 commit 183bc61

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

app/controllers/jobs_controller.rb

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
11
class JobsController < ApplicationController
22

33
def index
4-
params[:show_fulltime] ||= true
5-
params[:show_remote] ||= true
6-
params[:show_contract] ||= true
7-
# raise params.inspect
84

5+
if [:show_fulltime, :show_parttime, :show_contract].any?{|s| params[s].blank? }
6+
redirect_to jobs_path(show_fulltime: true, show_parttime: true, show_contract: true, show_remote: false)
7+
return
8+
end
9+
roles = []
10+
roles.push(Job::FULLTIME) if params[:show_fulltime] == 'true'
11+
roles.push(Job::PARTTIME) if params[:show_parttime] == 'true'
12+
roles.push(Job::CONTRACT) if params[:show_contract] == 'true'
913
@jobs = Job.active.order(created_at: :desc)
1014

11-
# if params_true?(:show_fulltime)
12-
# @jobs = @jobs.
13-
# end
14-
# if params[:show_fulltime]
15-
#
16-
# where("role_type != ?", JOB::FULLTIME)
17-
# end
18-
19-
if !params[:show_contract]
20-
21-
end
15+
@jobs = @jobs.where('jobs.role_type in (?)', roles)
16+
@jobs = @jobs.where(location: 'Remote') if params[:show_remote] == 'true'
17+
@jobs = @jobs.where('jobs.location ilike :q or jobs.title ilike :q or jobs.company ilike :q', q: "%#{params[:q]}%") unless params[:q].blank?
2218

2319
if params[:posted]
2420
@jobs = @jobs.where.not(id: params[:posted])
2521
@featured = Job.find(params[:posted])
2622
end
27-
28-
2923
end
3024

3125
def new

app/views/jobs/index.html.haml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@
99
.clearfix.mb2.md-show
1010
.col.sm-col-11.py2
1111
=form_tag jobs_path, method: :get do
12-
= text_field_tag :q, params[:q], placeholder: 'Search great jobs by Location, Title, or Company', class: 'field col-6'
12+
= text_field_tag :q, params[:q], placeholder: 'Search great jobs by Location, Title, or Company', class: 'field col-5'
1313
.col-1.inline.ml1
14-
= check_box_tag :show_fulltime, true, params[:show_fulltime]
15-
= label_tag :show_fulltime, 'Full Time'
16-
= check_box_tag :show_contract, true, params[:show_contract]
17-
= label_tag :show_contract, 'Contracting'
18-
= check_box_tag :show_remote, true, params[:show_remote]
19-
= label_tag :show_remote, 'Remote'
14+
= hidden_field_tag :show_fulltime, false, id: nil
15+
= check_box_tag :show_fulltime, true, params[:show_fulltime] == 'true'
16+
= label_tag :show_fulltime, 'Full Time'
17+
18+
= hidden_field_tag :show_parttime, false, id: nil
19+
= check_box_tag :show_parttime, true, params[:show_parttime] == 'true'
20+
= label_tag :show_parttime, 'Part Time'
21+
22+
= hidden_field_tag :show_contract, false, id: nil
23+
= check_box_tag :show_contract, true, params[:show_contract] == 'true'
24+
= label_tag :show_contract, 'Contracting'
25+
26+
= hidden_field_tag :show_remote, false, id: nil
27+
= check_box_tag :show_remote, true, params[:show_remote] == 'true'
28+
= label_tag :show_remote, 'Remote jobs'
2029
.col-1.inline.ml1
2130
%button.btn.bg-purple.white.rounded{type: 'submit'}= icon('search')
2231
.col.sm-col-1

0 commit comments

Comments
 (0)