From 3e77534dcfad4bd12f5c8d69c22363213225ff9e Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Fri, 25 Nov 2016 01:31:45 +0000 Subject: [PATCH 01/10] Product variant form script --- .../_form/on_demand_script.html.haml.deface | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/overrides/spree/admin/variants/_form/on_demand_script.html.haml.deface 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"); + } + } + + }); + + }); From 7981feefa165ae2cefc4a25907251273476a4006 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Mon, 28 Nov 2016 14:38:13 +0000 Subject: [PATCH 02/10] Updated form to include help tip for clarity --- app/assets/javascripts/admin/products/products.js.coffee | 2 +- app/overrides/spree/admin/variants/_form/add_angular.deface | 2 ++ .../admin/variants/_form/on_demand_tooltip.html.haml.deface | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 app/overrides/spree/admin/variants/_form/add_angular.deface create mode 100644 app/overrides/spree/admin/variants/_form/on_demand_tooltip.html.haml.deface 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/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_tooltip.html.haml.deface b/app/overrides/spree/admin/variants/_form/on_demand_tooltip.html.haml.deface new file mode 100644 index 0000000000..3827bdaac5 --- /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' => "Items made to order do not have a set stock level, such as loaves of bread made fresh to order."} + %a What's this? \ No newline at end of file From 252f8768273a63778d2e7be9e3403523a000b487 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Sat, 17 Dec 2016 22:54:59 +0000 Subject: [PATCH 03/10] Fixed orders closed display for mobile view --- app/assets/stylesheets/darkswarm/_shop-navigation.css.sass | 3 +++ app/views/shopping_shared/_order_cycles.html.haml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass b/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass index a2f2304d3e..c1f8c54d63 100644 --- a/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass +++ b/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass @@ -33,17 +33,20 @@ ordercycle + text-align: right p.text-right 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 max-width: 100% + text-align: left float: right form.custom text-align: right 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 From 38fe0afc032daff463b7c146eb1304b61599a91f Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Sat, 17 Dec 2016 22:59:29 +0000 Subject: [PATCH 04/10] Changed p widths --- app/assets/stylesheets/darkswarm/_shop-navigation.css.sass | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass b/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass index c1f8c54d63..144a5049f4 100644 --- a/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass +++ b/app/assets/stylesheets/darkswarm/_shop-navigation.css.sass @@ -34,7 +34,7 @@ ordercycle text-align: right - p.text-right + p max-width: 400px @media all and (max-width: 640px) float: left @@ -44,9 +44,8 @@ width: 100% margin-top: 10px background: #e5e5e5 - p.text-right + p max-width: 100% - text-align: left float: right form.custom text-align: right From bc5672b5eb59f40a65366c1407114e3b50c0f5c6 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Tue, 20 Dec 2016 13:30:24 +0000 Subject: [PATCH 05/10] Added translation --- .../admin/variants/_form/on_demand_tooltip.html.haml.deface | 2 +- config/locales/en-GB.yml | 2 ++ config/locales/en.yml | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) 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 index 3827bdaac5..946370514b 100644 --- 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 @@ -1,3 +1,3 @@ / insert_bottom "[data-hook='on_demand']" -%div{'ofn-with-tip' => "Items made to order do not have a set stock level, such as loaves of bread made fresh to order."} +%div{'ofn-with-tip' => t('admin.products.variants.to_order_tip')} %a What's this? \ No newline at end of file diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index f76c59352d..2a8d9bc0fb 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -99,6 +99,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 ba2b1acab6..6f80f0f1b7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -140,6 +140,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: index: From 165b437f315c249da56cc698e1db1b53f05f2d92 Mon Sep 17 00:00:00 2001 From: Paul Mackay Date: Fri, 20 Jan 2017 15:59:22 +0000 Subject: [PATCH 06/10] #1226: fix OSM URL to use HTTPS --- .../javascripts/darkswarm/directives/map_osm_tiles.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 940ca7ade1739bda52071481a32debabcdc9c648 Mon Sep 17 00:00:00 2001 From: OliverUK Date: Fri, 27 Jan 2017 15:02:38 +0000 Subject: [PATCH 07/10] translate ABN and ACN to company number, charity number --- config/locales/en-GB.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 92eba244eb..041cdc614b 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -548,7 +548,7 @@ en-GB: sell_hubs_detail: "Set up a profile for your food enterprise or organisation on the OFN. At any time you can upgrade your profile to a multi-producer shop." sell_groups_detail: "Set up a tailored directory of enterprises (producers and other food enterprises) for your region or for your organisation." sell_user_guide: "Find out more in our user guide." - sell_listing_price: "Selling through OFN UK is free!\n\nOFN UK is a Platform Cooperative - part of the Solidarity or Sharing Economy. Our goal is to support the distribution of as much local food as possible. As such OFN UK asks users to 'Pay What You Feel' toward the running costs and maintenance. We think 2% of sales is fair for all the services that OFN UK provide. But more importantly, we think that getting good local food to people at a fair price is more important than paying for software. So pay what you feel our services are worth to your enterprise." + sell_listing_price: "Sell through OFN UK. Pay what you think is fair.\n\nOur goal is to support the distribution of as much local food as possible. As such OFN UK asks users to 'Pay What You Feel' toward the running costs and maintenance. All we ask is that you do pay something. " sell_embed: "We collectively budget for new feature development from the international OFN community. This way the huge cost of good software development can be shared. If you want a new feature, chances are someone in France, South Africa, Australia, India or Brazil might want it too! Use the Community Forum to suggest features you'd like to see." sell_ask_services: "Ask us about OFN services." shops_title: Shops @@ -683,9 +683,9 @@ en-GB: enterprise_long_desc: "Long Description" enterprise_long_desc_placeholder: "This is your opportunity to tell the story of your enterprise - what makes you different and wonderful? We'd suggest keeping your description to under 600 characters or 150 words." enterprise_long_desc_length: "%{num} characters / up to 600 recommended" - enterprise_abn: "ABN" + enterprise_abn: "Company Number" enterprise_abn_placeholder: "eg. 99 123 456 789" - enterprise_acn: "ACN" + enterprise_acn: "Charity Number" enterprise_acn_placeholder: "eg. 123 456 789" enterprise_tax_required: "You need to make a selection." enterprise_final_step: "Final step!" From 67730e82c3083a481059cd8183d71317b082adca Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 30 Jan 2017 12:04:24 +0000 Subject: [PATCH 08/10] Update en-GB.yml --- config/locales/en-GB.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 041cdc614b..c1954c4956 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -548,7 +548,7 @@ en-GB: sell_hubs_detail: "Set up a profile for your food enterprise or organisation on the OFN. At any time you can upgrade your profile to a multi-producer shop." sell_groups_detail: "Set up a tailored directory of enterprises (producers and other food enterprises) for your region or for your organisation." sell_user_guide: "Find out more in our user guide." - sell_listing_price: "Sell through OFN UK. Pay what you think is fair.\n\nOur goal is to support the distribution of as much local food as possible. As such OFN UK asks users to 'Pay What You Feel' toward the running costs and maintenance. All we ask is that you do pay something. " + sell_listing_price: "Sell through OFN UK. Pay what you think is fair. Our goal is to support the distribution of as much local food as possible. As such OFN UK asks users to 'Pay What You Feel' toward the running costs and maintenance. All we ask is that you do pay something. " sell_embed: "We collectively budget for new feature development from the international OFN community. This way the huge cost of good software development can be shared. If you want a new feature, chances are someone in France, South Africa, Australia, India or Brazil might want it too! Use the Community Forum to suggest features you'd like to see." sell_ask_services: "Ask us about OFN services." shops_title: Shops From 6d19613ecc943261717c8c53ccf13e852f9830ca Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 30 Jan 2017 12:53:01 +0000 Subject: [PATCH 09/10] Revert "translate ABN and ACN to company number, charity number" --- config/locales/en-GB.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index c1954c4956..92eba244eb 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -548,7 +548,7 @@ en-GB: sell_hubs_detail: "Set up a profile for your food enterprise or organisation on the OFN. At any time you can upgrade your profile to a multi-producer shop." sell_groups_detail: "Set up a tailored directory of enterprises (producers and other food enterprises) for your region or for your organisation." sell_user_guide: "Find out more in our user guide." - sell_listing_price: "Sell through OFN UK. Pay what you think is fair. Our goal is to support the distribution of as much local food as possible. As such OFN UK asks users to 'Pay What You Feel' toward the running costs and maintenance. All we ask is that you do pay something. " + sell_listing_price: "Selling through OFN UK is free!\n\nOFN UK is a Platform Cooperative - part of the Solidarity or Sharing Economy. Our goal is to support the distribution of as much local food as possible. As such OFN UK asks users to 'Pay What You Feel' toward the running costs and maintenance. We think 2% of sales is fair for all the services that OFN UK provide. But more importantly, we think that getting good local food to people at a fair price is more important than paying for software. So pay what you feel our services are worth to your enterprise." sell_embed: "We collectively budget for new feature development from the international OFN community. This way the huge cost of good software development can be shared. If you want a new feature, chances are someone in France, South Africa, Australia, India or Brazil might want it too! Use the Community Forum to suggest features you'd like to see." sell_ask_services: "Ask us about OFN services." shops_title: Shops @@ -683,9 +683,9 @@ en-GB: enterprise_long_desc: "Long Description" enterprise_long_desc_placeholder: "This is your opportunity to tell the story of your enterprise - what makes you different and wonderful? We'd suggest keeping your description to under 600 characters or 150 words." enterprise_long_desc_length: "%{num} characters / up to 600 recommended" - enterprise_abn: "Company Number" + enterprise_abn: "ABN" enterprise_abn_placeholder: "eg. 99 123 456 789" - enterprise_acn: "Charity Number" + enterprise_acn: "ACN" enterprise_acn_placeholder: "eg. 123 456 789" enterprise_tax_required: "You need to make a selection." enterprise_final_step: "Final step!" From fc4ead9b05b679065e8a5ab642733f1bab3771cf Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Thu, 2 Feb 2017 01:06:20 +0000 Subject: [PATCH 10/10] Ensure on_demand set properly on new products --- app/models/spree/product_decorator.rb | 1 + spec/features/admin/products_spec.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) 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/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')