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
Mai Hoang Thai Ha
VenJob
Commits
6736961a
Commit
6736961a
authored
Aug 16, 2021
by
Mai Hoang Thai Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use session to keep value when back form
parent
b51d4466
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
8 deletions
+16
-8
app/controllers/applies_controller.rb
+11
-2
app/javascript/packs/application.js
+1
-1
app/views/applies/confirm.html.slim
+1
-1
app/views/applies/new.html.slim
+3
-4
No files found.
app/controllers/applies_controller.rb
View file @
6736961a
...
@@ -2,14 +2,22 @@ class AppliesController < ApplicationController
...
@@ -2,14 +2,22 @@ class AppliesController < ApplicationController
before_action
:load_job
,
only:
%i[new confirm create]
before_action
:load_job
,
only:
%i[new confirm create]
def
new
def
new
@apply
=
current_user
.
apply_jobs
.
build
@apply
=
if
request
.
referer
.
include?
(
'confirm'
)
&&
session
[
:apply_job
].
present?
ApplyJob
.
new
(
session
[
:apply_job
])
else
current_user
.
apply_jobs
.
build
end
end
end
def
confirm
def
confirm
@apply
=
current_user
.
apply_jobs
.
build
(
apply_params
)
@apply
=
current_user
.
apply_jobs
.
build
(
apply_params
)
@apply
.
job
=
@job
@apply
.
job
=
@job
render
'new'
if
@apply
.
invalid?
if
@apply
.
valid?
session
[
:apply_job
]
=
@apply
else
render
'new'
end
end
end
def
create
def
create
...
@@ -23,6 +31,7 @@ class AppliesController < ApplicationController
...
@@ -23,6 +31,7 @@ class AppliesController < ApplicationController
else
else
render
'new'
render
'new'
end
end
session
[
:apply_job
]
=
nil
end
end
private
private
...
...
app/javascript/packs/application.js
View file @
6736961a
...
@@ -15,4 +15,4 @@ ActiveStorage.start()
...
@@ -15,4 +15,4 @@ ActiveStorage.start()
import
"bootstrap"
import
"bootstrap"
window
.
bootstrap
=
require
(
"bootstrap"
);
window
.
bootstrap
=
require
(
"bootstrap"
);
import
"../stylesheets/application.scss"
;
import
"../stylesheets/application.scss"
;
import
"./validation"
;
app/views/applies/confirm.html.slim
View file @
6736961a
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
span
.form-control
span
.form-control
=
url_for
(
@apply
.
cv
)
=
url_for
(
@apply
.
cv
)
=
link_to
'Edit'
,
apply_path
(
job_id:
@job
.
id
)
,
class:
'btn btn-secondary w-25 btn-height mr-5 my-5'
=
link_to
'Edit'
,
:back
,
class:
'btn btn-secondary w-25 btn-height mr-5 my-5'
=
f
.
submit
'Confirm'
,
class:
'btn btn-primary w-25 btn-height mx-5 my-5'
=
f
.
submit
'Confirm'
,
class:
'btn btn-primary w-25 btn-height mx-5 my-5'
...
...
app/views/applies/new.html.slim
View file @
6736961a
...
@@ -14,13 +14,13 @@
...
@@ -14,13 +14,13 @@
.col-2
.col-2
=
f
.
label
:user_name
,
'Full name'
,
class:
'form-label label'
=
f
.
label
:user_name
,
'Full name'
,
class:
'form-label label'
.col-10
.col-10
=
f
.
text_field
:user_name
,
value:
@current_user
.
name
,
class:
'form-control'
=
f
.
text_field
:user_name
,
value:
@
apply
.
user_name
||=
@
current_user
.
name
,
class:
'form-control'
span
.form-msg
span
.form-msg
.row.mb-5.form-group
.row.mb-5.form-group
.col-2
.col-2
=
f
.
label
:email
,
class:
'form-label label'
=
f
.
label
:email
,
class:
'form-label label'
.col-10
.col-10
=
f
.
text_field
:email
,
value:
@current_user
.
email
,
class:
'form-control'
=
f
.
text_field
:email
,
value:
@
apply
.
email
||=
@
current_user
.
email
,
class:
'form-control'
span
.form-msg
span
.form-msg
.row.mb-5
.row.mb-5
/ - if @user.cv.attached?
/ - if @user.cv.attached?
...
@@ -31,8 +31,7 @@
...
@@ -31,8 +31,7 @@
=
f
.
file_field
:cv
,
accept:
ApplyJob
::
ACCEPT_CONTENT_TYPE
,
class:
'form-control'
=
f
.
file_field
:cv
,
accept:
ApplyJob
::
ACCEPT_CONTENT_TYPE
,
class:
'form-control'
=
f
.
submit
'Confirm'
,
class:
'btn btn-primary w-25 my-4 btn-height'
=
f
.
submit
'Confirm'
,
class:
'btn btn-primary w-25 my-4 btn-height'
/ = render 'validate_form'
=
render
'validate_form'
=
javascript_pack_tag
'validation'
javascript:
javascript:
Validator
({
Validator
({
form
:
'#apply-form'
,
form
:
'#apply-form'
,
...
...
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