Commit b36f3848 by thanhnd

Merge branch 'job_list_page' into 'master'

Job list page

See merge request !4
parents c94c18ed 3d8e59dc
Pipeline #513 failed with stages
in 0 seconds
...@@ -59,3 +59,10 @@ end ...@@ -59,3 +59,10 @@ end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
#mysql2 #mysql2
gem 'mysql2' gem 'mysql2'
#paginator
gem 'kaminari'
gem 'kaminari-bootstrap'
#setting file yml
gem 'settingslogic'
...@@ -93,6 +93,21 @@ GEM ...@@ -93,6 +93,21 @@ GEM
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
kaminari (1.2.0)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.0)
kaminari-activerecord (= 1.2.0)
kaminari-core (= 1.2.0)
kaminari-actionview (1.2.0)
actionview
kaminari-core (= 1.2.0)
kaminari-activerecord (1.2.0)
activerecord
kaminari-core (= 1.2.0)
kaminari-bootstrap (3.0.1)
kaminari (>= 0.13.0)
rails
kaminari-core (1.2.0)
listen (3.1.5) listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
...@@ -169,6 +184,7 @@ GEM ...@@ -169,6 +184,7 @@ GEM
selenium-webdriver (3.142.7) selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0) childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2) rubyzip (>= 1.2.2)
settingslogic (2.0.9)
spring (2.1.0) spring (2.1.0)
spring-watcher-listen (2.0.1) spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0) listen (>= 2.7, < 4.0)
...@@ -219,12 +235,15 @@ DEPENDENCIES ...@@ -219,12 +235,15 @@ DEPENDENCIES
capybara (>= 2.15) capybara (>= 2.15)
jbuilder (~> 2.7) jbuilder (~> 2.7)
jquery-rails jquery-rails
kaminari
kaminari-bootstrap
listen (>= 3.0.5, < 3.2) listen (>= 3.0.5, < 3.2)
mysql2 mysql2
puma (~> 4.1) puma (~> 4.1)
rails (~> 6.0.2, >= 6.0.2.1) rails (~> 6.0.2, >= 6.0.2.1)
sass-rails (>= 6) sass-rails (>= 6)
selenium-webdriver selenium-webdriver
settingslogic
spring spring
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)
sprockets (~> 3.7.2) sprockets (~> 3.7.2)
......
...@@ -33,6 +33,16 @@ body { ...@@ -33,6 +33,16 @@ body {
padding: 10px; padding: 10px;
} }
.total_job {
color: red;
text-transform: uppercase;
text-align: left;
margin: auto;
width: 100%;
padding: 10px;
float: left;
}
.form-inline { .form-inline {
color: red; color: red;
text-transform: uppercase; text-transform: uppercase;
...@@ -119,4 +129,7 @@ ul.breadcrumb li a:hover { ...@@ -119,4 +129,7 @@ ul.breadcrumb li a:hover {
} }
.button1 {border-radius: 4px;} .button1 {border-radius: 4px;}
.button2 {border-radius: 4px;} .button2 {
float: right;
border-radius: 4px;
}
class JobsController < ApplicationController class JobsController < ApplicationController
def show def show
@job_detail = Job.find(params[:id]) @job_detail = Job.find_by_id(params[:id])
end
def index
@job_count = Job.count
pagin = params[:page].to_i > 0 ? params[:page].to_i : 1
@pagin_job = Job.page(pagin).per(Settings.page)
end
def search
return redirect_to root_path, alert: "Empty field!" if params[:search].blank?
@search_job = Job.includes(:city).where("job_name LIKE ?","%#{params[:search]}%")
@pagin_job = @search_job.page(params[:page]).per(Settings.page)
end end
end end
class Settings < Settingslogic
source "#{Rails.root}/config/setting.yml"
namespace Rails.env
end
<font color="red"><b><label > Job List:</label></b></font>
<%= paginate @pagin_job %>
<% @pagin_job.each do |job| %>
<ul>
<button class="button button2">Favorites</button>
<li><%= job.job_name %></li>
<li><%= job.city.city_name %></li>
<li ><span class="text"><%= job.description %></span></li>
</ul>
<% end %>
<%= paginate @pagin_job %>
<div id="search" class="container p-5 my-2 bg-secondary text-white">
<%= form_tag job_search_path, method: :get do %>
<p>
<%= text_field_tag :search, params[:search] %>
<%= button_tag "Search", name: nil %>
</p>
<% end %>
</div>
<div id="job_list" class="container p-5 my-2 bg-secondary text-white">
<div class="total_job">
<label> Total Jobs: <%= Job.count %></label>
</div>
<%= render partial: "jobs"%>
</div>
<div id="search" class="container p-5 my-2 bg-secondary text-white">
<%= form_tag job_search_path, method: :get do %>
<p>
<%= text_field_tag :search, params[:search] %>
<%= button_tag "Search", name: nil %>
</p>
<% end %>
</div>
<div id="job_list" class="container p-5 my-2 bg-secondary text-white">
<%= render partial: "jobs" %>
</div>
...@@ -9,6 +9,11 @@ ...@@ -9,6 +9,11 @@
</div> </div>
<div id="job_detail"class="container p-5 my-2 bg-secondary text-white"> <div id="job_detail"class="container p-5 my-2 bg-secondary text-white">
<% if @job_detail.nil? == true %>
<div> This id is not available. </div>
<% else %>
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><a href="#">Top</a></li> <li><a href="#">Top</a></li>
<li><a href="#">City</a></li> <li><a href="#">City</a></li>
...@@ -16,7 +21,6 @@ ...@@ -16,7 +21,6 @@
<li><%= @job_detail.job_name %></li> <li><%= @job_detail.job_name %></li>
</ul> </ul>
<font color="red"><b><label > Job Detail:</label></b></font> <font color="red"><b><label > Job Detail:</label></b></font>
<ul> <ul>
<li><%= @job_detail.job_name %></li> <li><%= @job_detail.job_name %></li>
...@@ -26,10 +30,9 @@ ...@@ -26,10 +30,9 @@
<li ><span class="text"><%= @job_detail.description %></span> <li ><span class="text"><%= @job_detail.description %></span>
</li> </li>
</ul> </ul>
<button class="button button1">Apply</button> <button class="button button1">Apply</button>
<button class="button button2">Favorites</button> <button class="button button2">Favorites</button>
<% end %>
</div> </div>
......
<li class="page-item">
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote, class: 'page-link' %>
</li>
<li>
<%= t('views.pagination.truncate').html_safe %>
</li>
<li class='page-item disabled'>
<%= link_to raw(t 'views.pagination.truncate'), '#', class: 'page-link' %>
</li>
<li class="page-item">
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, remote: remote, class: 'page-link' %>
</li>
<li class="page-next">
<%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote %>
</li>
\ No newline at end of file
<li class="page-item">
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote, class: 'page-link' %>
</li>
<li class="page<%= 'current' if page.current? %>">
<% if page.current? %>
<%= link_to page, "#" %>
<% else %>
<%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.rel} %>
<% end %>
</li>
<% if page.current? %>
<li class="page-item active">
<%= content_tag :a, page, data: { remote: remote }, rel: page.rel, class: 'page-link' %>
</li>
<% else %>
<li class="page-item">
<%= link_to page, url, remote: remote, rel: page.rel, class: 'page-link' %>
</li>
<% end %>
<%= paginator.render do %>
<div class="pagination">
<ul>
<%= prev_page_tag unless current_page.first? %>
<li>
<ul>
<% each_page do |page| %>
<% if page.left_outer? || page.right_outer? || page.inside_window? %>
<%= page_tag page %>
<% elsif !page.was_truncated? %>
<%= gap_tag %>
<% end %>
<% end %>
</ul>
</li>
<%= next_page_tag unless current_page.last? %>
</ul>
</div>
<% end %>
\ No newline at end of file
<%= paginator.render do %>
<nav>
<ul class="pagination">
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| %>
<% if page.left_outer? || page.right_outer? || page.inside_window? %>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end %>
<% end %>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
</ul>
</nav>
<% end %>
<li class="page-prev">
<%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote %>
</li>
\ No newline at end of file
<li class="page-item">
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote, class: 'page-link' %>
</li>
...@@ -5,11 +5,12 @@ ...@@ -5,11 +5,12 @@
</div> </div>
<div id="search" class="container p-5 my-2 bg-secondary text-white"> <div id="search" class="container p-5 my-2 bg-secondary text-white">
<!-- Search form --> <%= form_tag job_search_path, method: :get do %>
<form class="form-inline md-form mr-auto mb-4"> <p>
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search"> <%= text_field_tag :search, params[:search] %>
<button class="btn btn-outline-warning btn-rounded btn-sm my-0" type="submit">Search</button> <%= button_tag "Search", name: nil %>
</form> </p>
<% end %>
</div> </div>
......
...@@ -2,3 +2,5 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) ...@@ -2,3 +2,5 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile. require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations. require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
require 'yaml'
#YAML::ENGINE.yamler= 'syck'
# frozen_string_literal: true
Kaminari.configure do |config|
# config.default_per_page = 20
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
# config.max_pages = nil
# config.params_on_first_page = false
end
Rails.application.routes.draw do Rails.application.routes.draw do
get '/detail/:id', to: 'jobs#show' get 'detail/:id', to: 'jobs#show'
get 'jobs', to: 'jobs#index'
get 'jobs/search' => 'jobs#search', as: :job_search
root 'top_page#index' root 'top_page#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :top_page resources :top_page
end resources :jobs, :only => [:show, :index]
end
defaults: &defaults
development:
<<: *defaults
page: 5
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