Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VenJob
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mai Hoang Thai Ha
VenJob
Commits
7204d6e1
Commit
7204d6e1
authored
Aug 10, 2021
by
Mai Hoang Thai Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add helper to display location and breadcrumb
parent
f3cf955b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
48 deletions
+36
-48
app/controllers/jobs_controller.rb
+0
-4
app/controllers/top_controller.rb
+2
-2
app/helpers/application_helper.rb
+19
-0
app/views/jobs/index.html.slim
+1
-6
app/views/jobs/show.html.slim
+13
-30
app/views/top/index.html.slim
+1
-6
No files found.
app/controllers/jobs_controller.rb
View file @
7204d6e1
...
@@ -18,10 +18,6 @@ class JobsController < ApplicationController
...
@@ -18,10 +18,6 @@ class JobsController < ApplicationController
model
=
params
[
:model
].
classify
.
constantize
model
=
params
[
:model
].
classify
.
constantize
@target
=
model
.
find_by
(
slug:
job_params
[
:slug
])
@target
=
model
.
find_by
(
slug:
job_params
[
:slug
])
@jobs
=
@target
.
jobs
.
includes
(
:company
,
:cities_jobs
,
:cities
).
page
(
params
[
:page
]).
per
(
Job
::
JOB_PER_PAGE
)
@jobs
=
@target
.
jobs
.
includes
(
:company
,
:cities_jobs
,
:cities
).
page
(
params
[
:page
]).
per
(
Job
::
JOB_PER_PAGE
)
elsif
job_params
.
key?
(
:search
)
# search by keywords
wildcard_search
=
"%
#{
job_params
[
:search
]
}
%"
@jobs
=
Job
.
where
(
'name ILIKE ? OR postal_code LIKE ?'
,
wildcard_search
,
wildcard_search
)
.
page
(
params
[
:page
]).
per
(
Job
::
JOB_PER_PAGE
)
end
end
end
end
...
...
app/controllers/top_controller.rb
View file @
7204d6e1
...
@@ -2,7 +2,7 @@ class TopController < ApplicationController
...
@@ -2,7 +2,7 @@ class TopController < ApplicationController
def
index
def
index
@total_job
=
Job
.
count
@total_job
=
Job
.
count
@latest_jobs
=
Job
.
latest
@latest_jobs
=
Job
.
latest
@top_cities
=
City
.
top_jobs
.
take
(
City
::
TOP_JOB_COUNT
)
@top_cities
=
City
.
top_jobs
@top_industries
=
Industry
.
top_jobs
.
take
(
Industry
::
TOP_JOB_COUNT
)
@top_industries
=
Industry
.
top_jobs
end
end
end
end
app/helpers/application_helper.rb
View file @
7204d6e1
...
@@ -7,4 +7,23 @@ module ApplicationHelper
...
@@ -7,4 +7,23 @@ module ApplicationHelper
"
#{
page_title
}
|
#{
base_title
}
"
"
#{
page_title
}
|
#{
base_title
}
"
end
end
end
end
def
show_location
(
list
)
list
.
map
(
&
:name
).
join
(
' | '
)
end
def
show_breadcrumb
(
list
,
model
)
a
=
list
.
map
do
|
item
|
link_to
item
.
name
,
job_list_path
(
model:
model
,
slug:
item
.
slug
),
class:
'mx-1 text-decoration-none text-info'
end
a
.
join
(
'|'
).
html_safe
end
# breadcrumb
# def show_breadcrumb(job)
# a = link_to 'Home', root_path, class: 'text-decoration-none text-info mx-1 '
# span = tag.span '>', class: 'mx-1'
# arr = [a, show_item(job.cities, :city), show_item(job.industries, :industry), job.title]
# arr.join(span).html_safe
# end
end
end
app/views/jobs/index.html.slim
View file @
7204d6e1
...
@@ -22,12 +22,7 @@
...
@@ -22,12 +22,7 @@
|
Salary:
#{
job
.
salary
}
|
Salary:
#{
job
.
salary
}
ul
.list-unstyled
ul
.list-unstyled
-
city_list
=
job
.
cities
-
city_list
=
job
.
cities
-
city_list
.
each_with_index
do
|
city
,
i
|
=
show_location
(
city_list
)
span
=
city
.
name
-
if
i
!=
city_list
.
length
-
1
span
.mx-1
|
|
.job-desc
.job-desc
=
truncate
(
simple_format
(
job
.
description
),
escape:
false
,
length:
250
)
=
truncate
(
simple_format
(
job
.
description
),
escape:
false
,
length:
250
)
hr
.my-4
hr
.my-4
...
...
app/views/jobs/show.html.slim
View file @
7204d6e1
...
@@ -6,26 +6,14 @@ ruby:
...
@@ -6,26 +6,14 @@ ruby:
.container.my-5
.container.my-5
/ breadcrumb
/ breadcrumb
.breadcrumb
.breadcrumb
=
link_to
root_path
,
class:
'text-decoration-none text-info'
do
=
link_to
'Home'
,
root_path
,
class:
'text-decoration-none text-info'
'
Home
span
.mx-1
>
span
.d-block.mx-2
.text-info
|
>
=
show_breadcrumb
(
city_list
,
:city
)
-
city_list
.
each_with_index
do
|
city
,
i
|
span
.mx-1
>
=
link_to
job_list_path
(
model: :city
,
slug:
city
.
slug
),
class:
'text-decoration-none text-info'
do
.text-info
=
city
.
name
=
show_breadcrumb
(
industry_list
,
:industry
)
-
if
i
!=
city_list
.
length
-
1
span
.mx-1
>
span
.mx-1.text-info
|
|
span
.d-block.mx-2
|
>
-
industry_list
.
each_with_index
do
|
industry
,
i
|
=
link_to
job_list_path
(
model: :industry
,
slug:
industry
.
slug
),
class:
'text-decoration-none text-info'
do
=
industry
.
name
-
if
i
!=
industry_list
.
length
-
1
span
.mx-1.text-info
|
|
span
.d-block.mx-2
|
>
=
@job
.
title
=
@job
.
title
hr
.my-4
hr
.my-4
...
@@ -43,13 +31,8 @@ ruby:
...
@@ -43,13 +31,8 @@ ruby:
li
li
strong
.d-block
strong
.d-block
|
Location
|
Location
-
city_list
=
@job
.
cities
p
-
city_list
.
each_with_index
do
|
city
,
i
|
=
show_location
(
city_list
)
span
=
city
.
name
-
if
i
!=
city_list
.
length
-
1
span
.mx-1
|
|
li
li
strong
strong
|
Salary
|
Salary
...
@@ -78,7 +61,7 @@ ruby:
...
@@ -78,7 +61,7 @@ ruby:
strong
strong
|
Expiration date
|
Expiration date
p
p
=
@job
.
expiration_date
.
in_time_zone
(
"Hanoi"
).
to_date
=
@job
.
expiration_date
.
strftime
(
'%d/%m/%Y'
)
.job-benefits.my-4
.job-benefits.my-4
h3
h3
|
Benefits
|
Benefits
...
@@ -89,11 +72,11 @@ ruby:
...
@@ -89,11 +72,11 @@ ruby:
.job-desc.my-4
.job-desc.my-4
h3
h3
|
Description
|
Description
=
@job
.
description
.
html_safe
()
=
@job
.
description
.
html_safe
.job-req.my-4
.job-req.my-4
h3
h3
|
Requirement
|
Requirement
=
@job
.
requirement
.
html_safe
()
=
@job
.
requirement
.
html_safe
.job-info.my-4
.job-info.my-4
h3
h3
|
Other info
|
Other info
...
...
app/views/top/index.html.slim
View file @
7204d6e1
...
@@ -24,12 +24,7 @@
...
@@ -24,12 +24,7 @@
=
job
.
salary
=
job
.
salary
.job-locations
.job-locations
-
city_list
=
job
.
cities
-
city_list
=
job
.
cities
-
city_list
.
each_with_index
do
|
city
,
i
|
=
show_location
(
job
.
cities
)
span
=
city
.
name
-
if
i
!=
city_list
.
length
-
1
span
.mx-1
|
|
.job-desc
.job-desc
=
truncate
(
simple_format
(
job
.
description
),
escape:
false
,
length:
250
)
=
truncate
(
simple_format
(
job
.
description
),
escape:
false
,
length:
250
)
hr
.my-2
hr
.my-2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment