Commit 5931eb90 by Ngô Trung Hưng

use decorator pattern

parent 297950ef
Pipeline #846 failed with stages
in 0 seconds
...@@ -16,7 +16,7 @@ class JobController < ApplicationController ...@@ -16,7 +16,7 @@ class JobController < ApplicationController
industries = @job.industries.first industries = @job.industries.first
add_breadcrumb 'Trang chủ', root_path add_breadcrumb 'Trang chủ', root_path
add_breadcrumb cities.name, jobs_path(model: 'city', slug: cities.slug) add_breadcrumb cities.name, jobs_path(model: 'city', slug: cities.slug)
add_breadcrumb industries.name, jobs_path(model: 'city', slug: industries.slug) add_breadcrumb industries.name, jobs_path(model: 'industry', slug: industries.slug)
add_breadcrumb @job.name add_breadcrumb @job.name
end end
......
# frozen_string_literal: true
# pattern job decorator
module JobDecorator
def posted_at
created_at.strftime('%d - %m - %Y')
end
def expired_at
expiration_date.strftime('%d - %m - %Y')
end
end
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Description/Explanation of Person class # Description/Explanation of Person class
class Job < ApplicationRecord class Job < ApplicationRecord
include JobDecorator
NUMBER_LASTED_JOB = 5 NUMBER_LASTED_JOB = 5
belongs_to :company belongs_to :company
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<span><i class="far fa-building"></i> <%= link_to @job.company.name, jobs_path(model: 'company', slug: @job.company.slug), class: 'link_ct apply_job' %></span> <span><i class="far fa-building"></i> <%= link_to @job.company.name, jobs_path(model: 'company', slug: @job.company.slug), class: 'link_ct apply_job' %></span>
</div> </div>
</div> </div>
<div class="col-lg-3 "> <div class="col-lg-3">
<div class="btn_apply_job"> <div class="btn_apply_job">
<%= link_to 'Nộp CV ngay', '#', class: 'btn btn-apply_job' %> <%= link_to 'Nộp CV ngay', '#', class: 'btn btn-apply_job' %>
</div> </div>
...@@ -30,9 +30,9 @@ ...@@ -30,9 +30,9 @@
<div class="col-lg-12 col-md-12"> <div class="col-lg-12 col-md-12">
<div class="box_detail_jobs"> <div class="box_detail_jobs">
<div class="box_detail_jobs_location"> <div class="box_detail_jobs_location">
<span><i class="fas fa-map-marker-alt"></i> Địa điểm làm việc: </span> <span><i class="fas fa-map-marker-alt"></i> Địa điểm làm việc: </span>
<% @job.cities.each do |x| %> <% @job.cities.each do |x| %>
<%= link_to "&nbsp;#{x.name}&nbsp;".html_safe , jobs_path(model: 'city', slug: x.slug), class: 'link_ct apply_job link_optimize'%> <%= link_to "&nbsp;#{x.name}&nbsp;".html_safe , jobs_path(model: 'city', slug: x.slug), class: 'link_ct apply_job link_optimize'%>
<% end %> <% end %>
</div> </div>
<div class="box_detail_jobs_salary"> <div class="box_detail_jobs_salary">
...@@ -45,16 +45,12 @@ ...@@ -45,16 +45,12 @@
</div> </div>
<div class="col-lg-4 col-md-6"> <div class="col-lg-4 col-md-6">
<div class="detail_info"> <div class="detail_info">
<span><i class="fab fa-linode"></i> Ngày đăng tin: <%= @job.created_at.strftime('%d - %m - %Y') %></span> <span><i class="fab fa-linode"></i> Ngày đăng tin: <%= @job.posted_at %></span>
</div> </div>
</div> </div>
<div class="col-lg-4 col-md-6"> <div class="col-lg-4 col-md-6">
<div class="detail_info"> <div class="detail_info">
<% if @job.expiration_date.present? %> <span><i class="fab fa-linode"></i> Ngày hết hạn: <%= @job.expiration_date.present? ? @job.expired_at : 'đang cập nhật' %></span>
<span><i class="fab fa-linode"></i> Ngày hết hạn: <%= @job.expiration_date.strftime('%d - %m - %Y') %></span>
<% else %>
<span><i class="fab fa-linode"></i> Ngày hết hạn: đang cập nhật</span>
<% end %>
</div> </div>
</div> </div>
<div class="col-lg-4 col-md-6"> <div class="col-lg-4 col-md-6">
...@@ -74,9 +70,9 @@ ...@@ -74,9 +70,9 @@
<div class="col-lg-12 col-md-12"> <div class="col-lg-12 col-md-12">
<div class="box_detail_jobs"> <div class="box_detail_jobs">
<% if @job.description.include?('div') %> <% if @job.description.include?('div') %>
<%= @job.description.html_safe %> <%= @job.description.html_safe %>
<% else %> <% else %>
<pre class="pre_desc"><%= @job.description %></pre> <pre class="pre_desc"><%= @job.description %></pre>
<% end %> <% end %>
</div> </div>
</div> </div>
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
<div class="breadcrumb_total_search"> <div class="breadcrumb_total_search">
<span class="breadcrumb-item active"> <span class="breadcrumb-item active">
<% if @data.total_count > 0 %> <% if @data.total_count > 0 %>
<div style="word-wrap: break-word;"> <div style="word-wrap: break-word;">
<span>&nbsp;<b><%= @data.total_count %></b>&nbsp;kết quả phù hợp với từ khóa&nbsp;</span><b><%= @keyword %></b>&nbsp; <span>&nbsp;<b><%= @data.total_count %></b>&nbsp;kết quả phù hợp với từ khóa&nbsp;</span><b><%= @keyword %></b>&nbsp;
</div> </div>
<% else %> <% else %>
Không có kết quả phù hợp với từ khóa&nbsp;<b><%= @keyword %></b> Không có kết quả phù hợp với từ khóa&nbsp;<b><%= @keyword %></b>
<% 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