Commit 9dc4433d by Tan Phat Nguyen

Add feature navigation on head

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