Commit a3e9d1b3 by Ngô Trung Hưng

add loading page

parent 423eef1a
Pipeline #916 failed with stages
in 0 seconds
...@@ -15,3 +15,6 @@ ...@@ -15,3 +15,6 @@
//= require turbolinks //= require turbolinks
//= require jquery.min //= require jquery.min
//= require_tree . //= require_tree .
toastr.options = {
'closeButton': true
}
...@@ -38,4 +38,12 @@ $(document).on("turbolinks:load", function(){ ...@@ -38,4 +38,12 @@ $(document).on("turbolinks:load", function(){
$("input[type=file]").on('change',function(){ $("input[type=file]").on('change',function(){
document.getElementById ("label_name_file").innerHTML = this.files[0].name; 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 @@ ...@@ -2,28 +2,38 @@
class ApplyJobController < ApplicationController class ApplyJobController < ApplicationController
before_action :authenticate_user!, only: :apply before_action :authenticate_user!, only: :apply
def apply
@data_apply = AppliedJob.new def apply
redirect_to root_path if params[:job_id].blank?
@data_apply = AppliedJob.new
session[:job_id] = params[:job_id] session[:job_id] = params[:job_id]
end end
def confirmation def catch_data(applied_job_params)
@data_apply = AppliedJob.new(applied_job_params) @apply_job = AppliedJob.new(applied_job_params)
if @data_apply.save if @apply_job.cv.blank?
session[:user_name] = @data_apply.name if current_user.cv.present?
session[:user_email] = @data_apply.email @apply_job.cv = current_user.cv
redirect_to show_path render :confirm
else else
flash[:error] = 'error' flash[:error] = t('pages.mypage.nofile')
render 'apply' redirect_to apply_path(job_id: session[:job_id])
session.delete(:job_id)
end
end end
@apply_job
end
def confirm
@apply_job ||= catch_data(applied_job_params)
end end
def show def show
end end
def save def save
@data_apply.save debugger
confirm.save
end end
private private
......
...@@ -10,6 +10,7 @@ module ApplicationHelper ...@@ -10,6 +10,7 @@ module ApplicationHelper
def custom_bootstrap_flash def custom_bootstrap_flash
flash_messages = [] flash_messages = []
flash.each do |type, message| flash.each do |type, message|
next if message.blank?
type = 'success' if type == 'notice' type = 'success' if type == 'notice'
type = 'error' if type == 'alert' type = 'error' if type == 'alert'
text = "<script>toastr.#{type}('#{message}');</script>" text = "<script>toastr.#{type}('#{message}');</script>"
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
# Description/Explanation of Person class # Description/Explanation of Person class
class AppliedJob < ApplicationRecord class AppliedJob < ApplicationRecord
mount_uploader :cv, CvUploader mount_uploader :cv, CvUploader
validates_integrity_of :cv
belongs_to :user belongs_to :user
belongs_to :job belongs_to :job
validates :name, :email, :cv, presence: true
validates :name, :email, length: {in: 8..200}
validates :email, format: Devise.email_regexp
end end
<%= form_with(model: data_apply, url: confirm_path) do |f| %> <%= form_with(model: data_apply, url: confirm_path, local: true) do |f| %>
<br> <br>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
<%= f.label :name, t('pages.mypage.name') %> <%= f.label :name, t('pages.mypage.name') %>
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
<%= f.text_field(:name, class:'form-control') %> <%= f.text_field(:name, autofocus: true, autocomplete: 'name', class:'form-control') %>
<%= f.hidden_field(:job_id, value: session[:job_id]) %> <%= f.hidden_field(:job_id, value: params[:job_id]) %>
<%= f.hidden_field(:user_id, value: current_user.id) %>
</div> </div>
</div><br> </div><br>
<div class="row"> <div class="row">
...@@ -17,7 +18,7 @@ ...@@ -17,7 +18,7 @@
<%= f.label :email%> <%= f.label :email%>
</div> </div>
<div class="col-lg-6"> <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>
</div><br> </div><br>
<div class="row"> <div class="row">
...@@ -26,8 +27,8 @@ ...@@ -26,8 +27,8 @@
<span><%= t('pages.mypage.cv') %></span> <span><%= t('pages.mypage.cv') %></span>
</div> </div>
<div class="col-lg-5 col-md-12"> <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.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.file_field :cv, accept: '.pdf', class: 'pppp hidden' %>
</div> </div>
<div class="col-lg-1"> <div class="col-lg-1">
<%= f.label :cv, '<i class="fas fa-cloud-upload-alt"></i>'.html_safe, title: 'upload', class: 'lable_custom' %> <%= f.label :cv, '<i class="fas fa-cloud-upload-alt"></i>'.html_safe, title: 'upload', class: 'lable_custom' %>
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
<div class="box_job_apply"> <div class="box_job_apply">
<div class="ribbon"> <div class="ribbon">
<div class="row"> <div class="row">
<div class="col-lg-4 col-md-4"> <div class="col-lg-4 col-md-12">
<div class="ribbon_item active"> <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> </div>
<div class="col-lg-4 col-md-4"> <div class="col-lg-4 col-md-12">
<div class="ribbon_item active"> <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> </div>
<div class="col-lg-4 col-md-4"> <div class="col-lg-4 col-md-12">
<div class="ribbon_item"> <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> </div>
</div> </div>
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
Họ và tên: Họ và tên:
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
<%= session[:user_name] %> <%= @apply_job.name %>
</div> </div>
</div><br> </div><br>
<div class="row"> <div class="row">
...@@ -39,13 +39,22 @@ ...@@ -39,13 +39,22 @@
Email: Email:
</div> </div>
<div class="col-lg-6"> <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> </div>
</div> </div>
<%= link_to 'save', save_path %> <%= link_to 'save', save_path %>
<%= link_to 'back', edit_path(job_id: session[:job_id]) %> <%= link_to t('devise.back'), :back %>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<%= f.label :cv, t('pages.mypage.cv') %> <%= f.label :cv, t('pages.mypage.cv') %>
</div> </div>
<div class="col-md-9"> <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> <i style="font-size: 15px; color: #666">Current file: <%= current_user.cv.identifier %></i>
</div> </div>
</div><br> </div><br>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<%= f.label :cv, t('pages.mypage.cv') %> <%= f.label :cv, t('pages.mypage.cv') %>
</div> </div>
<div class="col-md-9"> <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>
</div><br> </div><br>
<div class="row"> <div class="row">
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<%= render 'layouts/padding' %> <%= render 'layouts/padding' %>
<%= yield %> <%= yield %>
<%= render 'layouts/footer' %> <%= render 'layouts/footer' %>
<%= render 'shared/loading' %>
</div> </div>
</body> </body>
</html> </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 ...@@ -22,7 +22,7 @@ Rails.application.configure do
config.eager_load = false config.eager_load = false
# Show full error reports. # Show full error reports.
config.consider_all_requests_local = false config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching. # Run rails dev:cache to toggle caching.
......
...@@ -10,8 +10,8 @@ Rails.application.routes.draw do ...@@ -10,8 +10,8 @@ Rails.application.routes.draw do
get 'industries', to: 'industry#index', as: :industry_index get 'industries', to: 'industry#index', as: :industry_index
get 'cities', to: 'city#index', as: :city_index get 'cities', to: 'city#index', as: :city_index
get 'apply', to: 'apply_job#apply', as: :apply get 'apply', to: 'apply_job#apply', as: :apply
post 'confrim', to: 'apply_job#confirmation', as: :confirm post 'confirm', to: 'apply_job#confirm', as: :confirm
get 'confrim', to: 'apply_job#show', as: :show get 'save', to: 'apply_job#save', as: :save
# Details job # Details job
get 'detail/:id', to: 'job#detail', as: :detail_job get 'detail/:id', to: 'job#detail', as: :detail_job
# Search # 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