Skip to content

Commit 64915bf

Browse files
committed
Add unemployment check, fix styles and seeds.
1 parent f539c04 commit 64915bf

14 files changed

+148
-84
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ gem "validate_url", "~> 1.0"
1919
gem "rexml", ">= 3.3.2"
2020

2121
group :development, :test do
22+
gem "byebug", "~> 11.1", ">= 11.1.3"
2223
gem "debug", "~> 1.9", ">= 1.9.2", platforms: %i[mri windows]
2324
gem "dotenv", "~> 3.1", ">= 3.1.2"
2425
gem "factory_bot_rails", "~> 6.4", ">= 6.4.3"

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ GEM
9898
bundler-audit (0.9.1)
9999
bundler (>= 1.2.0, < 3)
100100
thor (~> 1.0)
101+
byebug (11.1.3)
101102
childprocess (5.0.0)
102103
colorize (1.1.0)
103104
concurrent-ruby (1.2.3)
@@ -351,6 +352,7 @@ DEPENDENCIES
351352
bootsnap (~> 1.18, >= 1.18.3)
352353
brakeman
353354
bundler-audit (~> 0.9.1)
355+
byebug (~> 11.1, >= 11.1.3)
354356
colorize (~> 1.1)
355357
debug (~> 1.9, >= 1.9.2)
356358
devise (~> 4.9)

app/controllers/job_applications_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def set_job_application
9696
end
9797

9898
def job_application_params
99-
params.require(:job_application).permit(:date_applied, :company_name, :method_of_contact, :email_address, :point_of_contact, :website_link, :position_type, :position_title)
99+
params.require(:job_application).permit(:date_applied, :company_name, :method_of_contact, :email_address, :point_of_contact, :website_link, :position_type, :position_title, :claimed_for_unemployment)
100100
end
101101

102102
def filter_and_sort_job_applications
@@ -105,6 +105,8 @@ def filter_and_sort_job_applications
105105
job_applications = job_applications.search(params[:search]) if params[:search].present?
106106
job_applications = job_applications.by_method_of_contact(params[:method_of_contact]) if params[:method_of_contact].present?
107107
job_applications = job_applications.by_position_type(params[:position_type]) if params[:position_type].present?
108+
job_applications = job_applications.claimed_for_unemployment if params[:claimed_for_unemployment] == "true"
109+
job_applications = job_applications.not_claimed_for_unemployment if params[:claimed_for_unemployment] == "false"
108110

109111
sort_column = sort_column(params[:sort])
110112
sort_direction = sort_direction(params[:direction])
@@ -119,7 +121,7 @@ def filter_and_sort_job_applications
119121
end
120122

121123
def sort_column(column)
122-
%w[date_applied company_name position_title created_at].include?(column) ? column : "created_at"
124+
%w[date_applied company_name position_title created_at claimed_for_unemployment].include?(column) ? column : "created_at"
123125
end
124126

125127
def sort_direction(direction)

app/helpers/application_helper.rb

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,31 @@ def progress_bar_class(type)
3232
end
3333

3434
def sort_link_to(name, column)
35-
direction = (column.to_s == params[:sort] && params[:direction] == "asc") ? "desc" : "asc"
36-
link_to name,
37-
request.params.merge(sort: column, direction: direction),
38-
class: "text-gray-600 hover:text-gray-900",
35+
current_column = params[:sort]
36+
current_direction = params[:direction]
37+
38+
is_current_column = column.to_s == current_column
39+
next_direction = (is_current_column && current_direction == "asc") ? "desc" : "asc"
40+
41+
icon = if is_current_column
42+
(current_direction == "asc") ? "↑" : "↓"
43+
else
44+
""
45+
end
46+
47+
link_to request.params.merge(sort: column, direction: next_direction),
48+
class: "text-gray-600 hover:text-gray-900 inline-flex items-center",
3949
data: {
4050
turbo_frame: "job_applications_table",
4151
turbo_action: "replace"
42-
}
52+
} do
53+
content_tag(:span, class: "flex items-center") do
54+
safe_join([
55+
content_tag(:span, name, class: "mr-1"),
56+
content_tag(:span, icon, class: "sort-icon")
57+
])
58+
end
59+
end
4360
end
4461

4562
def safe_url(url)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
module JobApplicationsHelper
2+
def display_position_type(position_type)
3+
case position_type
4+
when "full_time" then "Full-time"
5+
when "part_time" then "Part-time"
6+
when "internship" then "Internship"
7+
else
8+
position_type
9+
end
10+
end
211
end

