Commit 9dc4433d by Tan Phat Nguyen

Add feature navigation on head

parent 434e224e
...@@ -27,6 +27,7 @@ gem 'capistrano3-unicorn' ...@@ -27,6 +27,7 @@ gem 'capistrano3-unicorn'
gem 'capistrano-rails' gem 'capistrano-rails'
gem 'capistrano-bundler', '>= 1.1.0' gem 'capistrano-bundler', '>= 1.1.0'
gem 'capistrano-rvm' gem 'capistrano-rvm'
gem 'breadcrumbs_on_rails'
group :development, :test do group :development, :test do
gem 'sqlite3', '1.3.9' gem 'sqlite3', '1.3.9'
......
...@@ -44,6 +44,7 @@ GEM ...@@ -44,6 +44,7 @@ GEM
debug_inspector (>= 0.0.1) debug_inspector (>= 0.0.1)
bootstrap-sass (3.2.0.0) bootstrap-sass (3.2.0.0)
sass (~> 3.2) sass (~> 3.2)
breadcrumbs_on_rails (2.3.0)
builder (3.2.2) builder (3.2.2)
byebug (3.4.0) byebug (3.4.0)
columnize (~> 0.8) columnize (~> 0.8)
...@@ -309,6 +310,7 @@ DEPENDENCIES ...@@ -309,6 +310,7 @@ DEPENDENCIES
arel (= 6.0.0.beta2) arel (= 6.0.0.beta2)
bcrypt (= 3.1.7) bcrypt (= 3.1.7)
bootstrap-sass (= 3.2.0.0) bootstrap-sass (= 3.2.0.0)
breadcrumbs_on_rails
byebug (= 3.4.0) byebug (= 3.4.0)
capistrano (~> 3.2.0) capistrano (~> 3.2.0)
capistrano-bundler (>= 1.1.0) capistrano-bundler (>= 1.1.0)
......
...@@ -2,15 +2,22 @@ class Admin::ProductsController < ApplicationController ...@@ -2,15 +2,22 @@ class Admin::ProductsController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_product, only: [:show, :edit, :update, :destroy] before_action :set_product, only: [:show, :edit, :update, :destroy]
add_breadcrumb 'Home', :root_path, title: 'Home'
def index def index
add_breadcrumb 'List of Products'
@products = Product.all.page(params[:page]) @products = Product.all.page(params[:page])
end end
def new def new
add_breadcrumb 'List of Products', :admin_products_path
add_breadcrumb 'New Product'
@product = Product.new @product = Product.new
end end
def create def create
add_breadcrumb 'List of Products', :admin_products_path
add_breadcrumb 'New Product'
@product = Product.new(product_params) @product = Product.new(product_params)
if @product.save if @product.save
...@@ -21,12 +28,18 @@ class Admin::ProductsController < ApplicationController ...@@ -21,12 +28,18 @@ class Admin::ProductsController < ApplicationController
end end
def show def show
add_breadcrumb 'List of Products', :admin_products_path
add_breadcrumb @product.name
end end
def edit def edit
add_breadcrumb 'List of Products', :admin_products_path
add_breadcrumb 'Update Product'
end end
def update def update
add_breadcrumb 'List of Products', :admin_products_path
add_breadcrumb 'Update Product'
if @product.update_attributes(product_params) if @product.update_attributes(product_params)
redirect_to [:admin, @product] redirect_to [:admin, @product]
else else
......
class CartsController < ApplicationController class CartsController < ApplicationController
add_breadcrumb 'Home', :root_path, title: 'Home'
def show def show
add_breadcrumb 'Cart', current_cart
flash.now[:warning] = 'Cart is empty.' unless current_cart.line_items.any? flash.now[:warning] = 'Cart is empty.' unless current_cart.line_items.any?
end end
......
class CategoriesController < ApplicationController class CategoriesController < ApplicationController
add_breadcrumb 'Home', :root_path, title: 'Home'
def show def show
@category = Category.find(params[:id]) @category = Category.find(params[:id])
add_breadcrumb "Category #{@category.name}", @category
@products = @category.products.page(params[:page]) @products = @category.products.page(params[:page])
end end
end end
class HomeController < ApplicationController class HomeController < ApplicationController
add_breadcrumb 'Home', :root_path, title: 'Home'
def index def index
@categories = Category.all @categories = Category.all
......
...@@ -2,24 +2,35 @@ class OrdersController < ApplicationController ...@@ -2,24 +2,35 @@ class OrdersController < ApplicationController
before_action :authenticate_user!, only: [:show, :edit, :update, :destroy, :index] before_action :authenticate_user!, only: [:show, :edit, :update, :destroy, :index]
before_action :set_order, only: [:show, :edit, :update, :destroy] before_action :set_order, only: [:show, :edit, :update, :destroy]
add_breadcrumb 'Home', :root_path, title: 'Home'
def index def index
add_breadcrumb 'List of Orders'
@orders = current_user.orders.page(params[:page]) @orders = current_user.orders.page(params[:page])
flash.now[:warning] = 'You have not order item yet.' unless @orders.any? flash.now[:warning] = 'You have not order item yet.' unless @orders.any?
end end
def show def show
add_breadcrumb 'List of Orders', :orders_path
add_breadcrumb 'Order Detail'
end end
def new def new
add_breadcrumb 'Cart', current_cart
add_breadcrumb 'Checkout'
redirect_to root_path if current_cart.line_items.empty? redirect_to root_path if current_cart.line_items.empty?
@order = Order.new @order = Order.new
end end
def edit def edit
add_breadcrumb 'List of Orders', :orders_path
add_breadcrumb 'Update Order'
end end
def create def create
add_breadcrumb 'Cart', current_cart
add_breadcrumb 'Checkout'
@order = Order.new(order_params) @order = Order.new(order_params)
@order.add_line_items_from_cart(current_cart) @order.add_line_items_from_cart(current_cart)
if @order.save if @order.save
...@@ -34,6 +45,8 @@ class OrdersController < ApplicationController ...@@ -34,6 +45,8 @@ class OrdersController < ApplicationController
end end
def update def update
add_breadcrumb 'List of Orders', :orders_path
add_breadcrumb 'Update Order'
if @order.update(order_params) if @order.update(order_params)
flash[:success] = 'Order was successfully updated.' flash[:success] = 'Order was successfully updated.'
redirect_to @order redirect_to @order
......
class ProductsController < ApplicationController class ProductsController < ApplicationController
add_breadcrumb 'Home', :root_path, title: 'Home'
def show def show
@product = Product.find(params[:id]) @product = Product.find(params[:id])
add_breadcrumb "Category #{@product.category.name}", @product.category
add_breadcrumb "#{@product.name}", @product
end end
def index def index
add_breadcrumb 'Search Results'
search_products = Searcher.find_products_by(search: params[:search], page: params[:page]) search_products = Searcher.find_products_by(search: params[:search], page: params[:page])
@products = search_products['docs'] @products = search_products['docs']
@products_paging = Kaminari.paginate_array(search_products['docs'], total_count: search_products['numFound']).page(params[:page]).per(Rails.configuration.paginates_per) @products_paging = Kaminari.paginate_array(search_products['docs'], total_count: search_products['numFound']).page(params[:page]).per(Rails.configuration.paginates_per)
......
<% provide(:title, 'Forgot password') %> <% provide(:title, 'Forgot password') %>
<% add_breadcrumb 'Home', :root_path, title: 'Home'
add_breadcrumb 'Log in', :new_user_session_path
add_breadcrumb 'Forgot your password?' %>
<h1 class='page-header'>Forgot your password?</h1> <h1 class='page-header'>Forgot your password?</h1>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
......
<% provide(:title, 'Edit user') %> <% provide(:title, 'Edit user') %>
<% add_breadcrumb 'Home', :root_path, title: 'Home'
add_breadcrumb 'Edit user' %>
<h1 class='page-header'>Edit <%= resource_name.to_s.humanize %></h1> <h1 class='page-header'>Edit <%= resource_name.to_s.humanize %></h1>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
......
<% provide(:title, 'Sign up') %> <% provide(:title, 'Sign up') %>
<% add_breadcrumb 'Home', :root_path, title: 'Home'
add_breadcrumb 'Sign up' %>
<h1 class='page-header'>Sign up</h1> <h1 class='page-header'>Sign up</h1>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
......
<% provide(:title, 'Log in') %> <% provide(:title, 'Log in') %>
<% add_breadcrumb 'Home', :root_path, title: 'Home'
add_breadcrumb 'Log in' %>
<h1 class='page-header'>Log in</h1> <h1 class='page-header'>Log in</h1>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
</ul> </ul>
</div> </div>
<div class='col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main'> <div class='col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main'>
<ol class="breadcrumb">
<%= render_breadcrumbs :tag => :li, :separator => "" %>
</ol>
<%= render 'errors' %> <%= render 'errors' %>
<%= yield %> <%= yield %>
</div> </div>
......
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