Commit 550a2c5c by Trịnh Hoàng Phúc

Merge branch 'feature/user_management_test' into 'master'

User mamangement history page, defind AJAX apply job

See merge request !8
parents ccc6289d 627b4293
Pipeline #573 failed with stages
in 0 seconds
...@@ -10,4 +10,20 @@ ...@@ -10,4 +10,20 @@
$(".back2top").click(function(){ $(".back2top").click(function(){
$("html, body").animate({scrollTop: 0}, 500); $("html, body").animate({scrollTop: 0}, 500);
}) })
$(".job_application .application_button").click(function (e) {
e.preventDefault()
data = { job_ids: [$(this).data("id")] }
$.ajax({
url: '/job/apply',
data: data,
type: 'POST',
success: (res) => {
console.log("response: ", res)
},
error: (err) => {
console.log("error: ", err)
}
});
})
})(jQuery); })(jQuery);
\ No newline at end of file
class HistoryController < ApplicationController
def index
if cookies[:job_ids_history].nil?
redirect_to '/jobs'
else
arr_job_ids = cookies[:job_ids_history].split(",")
job_ids = cookies[:job_ids_history].split(",")
@jobs_history = Job.where('id IN (?)', job_ids).order("id DESC")
end
end
end
\ No newline at end of file
...@@ -19,8 +19,23 @@ class JobsController < ApplicationController ...@@ -19,8 +19,23 @@ class JobsController < ApplicationController
if @job.present? if @job.present?
@title = @job.title @title = @job.title
@relate_jobs = Job.where("company_id = ? and id != ?", @job.company_id, @job.id).order("id DESC") @relate_jobs = Job.where("company_id = ? and id != ?", @job.company_id, @job.id).order("id DESC")
if cookies[:job_ids_history].nil?
cookies[:job_ids_history] = {value: @job.id, expires: Time.now + 3600}
else
arr_job_ids = cookies[:job_ids_history].split(",")
unless arr_job_ids.include?(@job.id.to_s)
if arr_job_ids.count == 10
arr_job_ids.shift
end
arr_job_ids << @job.id.to_s
end
cookies[:job_ids_history] = {value: arr_job_ids.join(","), expires: Time.now + 3600}
end
else else
@title = "Job was not found" @title = "Job was not found"
end end
end end
def apply_jobs
end
end end
<%= content_for :title, "VenJob - History" %>
<header class="page-header">
<h2 class="page-title">History</h2>
</header>
<div id="primary" class="content-area container" role="main">
<article id="post-2452" class="post-2452 page type-page status-publish hentry">
<div class="entry-content">
<div class="woocommerce">
<div class="woocommerce-notices-wrapper"></div>
<table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0">
<thead>
<tr>
<th class="product-remove">No.</th>
<th class="product-thumbnail">&nbsp;</th>
<th class="product-name">Title</th>
<th class="product-price">City</th>
<th class="product-quantity">Salary</th>
</tr>
</thead>
<tbody>
<% @jobs_history.each_with_index do |job, index| %>
<tr class="woocommerce-cart-form__cart-item cart_item">
<td>
<%= index + 1%>
</td>
<td style="text-align: center;">
<input type="checkbox">
</td>
<td>
<%= job.title %>
</td>
<td>
<% job.cities.each_with_index do |city, index| %>
<%= city.title %><%= ", " if index != job.cities.size - 1 %>
<% end %>
</td>
<td class="product-price">
<%= job.salary %>
</td>
<td class="product-quantity">
</td>
</tr>
<% end %>
<tr>
<td colspan="6" class="actions">
<button type="submit" class="button" name="update_cart" value="Update cart" >Apply all</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</article>
</div>
...@@ -45,6 +45,9 @@ ...@@ -45,6 +45,9 @@
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-99991220"> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-99991220">
<a href="/industries">Industry</a> <a href="/industries">Industry</a>
</li> </li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-99991220">
<a href="/history">History</a>
</li>
<% if current_user %> <% if current_user %>
<li class="login menu-item menu-item-type-post_type menu-item-object-page menu-item-99991213"> <li class="login menu-item menu-item-type-post_type menu-item-object-page menu-item-99991213">
<%= link_to 'Sign out', destroy_user_session_path, method: :delete %> <%= link_to 'Sign out', destroy_user_session_path, method: :delete %>
......
...@@ -10,4 +10,7 @@ Rails.application.routes.draw do ...@@ -10,4 +10,7 @@ Rails.application.routes.draw do
get '/jobs/company/:company_id', to: 'jobs#index', as: 'jobs_with_company' get '/jobs/company/:company_id', to: 'jobs#index', as: 'jobs_with_company'
get '/cities/', to: 'cities#index', as: 'cities' get '/cities/', to: 'cities#index', as: 'cities'
get '/industries/', to: 'industries#index', as: 'industries' get '/industries/', to: 'industries#index', as: 'industries'
get '/history/', to: 'history#index'
post 'job/apply', to: 'job#apply_jobs'
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