Commit b3617479 by Thanh Hung Pham

Merge branch 'job-detail' into 'master'

page ID20

See merge request !6
parents 8e8ffb2c acaf9342
Pipeline #1385 failed with stages
in 0 seconds
@import "bootstrap"; @import "bootstrap";
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700&display=swap');
/* header */
#logo { #logo {
float: left; float: left;
margin-right: 10px; margin-right: 10px;
...@@ -24,6 +23,7 @@ ...@@ -24,6 +23,7 @@
.container p { .container p {
font-weight: 400; font-weight: 400;
font-size: medium; font-size: medium;
text-align: justify;
} }
a { a {
color: rgb(14, 14, 14); color: rgb(14, 14, 14);
...@@ -58,3 +58,8 @@ ...@@ -58,3 +58,8 @@
} }
} }
.apply-job .btn {
align-items: center;
justify-content: center;
}
class JobsController < ApplicationController class JobsController < ApplicationController
def show def index
if params[:city_slug].present? if params[:city_slug].present?
city = City.find_by(slug: params[:city_slug]) city = City.find_by(slug: params[:city_slug])
jobs = city.jobs jobs = city.jobs
...@@ -12,4 +12,8 @@ class JobsController < ApplicationController ...@@ -12,4 +12,8 @@ class JobsController < ApplicationController
@total = jobs.count @total = jobs.count
@jobs = jobs.latest_jobs.page(params[:page]) @jobs = jobs.latest_jobs.page(params[:page])
end end
def show
@job = Job.latest_jobs.find_by(slug: params[:job_slug])
end
end end
\ No newline at end of file
class TopController < ApplicationController class TopController < ApplicationController
def home def index
@jobs = Job.latest_jobs.limit(Job::LATEST_JOB_NUMBER) @jobs = Job.latest_jobs.limit(Job::LATEST_JOB_NUMBER)
@cities = City.top_cities @cities = City.top_cities
@industries = Industry.top_industries @industries = Industry.top_industries
......
module ApplicationHelper module ApplicationHelper
def format_datetime(input)
return if input.nil?
input.strftime('%d/%m/%Y')
end
end end
class Job < ApplicationRecord class Job < ApplicationRecord
extend FriendlyId
friendly_id :title, use: %i[slugged finders]
belongs_to :company belongs_to :company
has_many :apply_jobs, dependent: :destroy has_many :apply_jobs, dependent: :destroy
has_many :favorite_jobs, dependent: :destroy has_many :favorite_jobs, dependent: :destroy
...@@ -7,4 +9,8 @@ class Job < ApplicationRecord ...@@ -7,4 +9,8 @@ class Job < ApplicationRecord
has_and_belongs_to_many :cities has_and_belongs_to_many :cities
LATEST_JOB_NUMBER = 5 LATEST_JOB_NUMBER = 5
scope :latest_jobs, -> { includes(:cities, :industries, :company).order('created_at DESC') } scope :latest_jobs, -> { includes(:cities, :industries, :company).order('created_at DESC') }
def normalize_friendly_id(string)
string.to_s.to_slug.normalize(transliterations: :vietnamese).to_s
end
end end
\ No newline at end of file
nav.breadcrumb[style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb"]
ol.breadcrumb.py-3
li.breadcrumb-item
= link_to "Top", root_path
li.breadcrumb-item
- @job.cities.each do |city|
= link_to city.name + ' ', city_slug_path(city.slug)
li.breadcrumb-item
- @job.industries.each do |industry|
= link_to industry.name + ' ', industry_slug_path(industry.slug)
li.breadcrumb-item.active = @job.title
\ No newline at end of file
- provide :title, 'Job List'
= render 'search'
.container
h5.fw-normal
| Total:
= pluralize(@total, 'job')
h5.fw-normal
| Result for:
= @result
h6.offset-md-4
= paginate @jobs, window: 1
.job-list
- @jobs.each do |job|
.row.bg-white
.col-10.p-3.border.card-body.text-dark
h5.mb-1
= link_to job.title, detail_path(job.slug)
p.mb-1
= job.company.name
p.mb-1
i.fas.fa-dollar-sign.m-1
| Lương:
= job.salary
p.mb-1
i.fas.fa-map-marker-alt.m-1
= link_to job.cities.map(&:name).uniq.join(' | '), "#"
p.mb-1
= truncate(job.overview, length: 250)
.col-sm-2.p-3.border.favourite
= link_to "Farourite", "#", class: "btn btn-outline-primary"
h6.offset-md-4.px-5
= page_entries_info @jobs
h6.offset-md-4
= paginate @jobs, window: 1
\ No newline at end of file
- provide :title, 'Job List' - provide :title, 'Job Detail'
= render 'search' = render 'breadcrumb'
.container .row.bg-white
h5.fw-normal .col-10.p-3.detail-job.text-dark
| Total: h1.mb-2
= pluralize(@total, 'job') = @job.title
h5.fw-normal h3.mb-2
| Result for: = @job.company.name
= @result .row
h6.offset-md-4 .col
= paginate @jobs, window: 1 p.mb-2
.job-list | Lương:
- @jobs.each do |job| = @job.salary
.row.bg-white p.mb-2
.col-10.p-3.border.card-body.text-dark | Location:
h5.mb-1 - @job.cities.each do |city|
= link_to job.title, "#" = link_to city.name + ' | ', city_slug_path(city.slug)
p.mb-1 p.mb-2
= link_to job.company.name, "#" | Job type:
p.mb-1 = @job.job_type
i.fas.fa-dollar-sign.m-1 .col
| Lương: p.mb-2
= job.salary | Level:
p.mb-1 = @job.level
i.fas.fa-map-marker-alt.m-1 p.mb-2
= link_to job.cities.map(&:name).uniq.join(' | '), "#" | Experience:
p.mb-1 = @job.experience
= truncate(job.overview, length: 250) p.mb-2
.col-sm-2.p-3.border.favourite | Expired at:
= link_to "Farourite", "#", class: "btn btn-outline-primary" = format_datetime(@job.expired_at)
h6.offset-md-4.px-5 h5.my-3
= page_entries_info @jobs | Benefits
h6.offset-md-4 p.mb-2
= paginate @jobs, window: 1 = @job.benefits
\ No newline at end of file h5.my-3
| Overview
p.mb-2
- @job.overview
h5.my-3
| Requirement
p.mb-2
= @job.requirement
h5.my-3
| Other requirement
p.mb-2
= @job.other_requirement
.col-sm-2.p-3.apply-job
= link_to "Apply this Job", "#", class: "btn btn-outline-primary btn-lg"
.row.bg-white.p-4
.col.text-end
= link_to "Apply this Job", "#", class: "btn btn-outline-primary btn-lg"
.col
= link_to "Favourite", "#", class: "btn btn-outline-primary btn-lg"
\ No newline at end of file
...@@ -11,9 +11,9 @@ h3.p-2 ...@@ -11,9 +11,9 @@ h3.p-2
.card.my-3 .card.my-3
.card-body.text-dark .card-body.text-dark
h5.mb-1 h5.mb-1
= link_to job.title, "#" = link_to job.title, detail_path(job.slug)
p.mb-1 p.mb-1
= link_to job.company.name, "#" = job.company.name
p.mb-1 p.mb-1
i.fas.fa-dollar-sign.m-1 i.fas.fa-dollar-sign.m-1
| Lương: | Lương:
......
Rails.application.routes.draw do Rails.application.routes.draw do
root 'top#home' root 'top#index'
get 'cities', to: 'cities#show' get 'cities', to: 'cities#show'
get 'industries', to: 'industries#show' get 'industries', to: 'industries#show'
get 'jobs/city/:city_slug', to: 'jobs#show', as: 'city_slug' get 'jobs/city/:city_slug', to: 'jobs#index', as: 'city_slug'
get 'jobs/industry/:industry_slug', to: 'jobs#show', as: 'industry_slug' get 'jobs/industry/:industry_slug', to: 'jobs#index', as: 'industry_slug'
get 'detail/:job_slug', to: 'jobs#show', as: 'detail'
end end
\ No newline at end of file
class AddSlugToJobs < ActiveRecord::Migration[6.1]
def change
add_column :jobs, :slug, :string
add_index :jobs, :slug, unique: true
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_07_31_111344) do ActiveRecord::Schema.define(version: 2021_08_05_021856) do
create_table "apply_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| create_table "apply_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "user_id", null: false t.bigint "user_id", null: false
...@@ -119,7 +119,9 @@ ActiveRecord::Schema.define(version: 2021_07_31_111344) do ...@@ -119,7 +119,9 @@ ActiveRecord::Schema.define(version: 2021_07_31_111344) do
t.datetime "expired_at" t.datetime "expired_at"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.string "slug"
t.index ["company_id"], name: "index_jobs_on_company_id" t.index ["company_id"], name: "index_jobs_on_company_id"
t.index ["slug"], name: "index_jobs_on_slug", unique: true
end end
create_table "regions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| create_table "regions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
......
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