app/models/job_application.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ class JobApplication < ApplicationRecord
99
no_local: true,
1010
public_suffix: true
1111
}
12+
validates :claimed_for_unemployment, inclusion: {in: [true, false]}
13+
1214
enum method_of_contact: {email: "email", phone: "phone", internet_job_application: "internet job application", recruiter: "recruiter", other: "other"}
13-
enum position_type: {full_time: "full-time", part_time: "part-time", internship: "internship"}
15+
enum position_type: {
16+
full_time: "full_time",
17+
part_time: "part_time",
18+
internship: "internship"
19+
}
1420

1521
scope :search, ->(query) { where("company_name ILIKE ? OR position_title ILIKE ?", "%#{query}%", "%#{query}%") }
1622
scope :by_method_of_contact, ->(method) { where(method_of_contact: method) }
1723
scope :by_position_type, ->(type) { where(position_type: type) }
24+
scope :claimed_for_unemployment, -> { where(claimed_for_unemployment: true) }
25+
scope :not_claimed_for_unemployment, -> { where(claimed_for_unemployment: false) }
1826
end

app/views/job_applications/_form.html.erb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@
4444
</div>
4545
<div>
4646
<%= form.label :position_type, class: 'block text-sm font-medium text-gray-700 mb-2' %>
47-
<%= form.select :position_type, JobApplication.position_types.keys.map { |k| [k.humanize, k] }, { include_blank: 'Select a type' }, class: 'shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline' %>
47+
<%= form.select :position_type, JobApplication.position_types.keys.map { |k| [display_position_type(k), k] }, { include_blank: 'Select a type' }, class: 'shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline' %>
4848
</div>
4949
<div>
5050
<%= form.label :position_title, class: 'block text-sm font-medium text-gray-700 mb-2' %>
5151
<%= form.text_field :position_title, class: 'shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline' %>
5252
</div>
53+
<div class="mt-2">
54+
<%= form.label :claimed_for_unemployment, class: 'flex items-center' do %>
55+
<%= form.check_box :claimed_for_unemployment, class: 'h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded mr-2' %>
56+
<span class="text-sm font-medium text-gray-700">Claimed for Unemployment</span>
57+
<% end %>
58+
</div>
5359
</div>
5460
<div class="flex items-center justify-end mt-6">
5561
<%= link_to 'Cancel', root_path, class: 'bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline mr-2', data: { turbo_frame: "_top" } %>

