Commit 7204d6e1 by Mai Hoang Thai Ha

add helper to display location and breadcrumb

parent f3cf955b
......@@ -18,10 +18,6 @@ class JobsController < ApplicationController
model = params[:model].classify.constantize
@target = model.find_by(slug: job_params[:slug])
@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
......
......@@ -2,7 +2,7 @@ class TopController < ApplicationController
def index
@total_job = Job.count
@latest_jobs = Job.latest
@top_cities = City.top_jobs.take(City::TOP_JOB_COUNT)
@top_industries = Industry.top_jobs.take(Industry::TOP_JOB_COUNT)
@top_cities = City.top_jobs
@top_industries = Industry.top_jobs
end
end
......@@ -7,4 +7,23 @@ module ApplicationHelper
"#{page_title} | #{base_title}"
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
......@@ -22,12 +22,7 @@
| Salary: #{job.salary}
ul.list-unstyled
- city_list = job.cities
- city_list.each_with_index do |city, i|
span
= city.name
- if i != city_list.length - 1
span.mx-1
| |
= show_location(city_list)
.job-desc
= truncate(simple_format(job.description), escape: false, length: 250)
hr.my-4
......
......@@ -6,26 +6,14 @@ ruby:
.container.my-5
/ breadcrumb
.breadcrumb
= link_to root_path, class: 'text-decoration-none text-info' do
'Home
span.d-block.mx-2
| >
- city_list.each_with_index do |city, i|
= link_to job_list_path(model: :city, slug: city.slug), class: 'text-decoration-none text-info' do
= city.name
- if i != city_list.length - 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
| >
= link_to 'Home', root_path, class: 'text-decoration-none text-info'
span.mx-1 >
.text-info
= show_breadcrumb(city_list, :city)
span.mx-1 >
.text-info
= show_breadcrumb(industry_list, :industry)
span.mx-1 >
= @job.title
hr.my-4
......@@ -43,13 +31,8 @@ ruby:
li
strong.d-block
| Location
- city_list = @job.cities
- city_list.each_with_index do |city, i|
span
= city.name
- if i != city_list.length - 1
span.mx-1
||
p
= show_location(city_list)
li
strong
| Salary
......@@ -78,7 +61,7 @@ ruby:
strong
| Expiration date
p
= @job.expiration_date.in_time_zone("Hanoi").to_date
= @job.expiration_date.strftime('%d/%m/%Y')
.job-benefits.my-4
h3
| Benefits
......@@ -89,11 +72,11 @@ ruby:
.job-desc.my-4
h3
| Description
= @job.description.html_safe()
= @job.description.html_safe
.job-req.my-4
h3
| Requirement
= @job.requirement.html_safe()
= @job.requirement.html_safe
.job-info.my-4
h3
| Other info
......
......@@ -24,12 +24,7 @@
= job.salary
.job-locations
- city_list = job.cities
- city_list.each_with_index do |city, i|
span
= city.name
- if i != city_list.length - 1
span.mx-1
| |
= show_location(job.cities)
.job-desc
= truncate(simple_format(job.description), escape: false, length: 250)
hr.my-2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment