Commit e0740f33 by Ngô Trung Hưng

use render collection & fix method add_job_to_history

parent 57a0d779
Pipeline #992 failed with stages
in 0 seconds
...@@ -1622,3 +1622,6 @@ $main-color: #23303D; ...@@ -1622,3 +1622,6 @@ $main-color: #23303D;
height: 100%; height: 100%;
z-index: 99999; z-index: 99999;
} }
#label_name_file {
cursor: pointer;
}
\ No newline at end of file
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
# Job controller # Job controller
class JobController < ApplicationController class JobController < ApplicationController
before_action :load_data_dropdown, only: :index before_action :load_data_dropdown, only: :index
after_action :add_job_to_history, only: :detail def add_job_to_history(job_id)
def add_job_to_history return unless user_signed_in?
current_user.histories.find_or_create_by(job_id: session[:params_job_id]) if user_signed_in?
current_user.histories.find_or_create_by(job_id: job_id)
counter_history = current_user.histories.count counter_history = current_user.histories.count
current_user.histories.destroy(current_user.histories.first) if counter_history > 20 current_user.histories.destroy(current_user.histories.first) if counter_history > History::NUMBER_JOB_LIMIT
session.delete(:params_job_id)
end end
def index def index
...@@ -19,7 +19,9 @@ class JobController < ApplicationController ...@@ -19,7 +19,9 @@ class JobController < ApplicationController
def detail def detail
@job = Job.find(params[:id]).decorate @job = Job.find(params[:id]).decorate
session[:params_job_id] = @job.id return render 'error/fage_not_found' if @job.blank?
add_job_to_history(@job.id)
cities = @job.cities.first cities = @job.cities.first
industries = @job.industries.first industries = @job.industries.first
add_breadcrumb t('controller.job.detail.home'), root_path add_breadcrumb t('controller.job.detail.home'), root_path
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Description/Explanation of Person class # Description/Explanation of Person class
class History < ApplicationRecord class History < ApplicationRecord
NUMBER_JOB_LIMIT = 20
belongs_to :user belongs_to :user
belongs_to :job belongs_to :job
end end
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div class="breadcrumb_total_search"> <div class="breadcrumb_total_search">
<span class="breadcrumb-item active"> <span class="breadcrumb-item active">
<%= t('favorite.list_blank') %> <%= t('favorite.empty') %>
</span> </span>
</div> </div>
</div> </div>
......
...@@ -14,18 +14,16 @@ ...@@ -14,18 +14,16 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div class="breadcrumb_total_search"> <div class="breadcrumb_total_search">
<span class="breadcrumb-item active"> <span class="breadcrumb-item active">
<%= t('history.list_blank') %> <%= t('history.empty') %>
</span> </span>
</div> </div>
</div> </div>
<div style="width: 100%; height: 55vh"></div> <div style="width: 100%; height: 55vh"></div>
<% else %> <% else %>
<%= form_with url: apply_path, method: :get, local: true, skip_enforcing_utf8: true do |f| %> <%= form_with url: apply_path, method: :get, local: true, skip_enforcing_utf8: true do |f| %>
<div class="container"> <div class="container">
<div class="box_scroll"> <div class="box_scroll">
<% @jobs.each do |item| %> <%= render partial: 'histories/block_job_mini', collection: @jobs, as: :data, locals: { form: f } %>
<%= render 'histories/block_job_mini', data: item, form: f %>
<% end %>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
......
...@@ -136,11 +136,11 @@ en: ...@@ -136,11 +136,11 @@ en:
favorite: favorite:
liked: 'You have added job to favorites' liked: 'You have added job to favorites'
list: 'List of jobs you liked' list: 'List of jobs you liked'
list_blank: 'You do not have a favorite job!' empty: 'You do not have a favorite job!'
history: history:
list: 'Histories' list: 'Histories'
list_blank: 'You do not have a histories' empty: 'You do not have a histories'
see: 'See: ' seen_at: 'Seen_at: '
activerecord: activerecord:
attributes: attributes:
applied_job: applied_job:
......
...@@ -136,11 +136,11 @@ vi: ...@@ -136,11 +136,11 @@ vi:
favorite: favorite:
liked: 'Bạn đã thêm công việc vào yêu thích.' liked: 'Bạn đã thêm công việc vào yêu thích.'
list: 'Danh sách công việc bạn đã thích' list: 'Danh sách công việc bạn đã thích'
list_blank: 'Bạn chưa công việc yêu thích!' empty: 'Bạn chưa công việc yêu thích!'
history: history:
list: 'Lịch sử' list: 'Lịch sử'
list_blank: 'Bạn chưa xem công việc nào luôn á!' empty: 'Bạn chưa xem công việc nào luôn á!'
see: 'Đã xem lúc: ' seen_at: 'Đã xem lúc: '
activerecord: activerecord:
attributes: attributes:
applied_job: applied_job:
......
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