Commit a3e9d1b3 by Ngô Trung Hưng

add loading page

parent 423eef1a
Pipeline #916 failed with stages
in 0 seconds
......@@ -15,3 +15,6 @@
//= require turbolinks
//= require jquery.min
//= require_tree .
toastr.options = {
'closeButton': true
}
......@@ -38,4 +38,12 @@ $(document).on("turbolinks:load", function(){
$("input[type=file]").on('change',function(){
document.getElementById ("label_name_file").innerHTML = this.files[0].name;
});
});
$(document).on("turbolinks:click", function(){
$(".box_loading").show();
});
$(document).on("turbolinks:load", function(){
$(".box_loading").hide();
});
......@@ -2,28 +2,38 @@
class ApplyJobController < ApplicationController
before_action :authenticate_user!, only: :apply
def apply
redirect_to root_path if params[:job_id].blank?
@data_apply = AppliedJob.new
session[:job_id] = params[:job_id]
end
def confirmation
@data_apply = AppliedJob.new(applied_job_params)
if @data_apply.save
session[:user_name] = @data_apply.name
session[:user_email] = @data_apply.email
redirect_to show_path
def catch_data(applied_job_params)
@apply_job = AppliedJob.new(applied_job_params)
if @apply_job.cv.blank?
if current_user.cv.present?
@apply_job.cv = current_user.cv
render :confirm
else
flash[:error] = 'error'
render 'apply'
flash[:error] = t('pages.mypage.nofile')
redirect_to apply_path(job_id: session[:job_id])
session.delete(:job_id)
end
end
@apply_job
end
def confirm
@apply_job ||= catch_data(applied_job_params)
end
def show
end
def save
@data_apply.save
debugger
confirm.save
end
private
......
......@@ -10,6 +10,7 @@ module ApplicationHelper
def custom_bootstrap_flash
flash_messages = []
flash.each do |type, message|
next if message.blank?
type = 'success' if type == 'notice'
type = 'error' if type == 'alert'
text = "<script>toastr.#{type}('#{message}');</script>"
......
......@@ -3,7 +3,9 @@
# Description/Explanation of Person class
class AppliedJob < ApplicationRecord
mount_uploader :cv, CvUploader
validates_integrity_of :cv
belongs_to :user
belongs_to :job
validates :name, :email, :cv, presence: true
validates :name, :email, length: {in: 8..200}
validates :email, format: Devise.email_regexp
end
<%= form_with(model: data_apply, url: confirm_path) do |f| %>
<%= form_with(model: data_apply, url: confirm_path, local: true) do |f| %>
<br>
<div class="container">
<div class="row">
......@@ -7,8 +7,9 @@
<%= f.label :name, t('pages.mypage.name') %>
</div>
<div class="col-lg-6">
<%= f.text_field(:name, class:'form-control') %>
<%= f.hidden_field(:job_id, value: session[:job_id]) %>
<%= f.text_field(:name, autofocus: true, autocomplete: 'name', class:'form-control') %>
<%= f.hidden_field(:job_id, value: params[:job_id]) %>
<%= f.hidden_field(:user_id, value: current_user.id) %>
</div>
</div><br>
<div class="row">
......@@ -17,7 +18,7 @@
<%= f.label :email%>
</div>
<div class="col-lg-6">
<%= f.text_field(:email, class:'form-control') %>
<%= f.text_field(:email, autofocus: true, autocomplete: 'email', class:'form-control') %>
</div>
</div><br>
<div class="row">
......@@ -26,8 +27,8 @@
<span><%= t('pages.mypage.cv') %></span>
</div>
<div class="col-lg-5 col-md-12">
<%= f.label :cv, current_user.cv.identifier ? 'current_user.cv.identifier' : t('pages.mypage.nofile'), id: 'label_name_file' %>
<%= f.file_field :cv, class: 'pppp hidden' %>
<%= f.label :cv, current_user.cv.identifier ? current_user.cv.identifier : t('pages.mypage.nofile'), id: 'label_name_file' %>
<%= f.file_field :cv, accept: '.pdf', class: 'pppp hidden' %>
</div>
<div class="col-lg-1">
<%= f.label :cv, '<i class="fas fa-cloud-upload-alt"></i>'.html_safe, title: 'upload', class: 'lable_custom' %>
......
......@@ -2,19 +2,19 @@
<div class="box_job_apply">
<div class="ribbon">
<div class="row">
<div class="col-lg-4 col-md-4">
<div class="col-lg-4 col-md-12">
<div class="ribbon_item active">
<span class="custom_badges active">1</span> Nhập thông tin
<span class="custom_badges active">1</span> <%= t('pages.apply.ribon_1') %>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="col-lg-4 col-md-12">
<div class="ribbon_item active">
<span class="custom_badges active">2</span> Xác nhận thông tin
<span class="custom_badges active">2</span> <%= t('pages.apply.ribon_2') %>
</div>
</div>
<div class="col-lg-4 col-md-4">
<div class="col-lg-4 col-md-12">
<div class="ribbon_item">
<span class="custom_badges">3</span> Hoàn thành
<span class="custom_badges">3</span> <%= t('pages.apply.ribon_3') %>
</div>
</div>
</div>
......@@ -30,7 +30,7 @@
Họ và tên:
</div>
<div class="col-lg-6">
<%= session[:user_name] %>
<%= @apply_job.name %>
</div>
</div><br>
<div class="row">
......@@ -39,13 +39,22 @@
Email:
</div>
<div class="col-lg-6">
<%= session[:user_email] %>
<%= @apply_job.email %>
</div>
</div><br>
<div class="row">
<div class="col-lg-2"></div>
<div class="col-lg-2">
CV:
</div>
<div class="col-lg-6">
<%= @apply_job.cv.identifier %>
</div>
</div>
</div>
<%= link_to 'save', save_path %>
<%= link_to 'back', edit_path(job_id: session[:job_id]) %>
<%= link_to t('devise.back'), :back %>
</div>
</div>
</div>
\ No newline at end of file
......@@ -34,7 +34,7 @@
<%= f.label :cv, t('pages.mypage.cv') %>
</div>
<div class="col-md-9">
<%= f.file_field :cv, autofocus: true, class: 'pppp' %>
<%= f.file_field :cv, accept: '.pdf', autofocus: true, class: 'pppp' %>
<i style="font-size: 15px; color: #666">Current file: <%= current_user.cv.identifier %></i>
</div>
</div><br>
......
......@@ -31,7 +31,7 @@
<%= f.label :cv, t('pages.mypage.cv') %>
</div>
<div class="col-md-9">
<%= f.file_field :cv, autofocus: true, class: 'pppp' %>
<%= f.file_field :cv, accept: '.pdf', autofocus: true, class: 'pppp' %>
</div>
</div><br>
<div class="row">
......
......@@ -19,6 +19,7 @@
<%= render 'layouts/padding' %>
<%= yield %>
<%= render 'layouts/footer' %>
<%= render 'shared/loading' %>
</div>
</body>
</html>
<% if resource.errors.any? %>
<div id="error_explanation">
<ul>
<% resource.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
\ No newline at end of file
<style>
body {
padding: 0;
margin: 0;
}
.box_loading {
z-index: 9999999;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
box-sizing: border-box;
background-image:
linear-gradient(to bottom, rgba(112, 112, 112, 0.486), rgba(112, 112, 112, 0.486));
}
.content {
position: absolute;
top: 50%;
left: 50%;
width: 60px;
height: 60px;
border-radius: 50%;
border: 8px solid #f3f3f3c0;
border-left: 8px solid rgb(247, 127, 29);
border-right: 8px solid rgb(247, 127, 29);
transform: translateX(-50%) translateY(-50%);
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
<div class="box_loading">
<div class="content"></div>
</div>
......@@ -22,7 +22,7 @@ Rails.application.configure do
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = false
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
......
......@@ -10,8 +10,8 @@ Rails.application.routes.draw do
get 'industries', to: 'industry#index', as: :industry_index
get 'cities', to: 'city#index', as: :city_index
get 'apply', to: 'apply_job#apply', as: :apply
post 'confrim', to: 'apply_job#confirmation', as: :confirm
get 'confrim', to: 'apply_job#show', as: :show
post 'confirm', to: 'apply_job#confirm', as: :confirm
get 'save', to: 'apply_job#save', as: :save
# Details job
get 'detail/:id', to: 'job#detail', as: :detail_job
# Search
......
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