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
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
Nguyen Hoang Mai Phuong
VeNJOB
Commits
31945fac
Commit
31945fac
authored
Sep 09, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor code
parent
1c8089a4
Pipeline
#1425
canceled with stages
in 0 seconds
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
9 additions
and
19 deletions
+9
-19
app/controllers/favorite_jobs_controller.rb
+0
-2
app/controllers/jobs_controller.rb
+1
-1
app/helpers/application_helper.rb
+2
-6
app/views/favorite_jobs/_favorite.slim
+2
-0
app/views/favorite_jobs/update.js.slim
+2
-1
app/views/jobs/index.html.slim
+1
-5
app/views/jobs/show.html.slim
+1
-4
No files found.
app/controllers/favorite_jobs_controller.rb
View file @
31945fac
...
@@ -10,10 +10,8 @@ class FavoriteJobsController < ApplicationController
...
@@ -10,10 +10,8 @@ class FavoriteJobsController < ApplicationController
favorite
=
favorite_query
.
find_favorite
(
job_params
,
current_user
)
favorite
=
favorite_query
.
find_favorite
(
job_params
,
current_user
)
if
favorite
.
nil?
if
favorite
.
nil?
FavoriteJob
.
create
(
job:
@job
,
user:
current_user
)
FavoriteJob
.
create
(
job:
@job
,
user:
current_user
)
@favorite_exists
=
true
else
else
favorite
.
destroy
favorite
.
destroy
@favorite_exists
=
false
end
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
new_user_session_path
,
alert:
'You need to sign in or sign up before continuing.'
}
format
.
html
{
redirect_to
new_user_session_path
,
alert:
'You need to sign in or sign up before continuing.'
}
...
...
app/controllers/jobs_controller.rb
View file @
31945fac
...
@@ -19,7 +19,7 @@ class JobsController < ApplicationController
...
@@ -19,7 +19,7 @@ class JobsController < ApplicationController
def
show
def
show
@job
=
Job
.
find_by
(
slug:
params
[
:job_slug
])
or
not_found
@job
=
Job
.
find_by
(
slug:
params
[
:job_slug
])
or
not_found
check_favorite_exists
(
@job
)
favorite_text
(
@job
)
end
end
private
private
...
...
app/helpers/application_helper.rb
View file @
31945fac
...
@@ -25,11 +25,7 @@ module ApplicationHelper
...
@@ -25,11 +25,7 @@ module ApplicationHelper
render
file:
"
#{
Rails
.
root
}
/public/404.html"
,
status: :not_found
render
file:
"
#{
Rails
.
root
}
/public/404.html"
,
status: :not_found
end
end
def
favorite_text
def
favorite_text
(
job
)
@favorite_exists
?
'Unfavorite'
:
'Favorite'
FavoriteJob
.
find_by
(
job:
job
,
user:
current_user
).
present?
?
'Unfavorite'
:
'Favorite'
end
def
check_favorite_exists
(
input
)
@favorite_exists
=
!
FavoriteJob
.
find_by
(
job:
input
,
user:
current_user
).
nil?
end
end
end
end
app/views/favorite_jobs/_favorite.slim
0 → 100644
View file @
31945fac
=
link_to
favorite_text
(
job
),
favorite_update_path
(
job_id:
job
.
id
),
id:
"favorite-
#{
job
.
id
}
"
,
remote:
user_signed_in?
,
class:
"btn btn-outline-primary btn-lg"
\ No newline at end of file
app/views/favorite_jobs/update.js.slim
View file @
31945fac
|
$("#favorite-
#{
@job
.
id
}
").text("
|
$("#favorite-
#{
@job
.
id
}
").text("
=
favorite_text
=
favorite_text
(
@job
)
|
");
|
");
\ No newline at end of file
app/views/jobs/index.html.slim
View file @
31945fac
...
@@ -12,7 +12,6 @@
...
@@ -12,7 +12,6 @@
=
paginate
@jobs
,
window:
1
=
paginate
@jobs
,
window:
1
.job-list
.job-list
-
@jobs
.
each
do
|
job
|
-
@jobs
.
each
do
|
job
|
=
hidden_field
:status
,
check_favorite_exists
(
job
)
.row.bg-white
.row.bg-white
.col-10.p-3.card-body.text-dark
.col-10.p-3.card-body.text-dark
h5
.mb-1
h5
.mb-1
...
@@ -29,10 +28,7 @@
...
@@ -29,10 +28,7 @@
p
.mb-1
p
.mb-1
=
truncate
(
job
.
overview
,
length:
250
)
=
truncate
(
job
.
overview
,
length:
250
)
.col-sm-2.p-3.favourite
.col-sm-2.p-3.favourite
-
if
user_signed_in?
=
render
partial:
"favorite_jobs/favorite"
,
locals:
{
job:
job
}
=
link_to
favorite_text
,
favorite_update_path
(
job_id:
job
.
id
),
id:
"favorite-
#{
job
.
id
}
"
,
remote:
true
,
class:
"btn btn-outline-primary btn-lg"
-
else
=
link_to
favorite_text
,
favorite_update_path
(
job_id:
job
.
id
),
class:
"btn btn-outline-primary btn-lg"
h6
.offset-md-4.px
h6
.offset-md-4.px
=
page_entries_info
@jobs
=
page_entries_info
@jobs
h6
.offset-md-4
h6
.offset-md-4
...
...
app/views/jobs/show.html.slim
View file @
31945fac
...
@@ -51,7 +51,4 @@
...
@@ -51,7 +51,4 @@
.col.text-end
.col.text-end
=
link_to
"Apply this Job"
,
apply_path
(
job_id:
@job
.
id
),
class:
"btn btn-outline-primary btn-lg"
=
link_to
"Apply this Job"
,
apply_path
(
job_id:
@job
.
id
),
class:
"btn btn-outline-primary btn-lg"
.col.text-start
.col.text-start
-
if
user_signed_in?
=
render
partial:
"favorite_jobs/favorite"
,
locals:
{
job:
@job
}
=
link_to
favorite_text
,
favorite_update_path
(
job_id:
@job
.
id
),
id:
"favorite-
#{
@job
.
id
}
"
,
remote:
true
,
class:
"btn btn-outline-primary btn-lg"
-
else
=
link_to
favorite_text
,
favorite_update_path
(
job_id:
@job
.
id
),
class:
"btn btn-outline-primary btn-lg"
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