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
b58c2869
Commit
b58c2869
authored
Sep 09, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix favorite funtion
parent
6cebaf88
Pipeline
#1423
canceled with stages
in 0 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
4 deletions
+11
-4
app/controllers/jobs_controller.rb
+2
-1
app/helpers/application_helper.rb
+4
-0
app/views/favorite_jobs/update.js.slim
+2
-1
app/views/jobs/index.html.slim
+2
-1
app/views/jobs/show.html.slim
+1
-1
No files found.
app/controllers/jobs_controller.rb
View file @
b58c2869
...
...
@@ -11,6 +11,7 @@ class JobsController < ApplicationController
industry
=
Industry
.
find_by
(
slug:
params
[
:industry_slug
])
jobs
=
industry
.
jobs
@result
=
industry
.
name
end
@total
=
jobs
.
count
@jobs
=
jobs
.
latest_jobs
.
page
(
params
[
:page
])
...
...
@@ -18,7 +19,7 @@ class JobsController < ApplicationController
def
show
@job
=
Job
.
find_by
(
slug:
params
[
:job_slug
])
or
not_found
@favorite_exists
=
!
FavoriteJob
.
find_by
(
job:
@job
,
user:
current_user
).
nil?
check_favorite_exists
(
@job
)
end
private
...
...
app/helpers/application_helper.rb
View file @
b58c2869
...
...
@@ -28,4 +28,8 @@ module ApplicationHelper
def
favorite_text
@favorite_exists
?
'Unfavorite'
:
'Favorite'
end
def
check_favorite_exists
(
input
)
@favorite_exists
=
!
FavoriteJob
.
find_by
(
job:
input
,
user:
current_user
).
nil?
end
end
app/views/favorite_jobs/update.js.slim
View file @
b58c2869
|
$(
'#favorite_link'
).text("
|
$(
"#favorite-
#{
@job
.
id
}
"
).text("
=
favorite_text
|
");
\ No newline at end of file
app/views/jobs/index.html.slim
View file @
b58c2869
...
...
@@ -12,6 +12,7 @@
=
paginate
@jobs
,
window:
1
.job-list
-
@jobs
.
each
do
|
job
|
=
check_favorite_exists
(
job
)
.row.bg-white
.col-10.p-3.card-body.text-dark
h5
.mb-1
...
...
@@ -29,7 +30,7 @@
=
truncate
(
job
.
overview
,
length:
250
)
.col-sm-2.p-3.favourite
-
if
user_signed_in?
=
link_to
favorite_text
,
favorite_update_path
(
job_id:
job
.
id
),
id:
'favorite_link'
,
remote:
true
,
class:
"btn btn-outline-primary btn-lg"
=
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
...
...
app/views/jobs/show.html.slim
View file @
b58c2869
...
...
@@ -52,6 +52,6 @@
=
link_to
"Apply this Job"
,
apply_path
(
job_id:
@job
.
id
),
class:
"btn btn-outline-primary btn-lg"
.col.text-start
-
if
user_signed_in?
=
link_to
favorite_text
,
favorite_update_path
(
job_id:
@job
.
id
),
id:
'favorite_link'
,
remote:
true
,
class:
"btn btn-outline-primary btn-lg"
=
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