Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
ven-job
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Trịnh Hoàng Phúc
ven-job
Commits
627b4293
Commit
627b4293
authored
Apr 10, 2020
by
Hoang Phuc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User mamangement history page, defind AJAX apply job
parent
ccc6289d
Pipeline
#572
failed with stages
in 0 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
0 deletions
+105
-0
app/assets/stylesheets/js/custom.js
+17
-0
app/controllers/history_controller.rb
+12
-0
app/controllers/jobs_controller.rb
+15
-0
app/views/history/index.html.erb
+55
-0
app/views/layouts/application.html.erb
+3
-0
config/routes.rb
+3
-0
No files found.
app/assets/stylesheets/js/custom.js
View file @
627b4293
...
...
@@ -10,4 +10,20 @@
$
(
".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
);
\ No newline at end of file
app/controllers/history_controller.rb
0 → 100644
View file @
627b4293
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
app/controllers/jobs_controller.rb
View file @
627b4293
...
...
@@ -19,8 +19,23 @@ class JobsController < ApplicationController
if
@job
.
present?
@title
=
@job
.
title
@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
@title
=
"Job was not found"
end
end
def
apply_jobs
end
end
app/views/history/index.html.erb
0 → 100644
View file @
627b4293
<%=
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"
>
</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>
app/views/layouts/application.html.erb
View file @
627b4293
...
...
@@ -45,6 +45,9 @@
<li
class=
"menu-item menu-item-type-post_type menu-item-object-page menu-item-99991220"
>
<a
href=
"/industries"
>
Industry
</a>
</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
%>
<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
%>
...
...
config/routes.rb
View file @
627b4293
...
...
@@ -10,4 +10,7 @@ Rails.application.routes.draw do
get
'/jobs/company/:company_id'
,
to:
'jobs#index'
,
as:
'jobs_with_company'
get
'/cities/'
,
to:
'cities#index'
,
as:
'cities'
get
'/industries/'
,
to:
'industries#index'
,
as:
'industries'
get
'/history/'
,
to:
'history#index'
post
'job/apply'
,
to:
'job#apply_jobs'
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment