diff --git a/app/assets/javascripts/admin/products/products.js.coffee b/app/assets/javascripts/admin/products/products.js.coffee index e922d40a34..1952c8dded 100644 --- a/app/assets/javascripts/admin/products/products.js.coffee +++ b/app/assets/javascripts/admin/products/products.js.coffee @@ -1 +1 @@ -angular.module("admin.products", []) \ No newline at end of file +angular.module("admin.products", ["admin.utils"]) \ No newline at end of file diff --git a/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee b/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee index 0dcda8f59a..deb7186d95 100644 --- a/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/map_osm_tiles.js.coffee @@ -15,7 +15,7 @@ Darkswarm.directive 'mapOsmTiles', ($timeout) -> if x < 0 x = tilesPerGlobe + x # Wrap y (latitude) in a like manner if you want to enable vertical infinite scroll - 'http://tile.openstreetmap.org/' + zoom + '/' + x + '/' + coord.y + '.png' + 'https://a.tile.openstreetmap.org/' + zoom + '/' + x + '/' + coord.y + '.png' tileSize: new google.maps.Size(256, 256) name: 'OpenStreetMap' maxZoom: 18 diff --git a/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass b/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass index a2f2304d3e..144a5049f4 100644 --- a/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass +++ b/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass @@ -33,16 +33,18 @@ ordercycle - p.text-right + text-align: right + p max-width: 400px @media all and (max-width: 640px) float: left clear: left + text-align: left padding: 12px 10px width: 100% margin-top: 10px background: #e5e5e5 - p.text-right + p max-width: 100% float: right form.custom diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index 40c6a6910b..724101964b 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -237,6 +237,7 @@ Spree::Product.class_eval do variant = self.master.dup variant.product = self variant.is_master = false + variant.on_demand = self.on_demand self.variants << variant end end diff --git a/app/overrides/spree/admin/variants/_form/add_angular.deface b/app/overrides/spree/admin/variants/_form/add_angular.deface new file mode 100644 index 0000000000..507e821e9c --- /dev/null +++ b/app/overrides/spree/admin/variants/_form/add_angular.deface @@ -0,0 +1,2 @@ +add_to_attributes '[data-hook="admin_variant_form_fields"]' +attributes 'ng-app' => 'admin.products' \ No newline at end of file diff --git a/app/overrides/spree/admin/variants/_form/on_demand_script.html.haml.deface b/app/overrides/spree/admin/variants/_form/on_demand_script.html.haml.deface new file mode 100644 index 0000000000..6bd45a0d49 --- /dev/null +++ b/app/overrides/spree/admin/variants/_form/on_demand_script.html.haml.deface @@ -0,0 +1,28 @@ +/ insert_bottom "[data-hook='admin_variant_form_fields']" +:javascript + + $(document).ready(function() { + + var on_demand = $('input#variant_on_demand'); + var on_hand = $('input#variant_on_hand'); + + on_hand.attr('disabled', on_demand.attr('checked')); + + on_demand.change(function(){ + + on_hand.attr('disabled', this.checked); + + if(this.checked) { + on_hand.attr('data-stock', on_hand.val()); + on_hand.val("Infinity"); + } else { + if(on_hand.attr('data-stock') !== undefined) { + on_hand.val(on_hand.attr('data-stock')); + } else { + on_hand.val("0"); + } + } + + }); + + }); diff --git a/app/overrides/spree/admin/variants/_form/on_demand_tooltip.html.haml.deface b/app/overrides/spree/admin/variants/_form/on_demand_tooltip.html.haml.deface new file mode 100644 index 0000000000..946370514b --- /dev/null +++ b/app/overrides/spree/admin/variants/_form/on_demand_tooltip.html.haml.deface @@ -0,0 +1,3 @@ +/ insert_bottom "[data-hook='on_demand']" +%div{'ofn-with-tip' => t('admin.products.variants.to_order_tip')} + %a What's this? \ No newline at end of file diff --git a/app/views/shopping_shared/_order_cycles.html.haml b/app/views/shopping_shared/_order_cycles.html.haml index cd5ead30f3..0e18d3cfc7 100644 --- a/app/views/shopping_shared/_order_cycles.html.haml +++ b/app/views/shopping_shared/_order_cycles.html.haml @@ -3,10 +3,10 @@ angular.module('Darkswarm').value('orderCycleData', #{render "json/order_cycle"}) - if @order_cycles and @order_cycles.empty? - %h4.text-right + %h4 %i.ofn-i_032-closed-sign = t :shopping_oc_closed - %p.text-right + %p = t :shopping_oc_closed_description .text-right %small diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 9ac4446b3d..5542c29963 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -112,6 +112,8 @@ en-GB: inherits_properties?: Inherits Properties? available_on: Available On av_on: "Av. On" + variants: + to_order_tip: "Items made to order do not have a set stock level, such as loaves of bread made fresh to order." variant_overrides: index: title: Inventory diff --git a/config/locales/en.yml b/config/locales/en.yml index 0c96b5d42a..9590047ba2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -176,6 +176,8 @@ en: inherits_properties?: Inherits Properties? available_on: Available On av_on: "Av. On" + variants: + to_order_tip: "Items made to order do not have a set stock level, such as loaves of bread made fresh to order." variant_overrides: loading_flash: diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 445844d97b..2d5e4dcbe8 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -59,6 +59,33 @@ feature %q{ product.master.options_text.should == "5kg" end + scenario "creating an on-demand product", js: true do + login_to_admin_section + + click_link 'Products' + click_link 'New Product' + + fill_in 'product_name', with: 'Hot Cakes' + select 'New supplier', from: 'product_supplier_id' + select "Weight (kg)", from: 'product_variant_unit_with_scale' + fill_in 'product_unit_value_with_description', with: 1 + select taxon.name, from: "product_primary_taxon_id" + fill_in 'product_price', with: '1.99' + fill_in 'product_on_hand', with: 0 + check 'product_on_demand' + select 'Test Tax Category', from: 'product_tax_category_id' + select 'Test Shipping Category', from: 'product_shipping_category_id' + fill_in 'product_description', with: "In demand, and on_demand! The hottest cakes in town." + + click_button 'Create' + + expect(current_path).to eq spree.bulk_edit_admin_products_path + product = Spree::Product.find_by_name('Hot Cakes') + product.variants.count.should == 1 + variant = product.variants.first + variant.on_demand.should be_true + end + scenario "making a product into a group buy product" do product = create(:simple_product, name: 'group buy product')