radiant-shop-extension 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -1
- data/VERSION +1 -1
- data/app/controllers/admin/shop/categories_controller.rb +32 -65
- data/app/controllers/admin/shop/customers_controller.rb +8 -7
- data/app/controllers/admin/shop/orders_controller.rb +37 -159
- data/app/controllers/admin/shop/packages/packings_controller.rb +90 -0
- data/app/controllers/admin/shop/packages_controller.rb +65 -0
- data/app/controllers/admin/shop/products/images_controller.rb +5 -8
- data/app/controllers/admin/shop/products/variant_templates_controller.rb +27 -0
- data/app/controllers/admin/shop/products/variants_controller.rb +60 -0
- data/app/controllers/admin/shop/products_controller.rb +67 -64
- data/app/controllers/admin/shop/variants_controller.rb +49 -0
- data/app/helpers/shop_helper.rb +5 -0
- data/app/models/form_address.rb +144 -0
- data/app/models/form_checkout.rb +200 -307
- data/app/models/form_line_item.rb +60 -0
- data/app/models/shop_address.rb +2 -2
- data/app/models/shop_category.rb +48 -51
- data/app/models/shop_customer.rb +25 -5
- data/app/models/shop_group.rb +15 -0
- data/app/models/shop_grouping.rb +6 -0
- data/app/models/shop_line_item.rb +7 -6
- data/app/models/shop_order.rb +44 -16
- data/app/models/shop_package.rb +74 -0
- data/app/models/shop_packing.rb +22 -0
- data/app/models/shop_page.rb +7 -0
- data/app/models/shop_payment.rb +5 -1
- data/app/models/shop_product.rb +86 -48
- data/app/models/shop_product_attachment.rb +5 -2
- data/app/models/shop_product_variant.rb +31 -0
- data/app/models/shop_variant.rb +25 -0
- data/app/views/admin/shop/categories/edit.html.haml +9 -10
- data/app/views/admin/shop/categories/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/categories/edit/_form.html.haml +14 -0
- data/app/views/admin/shop/categories/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/categories/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/categories/edit/_meta.html.haml +8 -7
- data/app/views/admin/shop/categories/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/categories/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/categories/edit/inputs/_name.html.haml +4 -0
- data/app/views/admin/shop/categories/edit/meta/_handle.html.haml +6 -5
- data/app/views/admin/shop/categories/edit/meta/_layouts.html.haml +6 -5
- data/app/views/admin/shop/categories/edit/meta/_page.html.haml +3 -0
- data/app/views/admin/shop/categories/edit/parts/_description.html.haml +4 -1
- data/app/views/admin/shop/categories/index/_category.html.haml +11 -10
- data/app/views/admin/shop/categories/new.html.haml +10 -9
- data/app/views/admin/shop/customers/edit.html.haml +8 -10
- data/app/views/admin/shop/customers/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/customers/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/customers/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/customers/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/customers/edit/_parts.html.haml +9 -4
- data/app/views/admin/shop/customers/edit/inputs/_email.html.haml +3 -0
- data/app/views/admin/shop/customers/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/customers/edit/parts/_orders.html.haml +10 -6
- data/app/views/admin/shop/customers/index.html.haml +4 -1
- data/app/views/admin/shop/customers/index/_customer.html.haml +3 -3
- data/app/views/admin/shop/customers/index/_foot.html.haml +4 -0
- data/app/views/admin/shop/customers/index/_head.html.haml +4 -0
- data/app/views/admin/shop/customers/new.html.haml +9 -9
- data/app/views/admin/shop/orders/edit.html.haml +11 -0
- data/app/views/admin/shop/orders/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/orders/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/orders/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/orders/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/orders/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/orders/edit/parts/_address.html.haml +7 -0
- data/app/views/admin/shop/orders/edit/parts/_addresses.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/parts/_customer.html.haml +3 -0
- data/app/views/admin/shop/orders/edit/parts/_items.html.haml +8 -0
- data/app/views/admin/shop/orders/index.html.haml +10 -30
- data/app/views/admin/shop/orders/index/_foot.html.haml +3 -0
- data/app/views/admin/shop/orders/index/_head.html.haml +4 -0
- data/app/views/admin/shop/orders/index/_order.html.haml +13 -0
- data/app/views/admin/shop/orders/index/buttons/_all.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_new.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_paid.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_shipped.html.haml +1 -0
- data/app/views/admin/shop/packages/edit.html.haml +11 -0
- data/app/views/admin/shop/packages/edit/_foot.html.haml +17 -0
- data/app/views/admin/shop/packages/edit/_form.html.haml +15 -0
- data/app/views/admin/shop/packages/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/packages/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/packages/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/packages/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/packages/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +1 -0
- data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +5 -0
- data/app/views/admin/shop/packages/edit/parts/_description.html.haml +1 -0
- data/app/views/admin/shop/packages/edit/parts/_products.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +7 -0
- data/app/views/admin/shop/packages/edit/shared/_product.html.haml +8 -0
- data/app/views/admin/shop/packages/index.html.haml +13 -0
- data/app/views/admin/shop/packages/index/_foot.html.haml +7 -0
- data/app/views/admin/shop/packages/index/_head.html.haml +4 -0
- data/app/views/admin/shop/packages/index/_package.html.haml +9 -0
- data/app/views/admin/shop/packages/new.html.haml +11 -0
- data/app/views/admin/shop/packages/remove.html.haml +12 -0
- data/app/views/admin/shop/products/edit.html.haml +9 -12
- data/app/views/admin/shop/products/edit/_foot.html.haml +19 -0
- data/app/views/admin/shop/products/edit/_form.html.haml +15 -0
- data/app/views/admin/shop/products/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/products/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/products/edit/_meta.html.haml +8 -8
- data/app/views/admin/shop/products/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/products/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/products/edit/buttons/_browse_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +1 -0
- data/app/views/admin/shop/products/edit/buttons/_new_image.html.haml +1 -1
- data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +1 -0
- data/app/views/admin/shop/products/edit/inputs/_name.html.haml +4 -0
- data/app/views/admin/shop/products/edit/inputs/_price.html.haml +3 -0
- data/app/views/admin/shop/products/edit/meta/_category.html.haml +6 -5
- data/app/views/admin/shop/products/edit/meta/_page.html.haml +2 -0
- data/app/views/admin/shop/products/edit/meta/_sku.html.haml +6 -5
- data/app/views/admin/shop/products/edit/parts/_customers.html.haml +5 -0
- data/app/views/admin/shop/products/edit/parts/_description.html.haml +4 -1
- data/app/views/admin/shop/products/edit/parts/_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/parts/_variants.html.haml +3 -0
- data/app/views/admin/shop/products/edit/popups/_browse_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +6 -0
- data/app/views/admin/shop/products/edit/popups/_new_image.html.haml +4 -4
- data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +16 -0
- data/app/views/admin/shop/products/edit/{_image.html.haml → shared/_image.html.haml} +0 -0
- data/app/views/admin/shop/products/edit/shared/_template.html.haml +6 -0
- data/app/views/admin/shop/products/edit/shared/_variant.html.haml +10 -0
- data/app/views/admin/shop/products/index.html.haml +6 -3
- data/app/views/admin/shop/products/index/_foot.html.haml +10 -0
- data/app/views/admin/shop/products/index/_head.html.haml +4 -0
- data/app/views/admin/shop/products/index/_product.html.haml +18 -10
- data/app/views/admin/shop/products/index/buttons/_discounts.html.haml +1 -0
- data/app/views/admin/shop/products/index/buttons/_packages.html.haml +1 -0
- data/app/views/admin/shop/products/index/buttons/_variants.html.haml +1 -0
- data/app/views/admin/shop/products/new.html.haml +10 -9
- data/app/views/admin/shop/variants/edit.html.haml +11 -0
- data/app/views/admin/shop/variants/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/variants/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/variants/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/variants/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/variants/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/variants/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/variants/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/variants/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/variants/edit/inputs/_options.html.haml +3 -0
- data/app/views/admin/shop/variants/index.html.haml +13 -0
- data/app/views/admin/shop/variants/index/_foot.html.haml +4 -0
- data/app/views/admin/shop/variants/index/_head.html.haml +4 -0
- data/app/views/admin/shop/variants/index/_variant.html.haml +9 -0
- data/app/views/admin/shop/variants/new.html.haml +11 -0
- data/app/views/admin/shop/variants/remove.html.haml +12 -0
- data/config/locales/en.yml +8 -1
- data/config/routes.rb +11 -22
- data/db/migrate/20100929011106_fix_relationship_foreign_keys.rb +101 -0
- data/db/migrate/20100929011607_drop_shop_addressables.rb +25 -0
- data/db/migrate/20100929030510_create_shop_groups.rb +19 -0
- data/db/migrate/20100929080301_shop_groups_change_add_description.rb +11 -0
- data/db/migrate/20100929081200_create_variants.rb +20 -0
- data/db/migrate/20100929143531_change_variants_add_updated_by.rb +25 -0
- data/db/migrate/20100929145641_change_created_by_to_id.rb +75 -0
- data/db/migrate/20100929235221_change_category_add_variant_id.rb +9 -0
- data/db/migrate/20100930235221_create_packages.rb +31 -0
- data/db/migrate/20101005231713_create_page_ids.rb +11 -0
- data/db/migrate/20101006051214_create_pages_for_products_and_categories.rb +73 -0
- data/db/migrate/20101007111845_add_default_position_to_attachment.rb +9 -0
- data/lib/shop/controllers/application_controller.rb +1 -1
- data/lib/shop/interface/categories.rb +29 -0
- data/lib/shop/interface/customers.rb +15 -15
- data/lib/shop/interface/orders.rb +34 -0
- data/lib/shop/interface/packages.rb +34 -0
- data/lib/shop/interface/products.rb +18 -31
- data/lib/shop/interface/variants.rb +34 -0
- data/lib/shop/models/form_extension.rb +23 -0
- data/lib/shop/models/page.rb +3 -2
- data/lib/shop/tags/address.rb +3 -3
- data/lib/shop/tags/cart.rb +12 -16
- data/lib/shop/tags/category.rb +4 -6
- data/lib/shop/tags/helpers.rb +131 -30
- data/lib/shop/tags/item.rb +16 -33
- data/lib/shop/tags/package.rb +95 -0
- data/lib/shop/tags/product.rb +11 -16
- data/lib/shop/tags/product_variant.rb +52 -0
- data/mockups/discounts/new-edit.bmml +492 -0
- data/public/javascripts/admin/extensions/shop/edit.js +20 -0
- data/public/javascripts/admin/extensions/shop/packages/edit.js +109 -0
- data/public/javascripts/admin/extensions/shop/products/edit.js +64 -65
- data/public/javascripts/admin/extensions/shop/products/index.js +31 -36
- data/public/stylesheets/sass/admin/extensions/shop/edit.sass +58 -11
- data/public/stylesheets/sass/admin/extensions/shop/index.sass +104 -53
- data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +162 -0
- data/public/stylesheets/sass/admin/extensions/shop/products/edit.sass +115 -36
- data/public/stylesheets/sass/admin/extensions/shop/products/index.sass +12 -20
- data/radiant-shop-extension.gemspec +182 -38
- data/shop_extension.rb +29 -25
- data/spec/controllers/admin/shop/categories_controller_spec.rb +76 -191
- data/spec/controllers/admin/shop/customers_controller_spec.rb +67 -0
- data/spec/controllers/admin/shop/orders_controller_spec.rb +85 -0
- data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +188 -0
- data/spec/controllers/admin/shop/packages_controller_spec.rb +32 -0
- data/spec/controllers/admin/shop/products/images_controller_spec.rb +10 -15
- data/spec/controllers/admin/shop/products/variant_templates_controller_spec.rb +53 -0
- data/spec/controllers/admin/shop/products/variants_controller_spec.rb +116 -0
- data/spec/controllers/admin/shop/products_controller_spec.rb +80 -148
- data/spec/controllers/admin/shop/variants_controller_spec.rb +67 -0
- data/spec/datasets/forms.rb +23 -8
- data/spec/datasets/shop_addresses.rb +1 -4
- data/spec/datasets/shop_categories.rb +25 -4
- data/spec/datasets/shop_groups.rb +15 -0
- data/spec/datasets/shop_line_items.rb +4 -3
- data/spec/datasets/shop_orders.rb +6 -15
- data/spec/datasets/shop_packages.rb +25 -0
- data/spec/datasets/shop_payments.rb +12 -0
- data/spec/datasets/{images.rb → shop_product_attachments.rb} +9 -1
- data/spec/datasets/shop_product_variants.rb +22 -0
- data/spec/datasets/shop_products.rb +28 -18
- data/spec/datasets/shop_variants.rb +17 -0
- data/spec/lib/shop/models/image_spec.rb +4 -4
- data/spec/lib/shop/tags/address_spec.rb +3 -3
- data/spec/lib/shop/tags/cart_spec.rb +32 -43
- data/spec/lib/shop/tags/category_spec.rb +58 -93
- data/spec/lib/shop/tags/helpers_spec.rb +162 -69
- data/spec/lib/shop/tags/item_spec.rb +116 -158
- data/spec/lib/shop/tags/package_spec.rb +342 -0
- data/spec/lib/shop/tags/product_spec.rb +29 -26
- data/spec/lib/shop/tags/product_variant_spec.rb +175 -0
- data/spec/models/form_address_spec.rb +166 -0
- data/spec/models/form_checkout_spec.rb +27 -157
- data/spec/models/shop_address_spec.rb +81 -0
- data/spec/models/shop_category_spec.rb +114 -31
- data/spec/models/shop_customer_spec.rb +105 -0
- data/spec/models/shop_group_spec.rb +38 -0
- data/spec/models/shop_line_item_spec.rb +5 -5
- data/spec/models/shop_order_spec.rb +89 -83
- data/spec/models/shop_package_spec.rb +117 -0
- data/spec/models/shop_packing_spec.rb +67 -0
- data/spec/models/shop_payment_spec.rb +19 -0
- data/spec/models/shop_product_attachment_spec.rb +4 -3
- data/spec/models/shop_product_spec.rb +171 -92
- data/spec/models/shop_product_variant_spec.rb +92 -0
- data/spec/models/shop_variant_spec.rb +47 -0
- metadata +183 -39
- data/app/controllers/shop/categories_controller.rb +0 -45
- data/app/controllers/shop/line_items_controller.rb +0 -165
- data/app/controllers/shop/orders_controller.rb +0 -16
- data/app/controllers/shop/products_controller.rb +0 -48
- data/app/models/shop_addressable.rb +0 -11
- data/app/views/admin/shop/categories/edit/_fields.html.haml +0 -28
- data/app/views/admin/shop/categories/edit/_part.html.haml +0 -3
- data/app/views/admin/shop/categories/edit/_popup.html.haml +0 -3
- data/app/views/admin/shop/customers/edit/_fields.html.haml +0 -33
- data/app/views/admin/shop/customers/index/_bottom.html.haml +0 -4
- data/app/views/admin/shop/products/edit/_fields.html.haml +0 -38
- data/app/views/admin/shop/products/edit/_part.html.haml +0 -3
- data/app/views/admin/shop/products/edit/_popup.html.haml +0 -3
- data/app/views/admin/shop/products/index/_bottom.html.haml +0 -5
- data/spec/controllers/shop/categories_controller_spec.rb +0 -42
- data/spec/controllers/shop/line_items_controller_spec.rb +0 -256
- data/spec/controllers/shop/orders_controller_specs.rb +0 -37
- data/spec/controllers/shop/products_controller_spec.rb +0 -51
- data/vendor/plugins/json_fields/.gitignore +0 -3
- data/vendor/plugins/json_fields/MIT-LICENSE +0 -20
- data/vendor/plugins/json_fields/README.rdoc +0 -65
- data/vendor/plugins/json_fields/Rakefile +0 -55
- data/vendor/plugins/json_fields/init.rb +0 -2
- data/vendor/plugins/json_fields/lib/json_fields.rb +0 -99
- data/vendor/plugins/json_fields/spec/lib/json_fields_spec.rb +0 -124
- data/vendor/plugins/json_fields/spec/spec.opts +0 -6
- data/vendor/plugins/json_fields/spec/spec_helper.rb +0 -29
- data/vendor/plugins/json_fields/spec/test_models.rb +0 -12
@@ -0,0 +1,65 @@
|
|
1
|
+
class Admin::Shop::PackagesController < Admin::ResourceController
|
2
|
+
model_class ShopPackage
|
3
|
+
|
4
|
+
helper :shop
|
5
|
+
|
6
|
+
before_filter :config_global
|
7
|
+
before_filter :config_index, :only => [ :index ]
|
8
|
+
before_filter :config_new, :only => [ :new, :create ]
|
9
|
+
before_filter :config_edit, :only => [ :edit, :update ]
|
10
|
+
before_filter :assets_global
|
11
|
+
before_filter :assets_index, :only => :index
|
12
|
+
before_filter :assets_edit, :only => [ :edit, :update ]
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def config_global
|
17
|
+
@inputs ||= []
|
18
|
+
@meta ||= []
|
19
|
+
@buttons ||= []
|
20
|
+
@parts ||= []
|
21
|
+
@popups ||= []
|
22
|
+
|
23
|
+
@inputs << 'name'
|
24
|
+
@inputs << 'price'
|
25
|
+
end
|
26
|
+
|
27
|
+
def config_index
|
28
|
+
@buttons << 'packages'
|
29
|
+
@buttons << 'variants'
|
30
|
+
@buttons << 'discounts'
|
31
|
+
end
|
32
|
+
|
33
|
+
def config_new
|
34
|
+
@meta << 'sku'
|
35
|
+
|
36
|
+
@parts << 'description'
|
37
|
+
end
|
38
|
+
|
39
|
+
def config_edit
|
40
|
+
@meta << 'sku'
|
41
|
+
|
42
|
+
@parts << 'description'
|
43
|
+
@parts << 'products'
|
44
|
+
|
45
|
+
@buttons << 'browse_products'
|
46
|
+
|
47
|
+
@popups << 'browse_products'
|
48
|
+
end
|
49
|
+
|
50
|
+
def assets_global
|
51
|
+
end
|
52
|
+
|
53
|
+
def assets_index
|
54
|
+
include_stylesheet 'admin/extensions/shop/index'
|
55
|
+
end
|
56
|
+
|
57
|
+
def assets_edit
|
58
|
+
include_javascript 'admin/dragdrop'
|
59
|
+
include_javascript 'admin/extensions/shop/edit'
|
60
|
+
include_stylesheet 'admin/extensions/shop/edit'
|
61
|
+
include_stylesheet 'admin/extensions/shop/packages/edit'
|
62
|
+
include_javascript 'admin/extensions/shop/packages/edit'
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -16,7 +16,7 @@ class Admin::Shop::Products::ImagesController < Admin::ResourceController
|
|
16
16
|
unless @shop_product_images.empty?
|
17
17
|
respond_to do |format|
|
18
18
|
format.html { redirect_to edit_admin_shop_product_path(@shop_product) }
|
19
|
-
format.js { render :partial => '/admin/shop/products/edit/image', :collection => @shop_product_images }
|
19
|
+
format.js { render :partial => '/admin/shop/products/edit/shared/image', :collection => @shop_product_images }
|
20
20
|
format.json { render :json => @shop_product_images.to_json(attr_hash) }
|
21
21
|
end
|
22
22
|
else
|
@@ -36,8 +36,8 @@ class Admin::Shop::Products::ImagesController < Admin::ResourceController
|
|
36
36
|
# PUT /admin/shop/products/1/images/sort.json AJAX and HTML
|
37
37
|
#----------------------------------------------------------------------------
|
38
38
|
def sort
|
39
|
-
error = 'Could not sort Images.'
|
40
39
|
notice = 'Successfully sorted Images.'
|
40
|
+
error = 'Could not sort Images.'
|
41
41
|
attr_hash = ShopProductAttachment.params
|
42
42
|
|
43
43
|
begin
|
@@ -50,10 +50,9 @@ class Admin::Shop::Products::ImagesController < Admin::ResourceController
|
|
50
50
|
|
51
51
|
respond_to do |format|
|
52
52
|
format.html {
|
53
|
-
flash[:notice] = notice
|
54
53
|
redirect_to edit_admin_shop_product_path(@shop_product)
|
55
54
|
}
|
56
|
-
format.js { render :partial => '/admin/shop/products/edit/image', :collection => @shop_product.images }
|
55
|
+
format.js { render :partial => '/admin/shop/products/edit/shared/image', :collection => @shop_product.images }
|
57
56
|
format.json { render :json => @shop_product.images.to_json(attr_hash) }
|
58
57
|
end
|
59
58
|
rescue
|
@@ -90,10 +89,9 @@ class Admin::Shop::Products::ImagesController < Admin::ResourceController
|
|
90
89
|
|
91
90
|
respond_to do |format|
|
92
91
|
format.html {
|
93
|
-
flash[:notice] = notice
|
94
92
|
redirect_to edit_admin_shop_product_path(@shop_product)
|
95
93
|
}
|
96
|
-
format.js { render :partial => '/admin/shop/products/edit/image', :locals => { :image => @shop_product_attachment } }
|
94
|
+
format.js { render :partial => '/admin/shop/products/edit/shared/image', :locals => { :image => @shop_product_attachment } }
|
97
95
|
format.json { render :json => @shop_product_attachment.to_json(attr_hash) }
|
98
96
|
end
|
99
97
|
rescue
|
@@ -123,10 +121,9 @@ class Admin::Shop::Products::ImagesController < Admin::ResourceController
|
|
123
121
|
|
124
122
|
respond_to do |format|
|
125
123
|
format.html {
|
126
|
-
flash[:notice] = notice
|
127
124
|
redirect_to edit_admin_shop_product_path(@shop_product)
|
128
125
|
}
|
129
|
-
format.js { render :partial => '/admin/shop/products/edit/image', :locals => { :excerpt => @image } }
|
126
|
+
format.js { render :partial => '/admin/shop/products/edit/shared/image', :locals => { :excerpt => @image } }
|
130
127
|
format.json { render :json => { :notice => notice }, :status => :ok }
|
131
128
|
end
|
132
129
|
rescue
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Admin::Shop::Products::VariantTemplatesController < Admin::ResourceController
|
2
|
+
|
3
|
+
model_class ShopVariant
|
4
|
+
|
5
|
+
def update
|
6
|
+
error = 'Could not attach all Variants to Product.'
|
7
|
+
|
8
|
+
@shop_product = ShopProduct.find(params[:product_id])
|
9
|
+
|
10
|
+
if @shop_product.apply_variant_template(@shop_variant)
|
11
|
+
respond_to do |format|
|
12
|
+
format.html {
|
13
|
+
redirect_to [ :edit_admin, @shop_product ]
|
14
|
+
}
|
15
|
+
end
|
16
|
+
else
|
17
|
+
respond_to do |format|
|
18
|
+
format.html {
|
19
|
+
flash[:error] = error
|
20
|
+
redirect_to [ :edit_admin, @shop_product ]
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class Admin::Shop::Products::VariantsController < Admin::ResourceController
|
2
|
+
|
3
|
+
model_class ShopProductVariant
|
4
|
+
|
5
|
+
before_filter :find_product
|
6
|
+
|
7
|
+
def create
|
8
|
+
notice = 'Successfully created variant.'
|
9
|
+
error = 'Could not create variant.'
|
10
|
+
|
11
|
+
begin
|
12
|
+
@shop_product_variant.attributes = params[:shop_product_variant]
|
13
|
+
@shop_product_variant.save!
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html {
|
17
|
+
redirect_to edit_admin_shop_product_path(@shop_product)
|
18
|
+
}
|
19
|
+
format.js { render :partial => '/admin/shop/products/edit/shared/variant', :locals => { :variant => @shop_product_variant } }
|
20
|
+
end
|
21
|
+
rescue
|
22
|
+
respond_to do |format|
|
23
|
+
format.html {
|
24
|
+
flash[:error] = error
|
25
|
+
redirect_to edit_admin_shop_product_path(@shop_product)
|
26
|
+
}
|
27
|
+
format.js { render :text => error, :status => :unprocessable_entity }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def destroy
|
33
|
+
notice = 'Successfully destroyed variant.'
|
34
|
+
error = 'Could not destroy variant.'
|
35
|
+
|
36
|
+
if @shop_product_variant.destroy
|
37
|
+
respond_to do |format|
|
38
|
+
format.html {
|
39
|
+
redirect_to edit_admin_shop_product_path(@shop_product)
|
40
|
+
}
|
41
|
+
format.js { render :text => notice, :status => :ok }
|
42
|
+
end
|
43
|
+
else
|
44
|
+
respond_to do |format|
|
45
|
+
format.html {
|
46
|
+
flash[:error] = error
|
47
|
+
redirect_to edit_admin_shop_product_path(@shop_product)
|
48
|
+
}
|
49
|
+
format.js { render :text => error, :status => :unprocessable_entity }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def find_product
|
57
|
+
@shop_product = @shop_product_variant.product || ShopProduct.find(params[:product_id])
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -2,14 +2,17 @@ class Admin::Shop::ProductsController < Admin::ResourceController
|
|
2
2
|
|
3
3
|
model_class ShopProduct
|
4
4
|
|
5
|
+
helper :shop
|
6
|
+
|
5
7
|
before_filter :config_global
|
8
|
+
before_filter :config_index, :only => [ :index ]
|
6
9
|
before_filter :config_new, :only => [ :new, :create ]
|
7
10
|
before_filter :config_edit, :only => [ :edit, :update ]
|
8
11
|
before_filter :assets_global
|
9
12
|
before_filter :assets_index, :only => [ :index ]
|
10
13
|
before_filter :assets_edit, :only => [ :edit, :update ]
|
11
14
|
|
12
|
-
before_filter :
|
15
|
+
before_filter :set_layout_and_page, :only => [ :new ]
|
13
16
|
|
14
17
|
# GET /admin/shop/products
|
15
18
|
# GET /admin/shop/products.js
|
@@ -17,12 +20,11 @@ class Admin::Shop::ProductsController < Admin::ResourceController
|
|
17
20
|
#----------------------------------------------------------------------------
|
18
21
|
def index
|
19
22
|
@shop_categories = ShopCategory.all
|
20
|
-
@shop_products = ShopProduct.search(params[:search])
|
21
23
|
|
22
24
|
respond_to do |format|
|
23
25
|
format.html { render :index }
|
24
26
|
format.js { render :partial => '/admin/shop/products/index/product', :collection => @shop_products }
|
25
|
-
format.json { render :json => @shop_products.to_json
|
27
|
+
format.json { render :json => @shop_products.to_json }
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -32,26 +34,17 @@ class Admin::Shop::ProductsController < Admin::ResourceController
|
|
32
34
|
#----------------------------------------------------------------------------
|
33
35
|
def sort
|
34
36
|
notice = 'Products successfully sorted.'
|
35
|
-
error
|
37
|
+
error = 'Could not sort Products.'
|
36
38
|
|
37
39
|
begin
|
38
|
-
|
39
|
-
@shop_products = CGI::parse(params[:products])["shop_category_#{params[:category_id]}_products[]"]
|
40
|
-
|
41
|
-
@shop_products.each_with_index do |id, index|
|
42
|
-
ShopProduct.find(id).update_attributes!({
|
43
|
-
:position => index+1,
|
44
|
-
:shop_category_id => @shop_category.id
|
45
|
-
})
|
46
|
-
end
|
40
|
+
ShopProduct.sort(params[:category_id], CGI::parse(params[:products])["category_#{params[:category_id]}_products[]"])
|
47
41
|
|
48
42
|
respond_to do |format|
|
49
43
|
format.html {
|
50
|
-
flash[:notice] = notice
|
51
44
|
redirect_to admin_shop_products_path
|
52
45
|
}
|
53
|
-
|
54
|
-
|
46
|
+
format.js { render :text => notice, :status => :ok }
|
47
|
+
format.json { render :json => { :notice => notice }, :status => :ok }
|
55
48
|
end
|
56
49
|
rescue
|
57
50
|
respond_to do |format|
|
@@ -79,13 +72,12 @@ class Admin::Shop::ProductsController < Admin::ResourceController
|
|
79
72
|
@shop_product.save!
|
80
73
|
|
81
74
|
respond_to do |format|
|
82
|
-
format.html {
|
83
|
-
flash[:notice] = notice
|
75
|
+
format.html {
|
84
76
|
redirect_to edit_admin_shop_product_path(@shop_product) if params[:continue]
|
85
77
|
redirect_to admin_shop_products_path unless params[:continue]
|
86
78
|
}
|
87
|
-
format.js { render
|
88
|
-
format.json { render
|
79
|
+
format.js { render :partial => '/admin/shop/products/index/product', :locals => { :excerpt => @shop_product } }
|
80
|
+
format.json { render :json => @shop_product.to_json }
|
89
81
|
end
|
90
82
|
rescue
|
91
83
|
respond_to do |format|
|
@@ -93,8 +85,8 @@ class Admin::Shop::ProductsController < Admin::ResourceController
|
|
93
85
|
flash[:error] = error
|
94
86
|
render :new
|
95
87
|
}
|
96
|
-
format.js { render
|
97
|
-
format.json { render
|
88
|
+
format.js { render :text => error, :status => :unprocessable_entity }
|
89
|
+
format.json { render :json => { :error => error }, :status => :unprocessable_entity }
|
98
90
|
end
|
99
91
|
end
|
100
92
|
end
|
@@ -112,13 +104,12 @@ class Admin::Shop::ProductsController < Admin::ResourceController
|
|
112
104
|
@shop_product.update_attributes!(params[:shop_product])
|
113
105
|
|
114
106
|
respond_to do |format|
|
115
|
-
format.html {
|
116
|
-
flash[:notice] = notice
|
107
|
+
format.html {
|
117
108
|
redirect_to edit_admin_shop_product_path(@shop_product) if params[:continue]
|
118
109
|
redirect_to admin_shop_products_path unless params[:continue]
|
119
110
|
}
|
120
111
|
format.js { render :partial => '/admin/shop/products/index/product', :locals => { :product => @shop_product } }
|
121
|
-
format.json { render :json => @shop_product.to_json
|
112
|
+
format.json { render :json => @shop_product.to_json }
|
122
113
|
end
|
123
114
|
rescue
|
124
115
|
respond_to do |format|
|
@@ -139,79 +130,91 @@ class Admin::Shop::ProductsController < Admin::ResourceController
|
|
139
130
|
#----------------------------------------------------------------------------
|
140
131
|
def destroy
|
141
132
|
notice = 'Product deleted successfully.'
|
142
|
-
error = 'Could not delete Product.'
|
143
133
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
format.js { render :text => notice, :status => :ok }
|
153
|
-
format.json { render :json => { :notice => notice }, :status => :ok }
|
154
|
-
end
|
155
|
-
rescue
|
156
|
-
respond_to do |format|
|
157
|
-
format.html {
|
158
|
-
flash[:error] = error
|
159
|
-
render :remove
|
160
|
-
}
|
161
|
-
format.js { render :text => error, :status => :unprocessable_entity }
|
162
|
-
format.json { render :json => { :error => error }, :status => :unprocessable_entity }
|
163
|
-
end
|
134
|
+
@shop_product.destroy
|
135
|
+
|
136
|
+
respond_to do |format|
|
137
|
+
format.html {
|
138
|
+
redirect_to admin_shop_products_path
|
139
|
+
}
|
140
|
+
format.js { render :text => notice, :status => :ok }
|
141
|
+
format.json { render :json => { :notice => notice }, :status => :ok }
|
164
142
|
end
|
165
143
|
end
|
166
144
|
|
167
145
|
private
|
168
146
|
|
169
147
|
def config_global
|
148
|
+
@inputs ||= []
|
170
149
|
@meta ||= []
|
171
150
|
@buttons ||= []
|
172
151
|
@parts ||= []
|
173
152
|
@popups ||= []
|
153
|
+
|
154
|
+
@inputs << 'name'
|
155
|
+
@inputs << 'price'
|
156
|
+
|
157
|
+
@meta << 'sku'
|
158
|
+
@meta << 'page'
|
159
|
+
@meta << 'category'
|
160
|
+
|
161
|
+
@parts << 'description'
|
162
|
+
@parts << 'variants'
|
163
|
+
end
|
164
|
+
|
165
|
+
def config_index
|
166
|
+
@buttons << 'packages'
|
167
|
+
@buttons << 'variants'
|
168
|
+
@buttons << 'discounts'
|
174
169
|
end
|
175
170
|
|
176
171
|
def config_new
|
177
|
-
@meta << 'category'
|
178
|
-
@meta << 'sku'
|
179
|
-
|
180
|
-
@parts << 'description'
|
181
172
|
end
|
182
173
|
|
183
174
|
def config_edit
|
184
|
-
@
|
185
|
-
@
|
175
|
+
@parts << 'images'
|
176
|
+
@parts << 'customers'
|
186
177
|
|
187
|
-
@
|
188
|
-
@
|
178
|
+
@buttons << 'browse_images'
|
179
|
+
@buttons << 'new_image'
|
180
|
+
@buttons << 'browse_templates'
|
181
|
+
@buttons << 'new_variant'
|
189
182
|
|
190
|
-
@
|
191
|
-
@
|
192
|
-
|
193
|
-
@popups
|
194
|
-
@popups << 'new_image'
|
183
|
+
@popups << 'browse_images'
|
184
|
+
@popups << 'new_image'
|
185
|
+
@popups << 'browse_templates'
|
186
|
+
@popups << 'new_variant'
|
195
187
|
end
|
196
188
|
|
197
189
|
def assets_global
|
198
|
-
include_stylesheet 'admin/extensions/shop/edit'
|
199
190
|
end
|
200
191
|
|
201
192
|
def assets_index
|
193
|
+
include_stylesheet 'admin/extensions/shop/index'
|
194
|
+
include_stylesheet 'admin/extensions/shop/products/index'
|
195
|
+
|
202
196
|
include_javascript 'admin/dragdrop'
|
197
|
+
include_javascript 'admin/extensions/shop/edit'
|
203
198
|
include_javascript 'admin/extensions/shop/products/index'
|
204
|
-
include_stylesheet 'admin/extensions/shop/products/index'
|
205
199
|
end
|
206
200
|
|
207
201
|
def assets_edit
|
208
|
-
|
202
|
+
include_stylesheet 'admin/extensions/shop/edit'
|
209
203
|
include_stylesheet 'admin/extensions/shop/products/edit'
|
204
|
+
|
205
|
+
include_javascript 'admin/dragdrop'
|
206
|
+
include_javascript 'admin/extensions/shop/edit'
|
210
207
|
include_javascript 'admin/extensions/shop/products/edit'
|
211
208
|
end
|
212
209
|
|
213
|
-
def
|
214
|
-
@
|
210
|
+
def set_layout_and_page
|
211
|
+
@shop_category = ShopCategory.find(params[:category_id])
|
212
|
+
@shop_product.page = Page.new(
|
213
|
+
:parent_id => @shop_category.page_id,
|
214
|
+
:layout_id => @shop_category.product_layout_id,
|
215
|
+
:parts => [PagePart.new]
|
216
|
+
)
|
215
217
|
end
|
216
218
|
|
219
|
+
|
217
220
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class Admin::Shop::VariantsController < Admin::ResourceController
|
2
|
+
|
3
|
+
model_class ShopVariant
|
4
|
+
|
5
|
+
before_filter :config_global
|
6
|
+
before_filter :config_index, :only => [ :index ]
|
7
|
+
before_filter :config_new, :only => [ :new, :create ]
|
8
|
+
before_filter :config_edit, :only => [ :edit, :update ]
|
9
|
+
before_filter :assets_global
|
10
|
+
before_filter :assets_index, :only => [ :index ]
|
11
|
+
before_filter :assets_edit, :only => [ :edit, :update ]
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def config_global
|
16
|
+
@inputs ||= []
|
17
|
+
@meta ||= []
|
18
|
+
@buttons ||= []
|
19
|
+
@parts ||= []
|
20
|
+
@popups ||= []
|
21
|
+
|
22
|
+
@inputs << 'name'
|
23
|
+
@inputs << 'options'
|
24
|
+
end
|
25
|
+
|
26
|
+
def config_index
|
27
|
+
@buttons << 'packages'
|
28
|
+
@buttons << 'variants'
|
29
|
+
@buttons << 'discounts'
|
30
|
+
end
|
31
|
+
|
32
|
+
def config_new
|
33
|
+
end
|
34
|
+
|
35
|
+
def config_edit
|
36
|
+
end
|
37
|
+
|
38
|
+
def assets_global
|
39
|
+
include_stylesheet 'admin/extensions/shop/edit'
|
40
|
+
include_stylesheet 'admin/extensions/shop/index'
|
41
|
+
end
|
42
|
+
|
43
|
+
def assets_index
|
44
|
+
end
|
45
|
+
|
46
|
+
def assets_edit
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|