Commit a1978ad0 by Xuan Trung Le

create favorite_job page

parent 051d5416
......@@ -16,5 +16,9 @@
//= require javascripts/bootstrap.min.js
$(document).ready(function(){
<<<<<<< 051d54168d06f6979124eb192481eeefe159fbf7
$('.message').delay(5000).fadeOut('slow');
=======
$('#message').delay(5000).fadeOut('slow');
>>>>>>> create favorite_job page
});
......@@ -81,9 +81,12 @@ body{
.maxH89{
max-height: 89px;
}
// end
// Message
.message{
position: fixed; right: 0
// Table
.position-relative{
position: relative !important;
}
.mid-heigth{
position: absolute;
top: 25%;
}
class FavoritesController < ApplicationController
def index
@jobs = current_user.liked_jobs.includes(:company)
end
def user_like_job
job = Job.find(params[:job_id])
flash[:notice] = "You have favorited this job already"
unless current_user.liked_jobs.pluck(:id).include?(job.id)
current_user.like_job(job)
flash[:notice] = "Successfully favorited..."
end
redirect_back(fallback_location: root_path)
end
def user_unlike_job
job = Job.find(params[:job_id])
current_user.unlike_job(job)
flash[:notice] = "Successfully unfavorited..."
redirect_back(fallback_location: root_path)
end
end
class JobsController < ApplicationController
before_action :set_job, only: [:show]
skip_before_action :authenticate_user!, only: [:index, :city, :industry, :company, :show]
def index
@jobs = Job.top_list.includes(:company)
@cities = City.top_cities.includes(:country)
......
<div class="row">
<div class="container">
<div class="jobs clearfix">
<div class="job col-md-12">
<table class="table">
<tbody>
<%- @jobs.each do |job|-%>
<tr>
<td class="col-md-1 position-relative">
<input type="radio" name="rbn-apply-job" class="mid-heigth">
</td>
<td class="col-md-9">
<h4 class="mr0"><%= link_to job.name, job_path(job) %></h4>
<p><%= "Loacation: #{job.company.location}" %></p>
<p><%= "Salary: #{job.salary}" %></p>
</td>
<td class="col-md-2 position-relative">
<%= button_to "Remove",
unlike_job_favorites_path(job_id: job.id),
data: {confirm: "Are you sure you want to remove this job?"},
class: "btn btn-danger btn-lg mid-heigth" %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<%= button_to "Apply", nil, class: "btn btn-primary" %>
</div>
</div>
</div>
......@@ -4,25 +4,25 @@
<li><a href="/">TOP</a></li>
<li>
<%- @job.cities.each_with_index do |city, index| -%>
<%= "#{index > 0 ? ',' : ''}" %>
<%= link_to city.name, city_jobs_path(city) %>
<%= "#{index > 0 ? ',' : ''}" %>
<%= link_to city.name, city_jobs_path(city) %>
<%- end -%>
</li>
<li>
<%- @job.industries.each_with_index do |industry, index| -%>
<%= "#{index > 0 ? ',' : ''}" %>
<%= link_to industry.name, industry_jobs_path(industry) %>
<%= "#{index > 0 ? ',' : ''}" %>
<%= link_to industry.name, industry_jobs_path(industry) %>
<%- end -%>
</li>
<li><%= @job.name %></li>
</ol>
</ol>
<div class="job">
<div class="col-md-9">
<h1>2.<%= @job.name %></h1>
<p>3.<%= link_to @job.company.name, company_jobs_path(@job.company) %></p>
<p>4. Location:
<%- @job.cities.each_with_index do |city, index| -%>
<div class="job">
<div class="col-md-9">
<h1>2.<%= @job.name %></h1>
<p>3.<%= link_to @job.company.name, company_jobs_path(@job.company) %></p>
<p>4. Location:
<%- @job.cities.each_with_index do |city, index| -%>
<%= "#{index > 0 ? ',' : ''}" %>
<%= link_to city.name, city_jobs_path(city) %>
<%- end -%>
......@@ -39,11 +39,19 @@
<div class="col-md-6">
<%= link_to "Apply", apply_applies_path(job_id: @job.id), class: "btn btn-default btn-lg" %>
</div>
<div class="col-md-6">
<%= link_to "Favorite", "#", class: "btn btn-default btn-lg" %>
<div class="col-md-3">
<%= link_to "Apply", "#", class: "btn btn-primary btn-lg" %>
</div>
<div class="action">
<div class="col-md-6">
<%= link_to "Apply", "#", class: "btn btn-primary btn-lg" %>
</div>
<div class="col-md-6">
<%= button_to "Favorite",
job_favorites_path(job_id: @job.id),
class: "btn btn-primary btn-lg" %>
</div>
</div>
</div>
</div>
</div>
</div>
<% flash.each do |name, msg| %>
<<<<<<< 051d54168d06f6979124eb192481eeefe159fbf7
<div class="alert alert-info alert-dismissable fade in message">
=======
<div class="alert alert-info alert-dismissable fade in" style="position: fixed; right: 0" id="message">
>>>>>>> create favorite_job page
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong><%= "#{name}!" %></strong> <%= msg %>
</div>
......
......@@ -11,19 +11,38 @@
<%- if current_user -%>
<li><a href="#"><i class="fa fa-sign-in" aria-hidden="true"></i> My Page</a></li>
<li>
<<<<<<< 051d54168d06f6979124eb192481eeefe159fbf7
<%= link_to destroy_user_session_path, method: :delete do %>
<i class="fa fa-sign-out" aria-hidden="true"></i>Logout
=======
<%= link_to destroy_user_session_path, method: :delete do %> Logout
<i class="fa fa-sign-in" aria-hidden="true"></i>
>>>>>>> create favorite_job page
<% end %>
</li>
<%- else -%>
<li>
<<<<<<< 051d54168d06f6979124eb192481eeefe159fbf7
<%= link_to register_path(step: 1) do %>
<i class="fa fa-plus-circle" aria-hidden="true"></i> Register
=======
<%= link_to new_user_session_path do %> Login
<i class="fa fa-sign-in" aria-hidden="true"></i>
>>>>>>> create favorite_job page
<% end %>
</li>
<li><a href="#"><i class="fa fa-plus" aria-hidden="true"></i> Register</a></li>
<%- end -%>
<<<<<<< 051d54168d06f6979124eb192481eeefe159fbf7
<li><a href="#"><i class="fa fa-star" aria-hidden="true"></i></span> Favorite</a></li>
=======
<li>
<%= link_to favorites_path do %> Favorite
<i class="fa fa-star" aria-hidden="true"></i>
<% end %>
</li>
>>>>>>> create favorite_job page
<li><a href="#"><i class="fa fa-history" aria-hidden="true"></i></span> History</a></li>
</ul>
</div>
......
......@@ -9,6 +9,12 @@ Rails.application.routes.draw do
resources :cities, only: [:index, :show]
resources :industries, only: [:index, :show]
resources :favorites do
collection do
post :user_like_job, as: :job
post :user_unlike_job, as: :unlike_job
end
end
resources :jobs do
collection do
get 'city/:city_id' => "jobs#city", as: :city
......
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