Commit 2f6f57b8 by Tô Ngọc Ánh

Merge branch 'id20-job-detail' into 'master'

ID20 - Job detail

See merge request !10
parents 9e711633 b1b847f2
Pipeline #841 failed with stages
in 0 seconds
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -26,8 +26,30 @@ ...@@ -26,8 +26,30 @@
background-color: $main-color; background-color: $main-color;
} }
hr { .divider {
width: 100px; width: 100px;
border-top: 2px solid $main-color border-top: 2px solid $main-color
} }
\ No newline at end of file .vertical-divider {
position: relative;
padding: 0px 4px;
&::after {
content: '';
width: 1px;
height: 18px;
margin-left: 3px;
position: absolute;
border-right: 1px solid black;
top: 50%;
right: -3px;
transform: translateY(-50%);
}
&:last-child {
&::after {
display: none;
}
}
}
...@@ -6,4 +6,8 @@ class JobsController < ApplicationController ...@@ -6,4 +6,8 @@ class JobsController < ApplicationController
@keyword = object.try(:name) || object.try(:city) @keyword = object.try(:name) || object.try(:city)
@jobs = object.jobs.all.includes(:company, :locations, :industries).page(params[:page]) @jobs = object.jobs.all.includes(:company, :locations, :industries).page(params[:page])
end end
def show
@job = Job.find_by(id: params[:id])
end
end end
require './lib/common/convert_slug'
class Company < ApplicationRecord class Company < ApplicationRecord
include ConvertSlug
has_many :jobs has_many :jobs
before_save :add_slug, unless: :slug
private
def add_slug
self.slug = "#{to_slug(name)}-#{Time.now.to_i}#{rand(10_000)}"
end
end end
...@@ -13,6 +13,6 @@ class Industry < ApplicationRecord ...@@ -13,6 +13,6 @@ class Industry < ApplicationRecord
private private
def add_slug def add_slug
self.slug = "#{self.to_slug(self.name)}-#{Time.now.to_i}#{rand(10000)}" self.slug = "#{to_slug(name)}-#{Time.now.to_i}#{rand(10_000)}"
end end
end end
...@@ -18,6 +18,6 @@ class Location < ApplicationRecord ...@@ -18,6 +18,6 @@ class Location < ApplicationRecord
private private
def add_slug def add_slug
self.slug = "#{self.to_slug(self.city)}-#{Time.now.to_i}#{rand(10000)}" self.slug = "#{to_slug(city)}-#{Time.now.to_i}#{rand(10_000)}"
end end
end end
<div class='col-md-6 col-sm-12 my-2'> <div class='col-md-6 col-sm-12 my-2'>
<div class='card'> <div class='card'>
<div class='card-body'> <div class='card-body'>
<%= link_to job.title, '#', class: 'card-title font-weight-bold text-decoration-none' %> <%= link_to job.title, job_path(job), class: 'card-title font-weight-bold text-decoration-none' %>
<p class='card-text'><%= job.company.name %></p> <p class='card-text'><%= job.company.name %></p>
<p class='mb-0'> <p class='mb-0'>
<strong>Work place:</strong> <strong>Work place:</strong>
......
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
</div> </div>
<div id='latest-jobs' class='my-4 text-center'> <div id='latest-jobs' class='my-4 text-center'>
<h1>Latest Jobs</h1> <h1>Latest Jobs</h1>
<hr> <hr class="divider">
<div class='row'> <div class='row'>
<%= render partial: 'home/job', collection: @jobs %> <%= render partial: 'home/job', collection: @jobs %>
</div> </div>
</div> </div>
<div id='top-cities' class='my-4 text-center'> <div id='top-cities' class='my-4 text-center'>
<h1>Top Cities</h1> <h1>Top Cities</h1>
<hr> <hr class="divider">
<div class='row'> <div class='row'>
<%= render partial: 'locations/location', collection: @top_cities %> <%= render partial: 'locations/location', collection: @top_cities %>
</div> </div>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</div> </div>
<div id='top-industries' class='my-4 text-center'> <div id='top-industries' class='my-4 text-center'>
<h1>Top Industries</h1> <h1>Top Industries</h1>
<hr> <hr class="divider">
<div class='row'> <div class='row'>
<%= render partial: 'industries/industry', collection: @top_industries %> <%= render partial: 'industries/industry', collection: @top_industries %>
</div> </div>
......
<div id='industries' class='text-center my-3'> <div id='industries' class='text-center my-3'>
<h2>Industries List</h2> <h2>Industries List</h2>
<hr> <hr class="divider">
<div class='row'> <div class='row'>
<%= render partial: 'industries/industry', collection: @industries %> <%= render partial: 'industries/industry', collection: @industries %>
</div> </div>
......
<nav aria-label='breadcrumb'>
<ol class='breadcrumb'>
<li class='breadcrumb-item'><%= link_to 'TOP', root_path %></li>
<li class='breadcrumb-item'><%= link_to @job.locations.first.city, jobs_path(model: 'location', slug: @job.locations.first.slug) %></li>
<li class='breadcrumb-item'><%= link_to @job.industries.first.name, jobs_path(model: 'industry', slug: @job.industries.first.slug) %></li>
<li class='breadcrumb-item active' aria-current='page'><%= @job.title %></li>
</ol>
</nav>
<div class="row">
<div class="col-10">
<h2 class="font-weight-bold"><%= @job.title %></h2>
<h4><i class="fas fa-building"></i>
<%= link_to @job.company.name, jobs_path(model: 'company', slug: @job.company.slug), class: 'text-decoration-none text-dark' %>
</h4>
<span class="mx-2"><i class="fas fa-map-marker-alt"> </i>
<% @job.locations.each do |location| %>
<%= link_to location.city, jobs_path(model: 'location', slug: location.slug), class: 'vertical-divider text-dark' %>
<% end %>
</span>
<span class="mx-2"><i class="fas fa-briefcase"> </i>
<% @job.industries.each do |industry| %>
<%= link_to industry.name, jobs_path(model: 'industry', slug: industry.slug), class: 'vertical-divider text-dark' %>
<% end %>
</span>
<span class="mx-2"><i class="fas fa-user-alt"></i> <%= @job.level %></span>
<span class="mx-2"><i class="fas fa-business-time"></i> <%= @job.experience %></span>
<span class="mx-2"><i class="fas fa-wallet"></i> <%= @job.salary %></span>
<span class="mx-2"><i class="fas fa-calendar-week"></i> <%= @job.expiration_date %></span>
<hr>
<h3><strong>Description:</strong></h3>
<%= @job.description.html_safe %>
</div>
<div class="col-2">
<%= link_to 'Apply Now', '#', class: 'btn btn-outline-success btn-lg' %>
</div>
</div>
<div class="row my-3">
<div class="col-6 text-right">
<%= link_to 'Apply Now', '#', class: 'btn btn-outline-success btn-lg' %>
</div>
<div class="col-6 text-left">
<%= link_to 'Favorite', '#', class: 'btn btn-outline-danger btn-lg' %>
</div>
</div>
<div class='list my-3 text-center'> <div class='list my-3 text-center'>
<h2>Area List</h2> <h2>Area List</h2>
<hr> <hr class="divider">
<ul class='list-group list-group-horizontal justify-content-center'> <ul class='list-group list-group-horizontal justify-content-center'>
<li class='list-group-item'> <li class='list-group-item'>
<a href='#vietnam'>Việt Nam</a> <a href='#vietnam'>Việt Nam</a>
...@@ -12,15 +12,15 @@ ...@@ -12,15 +12,15 @@
</div> </div>
<div id='vietnam' class='text-center'> <div id='vietnam' class='text-center'>
<h2>Vietnam</h2> <h2>Vietnam</h2>
<hr> <hr class="divider">
<div class='row'> <div class='row'>
<%= render partial: 'locations/location', collection: @vn_cities_lists %> <%= render partial: 'locations/location', collection: @vn_cities_lists %>
</div> </div>
</div> </div>
<div id='international' class='text-center'> <div id='international' class='text-center'>
<h2>International</h2> <h2>International</h2>
<hr> <hr class="divider">
<div class='row'> <div class="row">
<%= render partial: 'locations/location', collection: @internal_cities_lists %> <%= render partial: 'locations/location', collection: @internal_cities_lists %>
</div> </div>
</div> </div>
...@@ -2,6 +2,7 @@ Rails.application.routes.draw do ...@@ -2,6 +2,7 @@ Rails.application.routes.draw do
root to: 'home#index' root to: 'home#index'
get 'cities', to: 'locations#index' get 'cities', to: 'locations#index'
get 'industries', to: 'industries#index' get 'industries', to: 'industries#index'
get 'detail/:id', to: 'jobs#show', as: :job
get 'jobs/:model/:slug', to: 'jobs#index', as: :jobs get 'jobs/:model/:slug', to: 'jobs#index', as: :jobs
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end end
class AddSlugToCompanies < ActiveRecord::Migration[5.2]
def change
add_column :companies, :slug, :string
add_index :companies, :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: 2020_08_05_034659) do ActiveRecord::Schema.define(version: 2020_08_06_093557) do
create_table "applied_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| create_table "applied_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.bigint "user_id" t.bigint "user_id"
...@@ -30,7 +30,9 @@ ActiveRecord::Schema.define(version: 2020_08_05_034659) do ...@@ -30,7 +30,9 @@ ActiveRecord::Schema.define(version: 2020_08_05_034659) do
t.string "address" t.string "address"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "slug"
t.index ["name"], name: "index_companies_on_name", unique: true t.index ["name"], name: "index_companies_on_name", unique: true
t.index ["slug"], name: "index_companies_on_slug", unique: true
end end
create_table "favorites", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| create_table "favorites", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
......
...@@ -2,17 +2,24 @@ namespace :create_slug do ...@@ -2,17 +2,24 @@ namespace :create_slug do
desc 'Create slug model Location' desc 'Create slug model Location'
task locations: :environment do task locations: :environment do
Location.all.each do |location| Location.all.each do |location|
location.update_attributes(slug: "#{location.to_slug(location.city)}-#{Time.now.to_i}#{rand(10000)}") location.update_attributes(slug: "#{location.to_slug(location.city)}-#{Time.now.to_i}#{rand(10_000)}")
end end
end end
desc 'Create slug model Industry' desc 'Create slug model Industry'
task industries: :environment do task industries: :environment do
Industry.all.each do |industry| Industry.all.each do |industry|
industry.update_attributes(slug: "#{industry.to_slug(industry.name)}-#{Time.now.to_i}#{rand(10000)}") industry.update_attributes(slug: "#{industry.to_slug(industry.name)}-#{Time.now.to_i}#{rand(10_000)}")
end
end
desc 'Create slug model Company'
task companies: :environment do
Company.all.each do |company|
company.update_attributes(slug: "#{company.to_slug(company.name)}-#{Time.now.to_i}#{rand(10_000)}")
end end
end end
desc 'Create slug to all model' desc 'Create slug to all model'
task all: %i[locations industries] task all: %i[locations industries companies]
end end
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