Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjob_nth
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
3
Merge Requests
3
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
Ngô Trung Hưng
venjob_nth
Commits
e105f69b
Commit
e105f69b
authored
Aug 21, 2020
by
Ngô Trung Hưng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix code favorite
parent
e17efe61
Pipeline
#981
canceled with stages
in 0 seconds
Changes
14
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
31 additions
and
31 deletions
+31
-31
app/controllers/favorite_controller.rb
+3
-3
app/controllers/job_controller.rb
+7
-0
app/helpers/application_helper.rb
+7
-1
app/helpers/apply_job_helper.rb
+0
-5
app/helpers/favorite_helper.rb
+0
-3
app/views/job/_block_info_job.html.erb
+2
-2
app/views/job/_block_job_mini.html.erb
+1
-1
app/views/job/_link_create.html.erb
+1
-1
app/views/job/_link_create_favorite_in_detail.html.erb
+1
-1
app/views/job/_link_destroy.html.erb
+1
-1
app/views/job/_link_destroy_favorite_in_detail.html.erb
+1
-1
app/views/layouts/_header.html.erb
+6
-6
app/views/users/sign_in.js.erb
+0
-3
config/routes.rb
+1
-3
No files found.
app/controllers/favorite_controller.rb
View file @
e105f69b
...
...
@@ -4,7 +4,7 @@ class FavoriteController < ApplicationController
before_action
:authenticate_user!
def
index
@favorites
=
current_user
.
favorites
.
map
(
&
:job
)
@favorites
=
current_user
.
favorites
.
order
(
created_at: :desc
).
map
(
&
:job
)
end
def
create
...
...
@@ -13,13 +13,13 @@ class FavoriteController < ApplicationController
@favorite
=
current_user
.
favorites
.
new
(
job_id:
params
[
:job_id
])
if
@favorite
.
invalid?
helpers
.
render_errors
(
@favorite
)
redirect_to
favorite_index_path
re
turn
re
direct_to
favorite_index_path
end
respond_to
:js
if
@favorite
.
save
end
def
destroy
@favorite
=
current_user
.
favorites
.
find_by
(
id:
params
[
:
favorite_
id
])
@favorite
=
current_user
.
favorites
.
find_by
(
id:
params
[
:id
])
return
redirect_to
favorite_index_path
if
@favorite
.
blank?
respond_to
:js
if
@favorite
.
destroy
...
...
app/controllers/job_controller.rb
View file @
e105f69b
...
...
@@ -3,6 +3,12 @@
# Job controller
class
JobController
<
ApplicationController
before_action
:load_data_dropdown
,
only: :index
# after_action :add_job_to_history, only: :detail
def
add_job_to_history
current_user
.
histories
.
create
(
session
[
:params_job_id
])
if
user_signed_in?
session
.
delete
(
:params_job_id
)
end
def
index
model
=
params
[
:model
].
classify
.
constantize
...
...
@@ -11,6 +17,7 @@ class JobController < ApplicationController
end
def
detail
session
[
:params_job_id
]
=
params
[
:id
]
@job
=
Job
.
find
(
params
[
:id
]).
decorate
cities
=
@job
.
cities
.
first
industries
=
@job
.
industries
.
first
...
...
app/helpers/application_helper.rb
View file @
e105f69b
...
...
@@ -11,12 +11,18 @@ module ApplicationHelper
flash_messages
=
[]
flash
.
each
do
|
type
,
message
|
next
if
message
.
blank?
message
.
delete!
(
"'"
)
if
message
.
include?
(
"'"
)
type
=
'success'
if
type
==
'notice'
type
=
'error'
if
type
==
'alert'
type
=
'warning'
if
type
==
'alert'
text
=
"<script>toastr.
#{
type
}
('
#{
message
}
');</script>"
flash_messages
<<
text
.
html_safe
if
message
end
flash_messages
.
join
(
"
\n
"
).
html_safe
end
def
render_errors
(
obj
)
errors
=
[]
obj
.
errors
.
full_messages
.
each
{
|
mess
|
errors
<<
"
#{
mess
}
<br>"
}
flash
[
:error
]
=
errors
.
join
(
'<br>'
).
html_safe
end
end
app/helpers/apply_job_helper.rb
View file @
e105f69b
# frozen_string_literal: true
module
ApplyJobHelper
def
render_errors
(
obj
)
errors
=
[]
obj
.
errors
.
full_messages
.
each
{
|
mess
|
errors
<<
"
#{
mess
}
<br>"
}
flash
[
:error
]
=
errors
.
join
(
'<br>'
).
html_safe
end
end
app/helpers/favorite_helper.rb
View file @
e105f69b
module
FavoriteHelper
def
render_errors
(
obj
)
obj
.
errors
.
full_messages
.
each
{
|
mess
|
flash
[
:warning
]
=
mess
}
end
end
app/views/job/_block_info_job.html.erb
View file @
e105f69b
...
...
@@ -39,9 +39,9 @@
<div
class=
"col-sm-2 col-md-3 d-none d-sm-block col-lg-2"
>
<div
class=
"link_favorite_top block_link_favorite"
>
<%
if
user_signed_in?
%>
<%
@
favorite_id
=
current_user
.
favorites
.
find_by
(
job_id:
data
.
id
)
%>
<%
favorite_id
=
current_user
.
favorites
.
find_by
(
job_id:
data
.
id
)
%>
<%
if
favorite_id
.
present?
%>
<%=
render
'job/link_destroy'
,
favorite_id:
@
favorite_id
%>
<%=
render
'job/link_destroy'
,
favorite_id:
favorite_id
%>
<%
else
%>
<%=
render
'job/link_create'
,
job_id:
data
.
id
%>
<%
end
%>
...
...
app/views/job/_block_job_mini.html.erb
View file @
e105f69b
...
...
@@ -29,7 +29,7 @@
</div>
</div>
<div
class=
"col-lg-1 col-md-1 col-sm-1"
>
<%=
link_to
'<i class="fas fa-trash"></i>'
.
html_safe
,
destroy_favorite_path
(
favorite_id:
data
.
favorites
.
ids
),
method: :delete
,
remote:
true
,
class:
'link_favorite in_block'
%>
<%=
link_to
'<i class="fas fa-trash"></i>'
.
html_safe
,
favorite_path
(
data
.
favorites
.
ids
),
method: :delete
,
remote:
true
,
class:
'link_favorite in_block'
%>
</div>
</div>
</div>
...
...
app/views/job/_link_create.html.erb
View file @
e105f69b
<%=
link_to
'<i class="far fa-heart"></i>'
.
html_safe
,
favorite_path
(
job_id:
job_id
),
method: :post
,
remote:
true
,
class:
'link_favorite'
%>
<%=
link_to
'<i class="far fa-heart"></i>'
.
html_safe
,
favorite_
index_
path
(
job_id:
job_id
),
method: :post
,
remote:
true
,
class:
'link_favorite'
%>
app/views/job/_link_create_favorite_in_detail.html.erb
View file @
e105f69b
<%=
link_to
t
(
'pages.index.btn_text_favorite'
),
favorite_path
(
job_id:
job_id
),
method: :post
,
remote:
true
,
class:
'btn btn-apply_job_favorite'
%>
<%=
link_to
t
(
'pages.index.btn_text_favorite'
),
favorite_
index_
path
(
job_id:
job_id
),
method: :post
,
remote:
true
,
class:
'btn btn-apply_job_favorite'
%>
app/views/job/_link_destroy.html.erb
View file @
e105f69b
<%=
link_to
'<i class="fas fa-heart"></i>'
.
html_safe
,
destroy_favorite_path
(
favorite_id:
favorite_id
),
method: :delete
,
remote:
true
,
class:
'link_favorite'
%>
<%=
link_to
'<i class="fas fa-heart"></i>'
.
html_safe
,
favorite_path
(
favorite_id
),
method: :delete
,
remote:
true
,
class:
'link_favorite'
%>
app/views/job/_link_destroy_favorite_in_detail.html.erb
View file @
e105f69b
<%=
link_to
t
(
'pages.index.unfavorite'
),
destroy_favorite_path
(
favorite_id:
favorite_id
),
method: :delete
,
remote:
true
,
class:
'btn btn-apply_job_favorite unfavorite'
%>
<%=
link_to
t
(
'pages.index.unfavorite'
),
favorite_path
(
favorite_id
),
method: :delete
,
remote:
true
,
class:
'btn btn-apply_job_favorite unfavorite'
%>
app/views/layouts/_header.html.erb
View file @
e105f69b
...
...
@@ -10,11 +10,9 @@
<div
class=
"header_top_menu_right"
>
<ul
class=
"list_menu_header_right"
>
<li
class=
"list_item_menu_header_right"
>
<%
if
user_signed_in?
%>
<%=
link_to
"(
#{
current_user
.
favorites
.
count
}
)
#{
t
(
'pages.index.favorite'
)
}
"
,
favorite_index_path
,
class:
'link_item_menu_header_right number_favorite'
%>
<%
else
%>
<%=
link_to
t
(
'pages.index.favorite'
),
favorite_index_path
,
class:
'link_item_menu_header_right'
%>
<%
end
%>
<%=
link_to_if
(
!
user_signed_in?
,
t
(
'pages.index.favorite'
),
favorite_index_path
,
class:
'link_item_menu_header_right number_favorite'
)
do
link_to
"(
#{
current_user
.
favorites
.
count
}
)
#{
t
(
'pages.index.favorite'
)
}
"
,
favorite_index_path
,
class:
'link_item_menu_header_right'
end
%>
</li>
<li
class=
"list_item_menu_header_right"
>
<%=
link_to
t
(
'pages.index.history'
),
'#'
,
class:
'link_item_menu_header_right'
%>
...
...
@@ -57,7 +55,9 @@
<div class = "menu_mobile_vertical">
<ul class = "list_menu_mobile_vertical">
<li class = "item_menu_mobile_vertical">
<%= link_to t('pages.index.favorite'), favorite_index_path, class: 'link_item_menu_mobile' %>
<%= link_to_if(!user_signed_in?, t('pages.index.favorite'), favorite_index_path, class: 'link_item_menu_mobile') do
link_to "(#{current_user.favorites.count}) #{t('pages.index.favorite')}", favorite_index_path, class: 'link_item_menu_mobile number_favorite'
end %>
</li>
<li class = "item_menu_mobile_vertical">
<%= link_to t('pages.index.history'), '#', class: 'link_item_menu_mobile' %>
...
...
app/views/users/sign_in.js.erb
deleted
100644 → 0
View file @
e17efe61
alert('You will be redirected to log in.');
window.location = '/users/sign_in';
\ No newline at end of file
config/routes.rb
View file @
e105f69b
...
...
@@ -15,9 +15,7 @@ Rails.application.routes.draw do
post
'done'
,
to:
'apply_job#done'
,
as: :done
get
'my/jobs'
,
to:
'apply_job#index'
,
as: :list_applied_jobs
# Fovorite
post
'favorite'
,
to:
'favorite#create'
,
as: :favorite
delete
'favorite'
,
to:
'favorite#destroy'
,
as: :destroy_favorite
get
'favorite'
,
to:
'favorite#index'
,
as: :favorite_index
resources
:favorite
,
only:
%i[index create destroy]
# Details job
get
'detail/:id'
,
to:
'job#detail'
,
as: :detail_job
# Search
...
...
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