Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjob
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xuan Trung Le
venjob
Commits
a1978ad0
Commit
a1978ad0
authored
Oct 23, 2017
by
Xuan Trung Le
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create favorite_job page
parent
051d5416
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
119 additions
and
18 deletions
+119
-18
app/assets/javascripts/application.js
+4
-0
app/assets/stylesheets/application.scss
+7
-4
app/controllers/favorites_controller.rb
+24
-0
app/controllers/jobs_controller.rb
+2
-0
app/views/favorites/index.html.erb
+31
-0
app/views/jobs/show.html.erb
+22
-14
app/views/layouts/_flash.html.erb
+4
-0
app/views/layouts/_menu.html.erb
+19
-0
config/routes.rb
+6
-0
No files found.
app/assets/javascripts/application.js
View file @
a1978ad0
...
...
@@ -16,5 +16,9 @@
//= require javascripts/bootstrap.min.js
$
(
document
).
ready
(
function
(){
<<<<<<<
051
d54168d06f6979124eb192481eeefe159fbf7
$
(
'.message'
).
delay
(
5000
).
fadeOut
(
'slow'
);
=======
$
(
'#message'
).
delay
(
5000
).
fadeOut
(
'slow'
);
>>>>>>>
create
favorite_job
page
});
app/assets/stylesheets/application.scss
View file @
a1978ad0
...
...
@@ -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%
;
}
app/controllers/favorites_controller.rb
0 → 100644
View file @
a1978ad0
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
app/controllers/jobs_controller.rb
View file @
a1978ad0
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
)
...
...
app/views/favorites/index.html.erb
0 → 100644
View file @
a1978ad0
<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>
app/views/jobs/show.html.erb
View file @
a1978ad0
...
...
@@ -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>
app/views/layouts/_flash.html.erb
View file @
a1978ad0
<%
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"
>
×
</a>
<strong>
<%=
"
#{
name
}
!"
%>
</strong>
<%=
msg
%>
</div>
...
...
app/views/layouts/_menu.html.erb
View file @
a1978ad0
...
...
@@ -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>
...
...
config/routes.rb
View file @
a1978ad0
...
...
@@ -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
...
...
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