Commit 522547c1 by Hoang Phuc

History page, defind route,controller,AJAX Apply job

parent 0d8a8c83
Pipeline #570 failed with stages
in 0 seconds
...@@ -78,27 +78,29 @@ ul.job_listings .job_listing:hover, .job_position_featured, li.type-resume:hover ...@@ -78,27 +78,29 @@ ul.job_listings .job_listing:hover, .job_position_featured, li.type-resume:hover
} }
.button--type-inverted, .widget--home-video .button, .load_more_jobs strong, .load_more_resumes strong, .job-manager-form.wp-job-manager-bookmarks-form a.bookmark-notice, .job-manager-form.wp-job-manager-favorites-form a.favorite-notice { .button--type-inverted, .widget--home-video .button, .load_more_jobs strong, .load_more_resumes strong, .job-manager-form.wp-job-manager-bookmarks-form a.bookmark-notice, .job-manager-form.wp-job-manager-favorites-form a.favorite-notice {
color: #7dc246;
border-color: #7dc246;
}
.button--type-inverted:hover, .widget--home-video .button:hover, .load_more_jobs strong:hover, .load_more_resumes strong:hover, .job-manager-form.wp-job-manager-bookmarks-form a.bookmark-notice:hover, .job-manager-form.wp-job-manager-favorites-form a.favorite-notice:hover {
background-color: #7dc246; background-color: #7dc246;
color: #fff; color: #fff;
} }
.button--type-action, .button--type-secondary:hover, .single-product #content .single_add_to_cart_button, .checkout-button, #place_order, input[type=button].application_button, .application_button_link, input[type=button].resume_contact_button { .button--type-inverted:hover, .widget--home-video .button:hover, .load_more_jobs strong:hover, .load_more_resumes strong:hover, .job-manager-form.wp-job-manager-bookmarks-form a.bookmark-notice:hover, .job-manager-form.wp-job-manager-favorites-form a.favorite-notice:hover {
color: #7dc246; color: #7dc246;
background-color: transparent;
border-color: #7dc246; border-color: #7dc246;
background-color: transparent;
} }
.button--type-action:hover, .button--type-secondary, .single-product #content .single_add_to_cart_button:hover, .checkout-button:hover, #place_order:hover, input[type=button].application_button:hover, .application_button_link:hover, input[type=button].resume_contact_button:hover { .button--type-action, .button--type-secondary:hover, .single-product #content .single_add_to_cart_button, .checkout-button, #place_order, input[type=button].application_button, .application_button_link, input[type=button].resume_contact_button {
background-color: #7dc246; background-color: #7dc246;
color: #ffffff; color: #ffffff;
border-color: #7dc246; border-color: #7dc246;
} }
.button--type-action:hover, .button--type-secondary, .single-product #content .single_add_to_cart_button:hover, .checkout-button:hover, #place_order:hover, input[type=button].application_button:hover, .application_button_link:hover, input[type=button].resume_contact_button:hover {
color: #7dc246;
background-color: transparent;
border-color: #7dc246;
}
.button--color-white, .button--color-white.button--type-inverted:hover, .button--type-hover-white:hover { .button--color-white, .button--color-white.button--type-inverted:hover, .button--type-hover-white:hover {
color: #797979; color: #797979;
background-color: #ffffff; background-color: #ffffff;
......
(function($) { (function ($) {
$(window).scroll(function () { $(window).scroll(function () {
var scroll = $(window).scrollTop(); var scroll = $(window).scrollTop();
if (scroll >= 1000) { if (scroll >= 1000) {
...@@ -7,7 +7,24 @@ ...@@ -7,7 +7,24 @@
$(".back2top").removeClass("active"); $(".back2top").removeClass("active");
} }
}); });
$(".back2top").click(function(){
$("html, body").animate({scrollTop: 0}, 500); $(".back2top").click(function () {
$("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
...@@ -3,7 +3,8 @@ class HistoryController < ApplicationController ...@@ -3,7 +3,8 @@ class HistoryController < ApplicationController
if cookies[:job_ids_history].nil? if cookies[:job_ids_history].nil?
redirect_to '/jobs' redirect_to '/jobs'
else 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 end
end end
...@@ -21,10 +21,16 @@ class JobController < ApplicationController ...@@ -21,10 +21,16 @@ class JobController < ApplicationController
else else
arr_job_ids = cookies[:job_ids_history].split(",") arr_job_ids = cookies[:job_ids_history].split(",")
unless arr_job_ids.include?(@job.id.to_s) 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 arr_job_ids << @job.id.to_s
end end
cookies[:job_ids_history] = {value: arr_job_ids.join(","), expires: Time.now + 3600} cookies[:job_ids_history] = {value: arr_job_ids.join(","), expires: Time.now + 3600}
end end
@relate_jobs = Job.where("company_id = #{@job.company_id} and id != #{@job.id}").limit(3).order("id DESC") @relate_jobs = Job.where("company_id = #{@job.company_id} and id != #{@job.id}").limit(3).order("id DESC")
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>
\ No newline at end of file
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
</aside> </aside>
<aside class="widget widget--job_listing"> <aside class="widget widget--job_listing">
<div class="job_application application"> <div class="job_application application">
<input type="button" class="application_button button" value="Apply for job" /> <input type="button" class="application_button button" value="Apply for job" data-id="<%= @job.id %>"/>
</div> </div>
<div class="job-manager-form wp-job-manager-bookmarks-form"> <div class="job-manager-form wp-job-manager-bookmarks-form">
<a class="bookmark-notice" href="https://jobify-demos.astoundify.com/classic/account/">Favorite</a> <a class="bookmark-notice" href="https://jobify-demos.astoundify.com/classic/account/">Favorite</a>
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
<%= javascript_include_tag "/assets/js/jquery.js" %> <%= javascript_include_tag "/assets/js/jquery.js" %>
<%= javascript_include_tag "/assets/js/jquery-migrate.min.js" %> <%= javascript_include_tag "/assets/js/jquery-migrate.min.js" %>
<%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?v=3&#038;libraries=geometry%2Cplaces&#038;language=en&#038;key=AIzaSyDFtSmGkBIXtMX63-bZKn50-6p3vZ2-WHE&#038;ver=5.3.2" %> <%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?v=3&#038;libraries=geometry%2Cplaces&#038;language=en&#038;key=AIzaSyDFtSmGkBIXtMX63-bZKn50-6p3vZ2-WHE&#038;ver=5.3.2" %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head> </head>
......
...@@ -8,4 +8,6 @@ Rails.application.routes.draw do ...@@ -8,4 +8,6 @@ Rails.application.routes.draw do
get '/cities/', to: 'city#index' get '/cities/', to: 'city#index'
get '/industries/', to: 'industry#index' get '/industries/', to: 'industry#index'
get '/history/', to: 'history#index' 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