many changes

This commit is contained in:
2012-12-03 18:39:36 +01:00
parent e3dc6a7c68
commit 7d64ab2022
37 changed files with 540 additions and 101 deletions
@@ -4,7 +4,7 @@ module Suppliers
# GET /product_categories
# GET /product_categories.json
def index
@product_categories = current_supplier.product_categories
@product_categories = current_supplier.product_categories.sort_by(&:position)
respond_to do |format|
format.html # index.html.erb
@@ -83,5 +83,14 @@ module Suppliers
format.json { head :no_content }
end
end
# POST /supplier/product_categories/sort
# params ~= product_category: ['abc', 'def', 'another id', ...]
def sort
@product_categories = ProductCategory.find(params[:product_category])
1.upto(@product_categories.size){|i| @product_categories[i-1].position = i}
CouchPotato.database.couchrest_database.bulk_save(@product_categories)
render nothing: true
end
end
end
@@ -4,7 +4,7 @@ module Suppliers
# GET /products
# GET /products.json
def index
@products = current_supplier.products
@products = ProductDecorator.decorate(current_supplier.products)
respond_to do |format|
format.html # index.html.erb
@@ -15,7 +15,7 @@ module Suppliers
# GET /products/1
# GET /products/1.json
def show
@product = Product.find(params[:id])
@product = ProductDecorator.find(params[:id])
respond_to do |format|
format.html # show.html.erb
@@ -27,7 +27,6 @@ module Suppliers
# GET /products/new.json
def new
@product = Product.new
@product.product_category_id = params[:product_category_id].presence
respond_to do |format|
format.html # new.html.erb