Commit 5e079295 by Mai Hoang Thai Ha

fixed controller, add ribbon

parent a92c2bab
// Place all the styles related to the Applies controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
.label {
font-size: 20px;
color: black;
}
.ribbon{
font-weight: 400;
line-height: 1.5;
color: #212529;
display: flex;
.item {
display: inline-flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-align: center;
align-items: center;
-ms-flex-pack: center;
justify-content: center;
padding: 20px;
font-size: 1rem;
font-weight: 700;
line-height: 1.5;
color: #6c757d;
text-align: center;
text-decoration: none;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: transparent;
border: none;
border-radius: .25rem;
.circle {
display: inline-flex;
-ms-flex-line-pack: center;
align-content: center;
-ms-flex-pack: center;
justify-content: center;
width: 2em;
height: 2em;
padding: .5em 0;
margin: .25rem;
line-height: 1em;
color: #fff;
background-color: #6c757d;
border-radius: 50%
}
}
.current-page {
color: #0d6efd;
.circle {
background: #0d6efd;
}
}
.line {
flex: 1 0 32px;
min-width: 1px;
min-height: 1px;
margin: auto;
background-color: rgba(0,0,0,.12);
}
}
\ No newline at end of file
class AppliesController < ApplicationController
before_action :load_job, only: %i[new confirm create]
def index
end
before_action :load_job, only: %i[confirm create]
def create
@user = User.find_by(id: 1)
......@@ -17,10 +15,8 @@ class AppliesController < ApplicationController
end
end
def show
end
def new
@job = Job.find_by(id: params[:job_id])
@apply = @job.apply_jobs.build
end
......@@ -28,10 +24,12 @@ class AppliesController < ApplicationController
@user = User.find_by(id: 1)
@apply = @job.apply_jobs.build(apply_params)
@apply.user_id = @user.id
if @apply.valid?
@name = params[:apply_job][:user_name]
@email = params[:apply_job][:email]
@cv = params[:apply_job][:cv]
@name = @apply.user_name
@email = @apply.email
@cv = @apply.cv
@job_id = @apply.job_id
else
render 'new'
end
......@@ -40,7 +38,7 @@ class AppliesController < ApplicationController
private
def load_job
@job = Job.find_by(id: params[:job_id])
@job = Job.find_by(id: params[:apply_job][:job_id])
end
def apply_params
......
class City < ApplicationRecord
scope :jobs_count, -> { joins(:jobs).group(:region).count }
has_and_belongs_to_many :jobs
enum region: { vietnam: 0, international: 1 }
validates :slug, presence: true, uniqueness: { case_sensitive: true }
def to_params
slug
end
has_and_belongs_to_many :jobs
def add_slugs
update slug: to_slug(name)
end
validates :slug, presence: true, uniqueness: { case_sensitive: true }
def self.top_jobs
self.all.map { |city| [city, city.jobs.count] }.sort_by(&:second).reverse.take(9)
all.map { |city| [city, city.jobs.count] }.sort_by(&:second).reverse.take(9)
end
end
......@@ -5,17 +5,7 @@ class Industry < ApplicationRecord
validates :slug, presence: true, uniqueness: { case_sensitive: true }
# before_validation :add_slugs
def to_params
slug
end
def add_slugs
update slug: to_slug(name)
end
def self.top_jobs
self.all.map { |industry| [industry, industry.jobs.count] }.sort_by(&:second).reverse.take(9)
all.map { |industry| [industry, industry.jobs.count] }.sort_by(&:second).reverse.take(9)
end
end
ul.ribbon
-if current_page?(action: 'new')
li.item.current-page
span.circle
| 1
| Apply
-else
li.item
span.circle
| 1
| Apply
.line
-if current_page?(action: 'confirm')
li.item.current-page
span.circle
| 2
| Confimation
-else
li.item
span.circle
| 2
| Confimation
.line
-if current_page?(action: 'create')
li.item.current-page
span.circle
| 3
| Done
-else
li.item
span.circle
| 3
| Done
\ No newline at end of file
- provide(:title, "Apply job")
- provide(:title, 'Confirmation')
.container
=render 'ribbon'
.container
h1.my-5.text-center
| Confirm
= @job.title
.col
= form_with(model: @apply, scope: :apply_job, url: done_path(job_id: @job), local: true) do |f|
= form_with(model: @apply, scope: :apply_job, url: done_path, local: true) do |f|
.mb-3
= f.label :name, 'Full name:', class: 'form-label'
span.mx-2
.mb-5
= f.hidden_field :job_id, value: @job_id, class: 'form-control'
= f.label :name, 'Full name:', class: 'form-label label'
span.mx-2.label
= @name
= f.hidden_field :user_name, value: @name, class: 'form-control'
.mb-3
= f.label :email, 'Email:', class: 'form-label'
span.mx-2
.mb-5
= f.label :email, 'Email:', class: 'form-label label'
span.mx-2.label
= @email
= f.hidden_field :email, value: @email, class: 'form-control'
.mb-5
span
= f.label :cv, 'Cv: ', class: 'form-label label'
= f.file_field :cv, accept: 'application/pdf, application/msword, application/zip, application/xls, application/xlsx'
span.mb-3.d-block.align-center
= f.label :cv, 'Cv:', class: 'form-label'
/ = f.hidden_field :cv, value: @cv
= f.file_field :cv
span.mx-2
= @cv.original_filename
= link_to 'Edit', apply_path(job_id: @job.id), class: "btn btn-secondary py-2 px-4"
= f.submit "Confirm", class: "btn btn-primary"
.row.justify-content-between
.col-6
= link_to 'Edit', apply_path(job_id: @job_id), class: 'btn btn-secondary py-2 px-4 w-100'
.col-6
= f.submit 'Confirm', class: 'btn btn-primary w-100'
- provide(:title, 'Done')
.container
=render 'ribbon'
.container.text-center
h3.my-4
| You have successfully applied for the #{@job.title}
......
- provide(:title, "Apply job")
- provide(:title, 'Apply job')
.container
=render 'ribbon'
.container
h1.my-5.text-center
| Apply for
= @job.title
.col
= form_with(model: @apply, scope: :apply_job, url: confirm_path(job_id: @job), local: true) do |f|
= form_with(model: @apply, scope: :apply_job, url: confirm_path, local: true) do |f|
= render 'shared/error_messages', object: f.object
.mb-3
= f.label :user_name, 'Full name', class: 'form-label'
.mb-5
= f.hidden_field :job_id, value: @job.id, class: 'form-control'
= f.label :user_name, 'Full name', class: 'form-label label'
= f.text_field :user_name, class: 'form-control'
.mb-3
= f.label :email, class: 'form-label'
.mb-5
= f.label :email, class: 'form-label label'
= f.text_field :email, class: 'form-control'
span.mb-3.d-block.align-center
= f.file_field :cv
= f.submit "Submit", class: "btn btn-primary"
.mb-5
span.label
= f.file_field :cv, accept: 'application/pdf, application/msword, application/zip, application/xls, application/xlsx'
= f.submit 'Confirm', class: 'btn btn-primary w-100'
......@@ -8,6 +8,7 @@
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "5.4.0",
"bootstrap": "^5.0.0-beta3",
"bs-stepper": "^1.7.0",
"jquery": "^3.6.0",
"turbolinks": "^5.2.0",
"webpack": "^4.46.0",
......
......@@ -1609,6 +1609,11 @@ browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.16.6, browserslist@^4
escalade "^3.1.1"
node-releases "^1.1.71"
bs-stepper@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/bs-stepper/-/bs-stepper-1.7.0.tgz#bfa4cc51c4e67957caae57f5bdcba1977186bac1"
integrity sha512-+DX7UKKgw2GI6ucsSCRd19VHYrxf/8znRCLs1lQVVLxz+h7EqgIOxoHcJ0/QTaaNoR9Cwg78ydo6hXIasyd3LA==
buffer-from@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
......
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