app/views/job_applications/_job_application.html.erb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<tr id="<%= dom_id(job_application) %>">
1+
<tr class="h-20" id="<%= dom_id(job_application) %>">
22
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
33
<%= job_application.date_applied.strftime('%m/%d/%Y') %>
44
</td>
@@ -9,17 +9,20 @@
99
<%= job_application.position_title %>
1010
</td>
1111
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
12-
<%= job_application.position_type.humanize %>
12+
<%= display_position_type(job_application.position_type) %>
1313
</td>
1414
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
1515
<%= job_application.method_of_contact.humanize %>
1616
</td>
1717
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
18-
<%= job_application.point_of_contact || '-' %>
18+
<%= job_application.point_of_contact.present? ? job_application.point_of_contact : '-' %>
1919
</td>
2020
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
2121
<%= job_application.email_address.present? ? job_application.email_address : '-' %>
2222
</td>
23+
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
24+
<%= job_application.claimed_for_unemployment ? '✔︎' : '-' %>
25+
</td>
2326
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
2427
<% if job_application.website_link.present? %>
2528
<%= link_to 'Visit',
Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,54 @@
11
<%= turbo_frame_tag "job_applications_table" do %>
22
<div class="overflow-x-auto bg-white shadow-md rounded-lg">
33
<% if @job_applications.any? %>
4-
<table class="min-w-full leading-normal">
5-
<thead class="text-xs">
4+
<table class="w-full">
5+
<thead class="text-xs bg-gray-100 text-left font-semibold text-gray-600 w-8 border-b-2">
66
<tr>
7-
<tr>
8-
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left font-semibold text-gray-600 tracking-wider">
9-
<%= sort_link_to 'Date Applied', 'date_applied' %>
10-
</th>
11-
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left font-semibold text-gray-600 tracking-wider">
12-
<%= sort_link_to 'Company Name', 'company_name' %>
13-
</th>
14-
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left font-semibold text-gray-600 tracking-wider">
15-
<%= sort_link_to 'Position', 'position_title' %>
16-
</th>
17-
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left font-semibold text-gray-600 tracking-wider">
18-
Type
19-
</th>
20-
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left font-semibold text-gray-600 tracking-wider">
21-
Contact Method
22-
</th>
23-
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left font-semibold text-gray-600 tracking-wider">
24-
P.o.C.
25-
</th>
26-
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left font-semibold text-gray-600 tracking-wider">
27-
Email
28-
</th>
29-
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left font-semibold text-gray-600 tracking-wider">
30-
Website
31-
</th>
32-
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left font-semibold text-gray-600 tracking-wider">
33-
Actions
34-
</th>
35-
</tr>
36-
</thead>
37-
<tbody id="job_applications">
38-
<%= render partial: 'job_application', collection: job_applications %>
39-
</tbody>
40-
</table>
41-
<% else %>
42-
<div class="text-center py-10">
43-
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
44-
<path vector-effect="non-scaling-stroke" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z" />
45-
</svg>
46-
<p class="mt-1 text-sm text-gray-500">
47-
<%= "No results match your search criteria." if params[:search].present? || params[:method_of_contact].present? || params[:position_type].present? %>
48-
</p>
49-
</div>
50-
<% end %>
51-
</div>
52-
<% end %>
7+
<th class="px-5 py-3 w-8">
8+
<%= sort_link_to 'Applied', 'date_applied' %>
9+
</th>
10+
<th class="px-5 py-3 w-48">
11+
<%= sort_link_to 'Company', 'company_name' %>
12+
</th>
13+
<th class="px-5 py-3 w-48">
14+
<%= sort_link_to 'Position', 'position_title' %>
15+
</th>
16+
<th class="px-5 py-3">
17+
Type
18+
</th>
19+
<th class="px-5 py-3 w-48">
20+
Contact Method
21+
</th>
22+
<th class="px-5 py-3 w-48">
23+
P.o.C.
24+
</th>
25+
<th class="px-5 py-3 w-96">
26+
Email
27+
</th>
28+
<th class="px-5 py-3">
29+
<%= sort_link_to 'Claimed', 'claimed_for_unemployment' %>
30+
</th>
31+
<th class="px-5 py-3">
32+
Website
33+
</th>
34+
<th class="px-5 py-3">
35+
Actions
36+
</th>
37+
</tr>
38+
</thead>
39+
<tbody id="job_applications">
40+
<%= render partial: 'job_application', collection: job_applications %>
41+
</tbody>
42+
</table>
43+
<% else %>
44+
<div class="text-center py-10">
45+
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
46+
<path vector-effect="non-scaling-stroke" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z" />
47+
</svg>
48+
<p class="mt-1 text-sm text-gray-500">
49+
<%= "No results match your search criteria." if params[:search].present? || params[:method_of_contact].present? || params[:position_type].present? %>
50+
</p>
51+
</div>
52+
<% end %>
53+
</div>
54+
<% end %>
Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
<div class="fixed bottom-0 left-0 w-full z-50">
2-
<% if @pagination_info[:total_pages] > 1 %>
3-
<div class="flex items-center justify-between border-t border-gray-200 bg-white px-4 py-3 sm:px-6 shadow appearance-none rounded w-full text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
4-
<div class="text-sm text-gray-700">
5-
</div>
6-
<div>
7-
<%= will_paginate @job_applications,
8-
renderer: CustomPaginationRenderer,
9-
previous_label: 'Previous',
10-
next_label: 'Next',
11-
inner_window: 0,
12-
outer_window: 0,
13-
class: 'pagination',
14-
previous_page_class: 'px-3 py-1 rounded-md text-sm font-medium text-gray-700 bg-white border border-gray-300 hover:bg-gray-50',
15-
next_page_class: 'px-3 py-1 rounded-md text-sm font-medium text-gray-700 bg-white border border-gray-300 hover:bg-gray-50' %>
16-
</div>
1+
<% if @pagination_info[:total_pages] > 1 %>
2+
<div class="flex items-center justify-between border-t border-gray-200 bg-white px-4 py-3 sm:px-6 shadow appearance-none border rounded w-full text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
3+
<div class="text-sm text-gray-700">
174
</div>
18-
<% end %>
19-
</div>
5+
<div>
6+
<%= will_paginate @job_applications,
7+
renderer: CustomPaginationRenderer,
8+
previous_label: 'Previous',
9+
next_label: 'Next',
10+
inner_window: 0,
11+
outer_window: 0,
12+
class: 'pagination',
13+
previous_page_class: 'px-3 py-1 rounded-md text-sm font-medium text-gray-700 bg-white border border-gray-300 hover:bg-gray-50',
14+
next_page_class: 'px-3 py-1 rounded-md text-sm font-medium text-gray-700 bg-white border border-gray-300 hover:bg-gray-50' %>
15+
</div>
16+
</div>
17+
<% end %>

0 commit comments

Comments
 (0)