fix progress bar and add session for input field

parent b4c15816
Pipeline #1389 failed with stages
in 0 seconds
......@@ -38,3 +38,4 @@
/yarn-error.log
yarn-debug.log*
.yarn-integrity
/config/credentials.yml.enc
\ No newline at end of file
......@@ -8,6 +8,10 @@
padding-bottom: 10px;
}
footer {
min-height: 227px;
}
.navbar ul li a {
color: #fff;
font-size: 18px;
......@@ -63,6 +67,8 @@
justify-content: center;
}
// ribbon
.ribbon {
width: 100%;
}
......@@ -85,7 +91,7 @@
width: 40px;
height: 40px;
line-height: 40px;
border: 1px solid #ddd;
border: 2px solid #ddd;
display: block;
text-align: center;
margin: 0 auto 10px auto;
......@@ -97,7 +103,7 @@
content : '';
position:absolute;
width: 100%;
height: 1px;
height: 3px;
line-height: 40px;
background-color: #ddd;
top: 15px;
......@@ -121,10 +127,27 @@
background-color: blue;
}
// form
.btn-space {
margin-right: 10px;
}
footer {
min-height: calc(100vh - 327px);
.form-apply label {
margin: 8px 0;
font-size: 18px;
}
#error_explanation {
color: red;
ul {
color: red;
margin: 0 0 30px 0;
}
}
.field_with_errors {
.form-control {
color: $danger;
}
}
\ No newline at end of file
class ApplyJobsController < ApplicationController
def new
@apply_job = ApplyJob.new
@apply_job.job_id = params[:job_id]
job = Job.find_by(id: params[:job_id])
return root_path unless job
@apply_job = if session[:apply_job].present?
ApplyJob.new(session[:apply_job])
else
ApplyJob.new
end
@apply_job.job_id = job.id
end
def confirm
@apply_job = ApplyJob.new(apply_params)
@apply_job.job_id = apply_params[:job_id]
@apply_job.user_id = User.find_by(id: 1).id
if @apply_job.valid?
session[:apply_job] = @apply_job
render :confirm
else
render :new
end
end
def done
@apply_job = ApplyJob.new(apply_params)
@apply_job.user_id = User.find_by(id: 1).id
@apply_job.job_id = apply_params[:job_id]
if @apply_job.save!
ApplyJobMailer.with(apply_job: @apply_job).create_apply.deliver_now
flash.now[:success] = "You have applied successfully"
@job = Job.latest_jobs.find(apply_params[:job_id])
if @apply_job.save
ApplyJobMailer.with(apply_job: @apply_job, job: @job).create_apply.deliver_now
flash.now[:success] = 'You have applied successfully'
else
flash.now[:danger] = 'Please apply again'
redirect_to root_url
end
session[:apply_job] = nil
end
private
......
......@@ -4,4 +4,16 @@ module ApplicationHelper
input.strftime('%d/%m/%Y')
end
def class_active(link_path)
return unless current_page?(link_path)
'active'
end
def current_page?(*paths)
return true if paths.include?(request.path)
false
end
end
class ApplicationMailer < ActionMailer::Base
default from: 'nhmphuong1005@gmail.com'
default from: 'info@venjob.com'
layout 'mailer'
end
class ApplyJobMailer < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.apply_job_mailer.create_apply.subject
#
def create_apply
@apply_job = params[:apply_job]
#@name = params[:name]
# @email = params[:email]
# @cv = params[:email]
@job = params[:job]
mail to: @apply_job.email, subject: 'CONFIRM INFORMATION'
end
# def create_apply
# @greeting = "Hi"
# mail to: "to@example.org"
# end
end
......@@ -5,5 +5,6 @@ class ApplyJob < ApplicationRecord
validates :name, presence: true, length: { maximum: 200 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX }
validates :cv, attached: true, content_type: { in: 'application/pdf', message: 'must be a valid cv format' }
validates :cv, presence: true, content_type: { in: 'application/pdf', message: 'must be a valid image format' },
size: { less_than: 5.megabytes, message: 'should be less than 5MB' }
end
......@@ -4,8 +4,8 @@ class Industry < ApplicationRecord
has_and_belongs_to_many :jobs
LATEST_INDUSTRY_NUMBER = 9
scope :top_industries, -> { joins(:jobs).group(:name, :slug).order('count_all DESC').count.take(LATEST_INDUSTRY_NUMBER) }
scope :industry_list, -> { joins(:jobs).group(:name, :slug).having('count_all >= ?', 1).order('count_all DESC').count }
scope :top_industries, -> { group(:name, :slug).order('count_all DESC').count.take(LATEST_INDUSTRY_NUMBER) }
scope :industry_list, -> { group(:name, :slug).having('count_all >= ?', 1).order('count_all DESC').count }
def normalize_friendly_id(string)
string.to_s.to_slug.normalize(transliterations: :vietnamese).to_s
......
......@@ -8,7 +8,7 @@ class Job < ApplicationRecord
has_and_belongs_to_many :industries
has_and_belongs_to_many :cities
LATEST_JOB_NUMBER = 5
scope :latest_jobs, -> { includes(:cities, :industries, :company).order('created_at DESC') }
scope :latest_jobs, -> { includes(:cities, :company).order('created_at DESC') }
def normalize_friendly_id(string)
string.to_s.to_slug.normalize(transliterations: :vietnamese).to_s
......
......@@ -4,11 +4,15 @@ p
| ,
p
| Thank you for applied with VenJOB. Your applied job's information is as follow:
/ Job title: <Job title>
/ Location: <Job location>
/ Company: <Company>
p
| Job title:
= @job.title
p
| Company:
= @job.company.name
p
| Location:
= @job.cities.map(&:name).uniq.join(' , ')
p
| Your submitted information:
p
......
| Dear
= @apply_job.name
| ,
| Thank you for applied with VenJOB. Your applied job's information is as follow:
| Your submitted information:
| Job title:
= @job.title
| Company:
= @job.company.name
| Location:
= @job.cities.map(&:name).uniq.join(' , ')
| Full Name:
= @apply_job.name
| Email:
......
.ribbon
ul.progressbar
li.active
li class="#{class_active(apply_path)}"
.span.indicator
.span.title Apply
li
.span.indicator.2
li class="#{class_active(confirm_path)}"
.span.indicator
.span.title Confirm
li
.span.indicator.3
li class="#{class_active(done_path)}"
.span.indicator
.span.title Done
\ No newline at end of file
.ribbon
ul.progressbar
li
.span.indicator
.span.title Apply
li.active
.span.indicator.2
.span.title Confirm
li
.span.indicator.3
.span.title Done
h2.text-center.p-4
= render 'ribbon'
h2.text-center
| CONFIRM INFORMATION
.col-md-6.offset-md-3
= form_with(model: @apply_job, url: '/done', local: true) do |f|
.col-md-6.offset-md-3.form-apply
= form_with(model: @apply_job, url: done_path, local: true) do |f|
= render 'shared/error_messages'
= f.hidden_field :job_id
= f.label :name
= f.text_field :name, required: true, disabled: true,length: { maximum: 200 }, placeholder: "Type name...", class: 'form-control'
= f.hidden_field :name, required: true, length: { maximum: 50 }
= f.text_field :name, required: true, disabled: true, length: { maximum: 200 },
placeholder: "Type name...", class: 'form-control'
= f.hidden_field :name
= f.label :email
= f.text_field :email, required: true, disabled: true,length: { maximum: 255 }, format: { with: ApplyJob::VALID_EMAIL_REGEX}, placeholder: "Type email...", class: 'form-control'
= f.hidden_field :email, required: true, length: { maximum: 255 }, format: { with: ApplyJob::VALID_EMAIL_REGEX}
= f.text_field :email, required: true, disabled: true, length: { maximum: 255 }, format: { with: ApplyJob::VALID_EMAIL_REGEX},
placeholder: "Type email...", class: 'form-control'
= f.hidden_field :email
p.my-1
= f.label :cv, "CV"
p
= f.file_field :cv, required: true, accept: "application/pdf"
.span.p-4.text-center
= link_to "Back", apply_path, class: "btn btn-primary btn-lg btn-space"
= f.submit "Done", class: "btn btn-primary btn-lg btn-space"
\ No newline at end of file
= f.file_field :cv, required: true, accept: "application/pdf", size: { less_than: 5.megabytes, message:"should be less than 5MB" }
.span.p-3.text-center
= link_to "Back", apply_path(job_id: @apply_job.job_id), class: "btn btn-primary btn-space"
= f.submit "Done", class: "btn btn-primary btn-space"
\ No newline at end of file
.ribbon.py-4
ul.progressbar
li
.span.indicator
.span.title Apply
li
.span.indicator.2
.span.title Confirm
li.active
.span.indicator.3
.span.title Done
.container.py-4
= render 'ribbon'
.container.py-5
h3.py-3.text-center
| Thank you for apply
\ No newline at end of file
| Thank you for apply
p.p-3.text-center
= link_to "Back to TOP page", root_path, class: "btn btn-primary btn-lg"
\ No newline at end of file
.ribbon
ul.progressbar
li.active
.span.indicator
.span.title Apply
li
.span.indicator.2
.span.title Confirm
li
.span.indicator.3
.span.title Done
h2.text-center.p-4
= render 'ribbon'
h2.text-center.form-title
| APPLY INFORMATION
.col-md-6.offset-md-3
= form_with(model: @apply_job, url: '/confirm', local: true) do |f|
.col-md-6.offset-md-3.form-apply
= form_with(model: @apply_job, url: confirm_path, local: true) do |f|
= render 'shared/error_messages'
= f.hidden_field :job_id
= f.label :name
= f.text_field :name, required: true,length: { maximum: 200 }, placeholder: "Type name...", class: 'form-control'
= f.label :email
......@@ -21,6 +13,6 @@ h2.text-center.p-4
p.my-1
= f.label :cv, "CV"
p
= f.file_field :cv, required: true, accept: "application/pdf"
.span.p-4.text-center
= f.submit "Confirm", class: "btn btn-primary btn-lg"
\ No newline at end of file
= f.file_field :cv, required: true, accept: "application/pdf", size: { less_than: 5.megabytes, message:"should be less than 5MB" }
.span.p-3.text-center
= f.submit "Confirm", class: "btn btn-primary"
\ No newline at end of file
- if @apply_job.errors.any?
#error_explanation
.alert.alert-danger
| The form contains
= pluralize(@apply_job.errors.count, "error")
| .
ul
- @apply_job.errors.full_messages.each do |msg|
li
= msg
\ No newline at end of file
......@@ -40,6 +40,19 @@ Rails.application.configure do
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host: "localhost:3000" , protocol: "http"}
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'localhost:3000',
user_name: Rails.application.credentials.dig(:google_smtp, :email),
password: Rails.application.credentials.dig(:google_smtp, :password),
authentication: 'plain',
enable_starttls_auto: true }
# Mount Action Cable outside main process or domain.
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
......@@ -66,7 +79,7 @@ Rails.application.configure do
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
......
every 1.day, at: '08:00 am' do
rake 'crawler:all'
end
# every 1.day, at: '08:00 am' do
# rake 'crawler:all'
# end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment