Commit f1077f8b by nnnghia98

fix decorator

parent 7a5a4a8d
...@@ -38,13 +38,6 @@ h1, h2, h3, h4, h5, h6 { ...@@ -38,13 +38,6 @@ h1, h2, h3, h4, h5, h6 {
line-height: 1; line-height: 1;
} }
h1 {
font-size: 3em;
letter-spacing: -2px;
margin-bottom: 30px;
text-align: center;
}
h2 { h2 {
font-size: 1.2em; font-size: 1.2em;
letter-spacing: -1px; letter-spacing: -1px;
...@@ -157,3 +150,9 @@ dl, dt, dd { ...@@ -157,3 +150,9 @@ dl, dt, dd {
list-style-type: none; list-style-type: none;
line-height: normal; line-height: normal;
} }
.breadcrump {
font-weight: lighter;
font-size: 12px;
margin-bottom: 15px;
}
class JobsController < ApplicationController class JobsController < ApplicationController
def index def index
@jobs = Job.page(params[:page]).per(Settings.job.per_page) @jobs = Job.page(params[:page]).per(Settings.job.per_page).decorate
end end
def show def show
@job = Job.find(params[:id]) @job = Job.find(params[:id]).decorate
end end
end end
class ApplicationDecorator < Draper::Decorator
def self.collection_decorator_class
PaginatingDecorator
end
end
class JobDecorator < Draper::Decorator class JobDecorator < ApplicationDecorator
include ActionView::Helpers::TextHelper
delegate_all delegate_all
decorates_association :city decorates_association :city
...@@ -6,7 +8,15 @@ class JobDecorator < Draper::Decorator ...@@ -6,7 +8,15 @@ class JobDecorator < Draper::Decorator
object.cities&.first&.name object.cities&.first&.name
end end
def company_name
object.company&.name
end
def display_short_des def display_short_des
object.short_des&.truncate(250) object.short_des&.truncate(250)
end end
def display_description
simple_format object.description
end
end end
class PaginatingDecorator < Draper::CollectionDecorator
delegate :current_page, :total_pages, :limit_value, :entry_name, :total_count, :offset_value, :last_page?
end
...@@ -38,6 +38,6 @@ class Job < ApplicationRecord ...@@ -38,6 +38,6 @@ class Job < ApplicationRecord
has_many :industries, through: :industry_jobs has_many :industries, through: :industry_jobs
def self.latest_job def self.latest_job
@latest_job ||= Job.order(updated_at: :desc).take(Settings.top.job.limit) @latest_job ||= order(updated_at: :desc).take(Settings.top.job.limit)
end end
end end
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</dl> </dl>
<dl class="job_data_row"> <dl class="job_data_row">
<dt>Short description</dt> <dt>Short description</dt>
<dd><%= job.decorate.display_short_des %></dd> <dd><%= job.display_short_des %></dd>
</dl> </dl>
<dl class="job_data_row"> <dl class="job_data_row">
<dt>Salary</dt> <dt>Salary</dt>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</dl> </dl>
<dl class="job_data_row"> <dl class="job_data_row">
<dt>Location</dt> <dt>Location</dt>
<dd><%= job.decorate.city_name %></dd> <dd><%= job.city_name %></dd>
</dl> </dl>
</div> </div>
<button type="button" class="btn btn-outline-secondary">Favorite</button> <button type="button" class="btn btn-outline-secondary">Favorite</button>
......
<div class="breadcrump">
<%= link_to "Top", root_path %> >
<%= link_to "City", cities_path %> >
<%= link_to "Industry", industries_path %> >
<%= @job.title %>
</div>
<div class="box">
<h1>
<%= @job.title %>
</h1>
<div class="job_data">
<dl class="job_data_row">
<dt>Company</dt>
<dd><%= @job.company_name %></dd>
</dl>
<dl class="job_data_row">
<dt>Location</dt>
<dd><%= @job.city_name %></dd>
</dl>
<dl class="job_data_row">
<dt>Salary</dt>
<dd><%= @job.salary %></dd>
</dl>
<dl class="job_data_row">
<dt>Description</dt>
<dd><%= @job.display_description %></dd>
</dl>
</div>
</div>
<div class="job_detail_button">
<%= link_to "Favorite", "#", class: "btn btn-primary float-right" %>
<%= link_to "Apply", "#", class: "btn btn-primary float-right mx-3" %>
</div>
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