diff --git a/app/assets/javascripts/darkswarm/directives/integer.js.coffee b/app/assets/javascripts/darkswarm/directives/integer.js.coffee deleted file mode 100644 index e162246122..0000000000 --- a/app/assets/javascripts/darkswarm/directives/integer.js.coffee +++ /dev/null @@ -1,5 +0,0 @@ -Darkswarm.directive "integer", -> - restrict: 'A' - link: (scope, elem, attr) -> - elem.bind 'input', -> - elem.val Math.round(elem.val()) diff --git a/app/assets/javascripts/templates/shop_variant.html.haml b/app/assets/javascripts/templates/shop_variant.html.haml index 04048f3cd0..6d050d0bde 100644 --- a/app/assets/javascripts/templates/shop_variant.html.haml +++ b/app/assets/javascripts/templates/shop_variant.html.haml @@ -11,7 +11,6 @@ .small-5.medium-3.large-3.columns.text-right{"bo-if" => "!variant.product.group_buy"} %input{type: :number, - integer: true, value: nil, min: 0, placeholder: "0", @@ -27,17 +26,14 @@ %span.bulk-input %input.bulk.first{type: :number, value: nil, - integer: true, min: 0, "ng-model" => "variant.line_item.quantity", placeholder: "min", "ofn-disable-scroll" => true, max: "{{variant.on_demand && 9999 || variant.count_on_hand }}", name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"} - %span.bulk-input + %span.bulk-input{"bo-if" => "variant.product.group_buy"} %input.bulk.second{type: :number, - "ng-disabled" => "!variant.line_item.quantity", - integer: true, min: 0, "ng-model" => "variant.line_item.max_quantity", placeholder: "max", diff --git a/app/assets/stylesheets/darkswarm/shopping-cart.css.sass b/app/assets/stylesheets/darkswarm/shopping-cart.css.sass index 74cec02ce0..cb71913831 100644 --- a/app/assets/stylesheets/darkswarm/shopping-cart.css.sass +++ b/app/assets/stylesheets/darkswarm/shopping-cart.css.sass @@ -38,7 +38,6 @@ padding: 4px 12px color: #fff .buttons - margin-bottom: 0.1em .button height: auto top: 0px diff --git a/app/overrides/spree/layouts/admin/add_customers_admin_tab.html.haml.deface b/app/overrides/spree/layouts/admin/add_customers_admin_tab.html.haml.deface deleted file mode 100644 index 7b7534b23f..0000000000 --- a/app/overrides/spree/layouts/admin/add_customers_admin_tab.html.haml.deface +++ /dev/null @@ -1,2 +0,0 @@ -/ insert_bottom "[data-hook='admin_tabs'], #admin_tabs[data-hook]" -= tab :customers, :url => main_app.admin_customers_path diff --git a/app/views/producers/_fat.html.haml b/app/views/producers/_fat.html.haml index 06d73666af..6083250780 100644 --- a/app/views/producers/_fat.html.haml +++ b/app/views/producers/_fat.html.haml @@ -68,7 +68,7 @@   .row.cta-container .columns.small-12 - %a.cta-hub{"ng-repeat" => "hub in producer.hubs | visible | orderBy:'-active'", + %a.cta-hub{"ng-repeat" => "hub in producer.hubs | orderBy:'-active'", "bo-href" => "hub.path", "ofn-change-hub" => "hub", "bo-class" => "{primary: hub.active, secondary: !hub.active}"} %i.ofn-i_033-open-sign{"bo-if" => "hub.active"} diff --git a/app/views/shared/menu/_cart.html.haml b/app/views/shared/menu/_cart.html.haml index f4d3e00c67..f8287c8f61 100644 --- a/app/views/shared/menu/_cart.html.haml +++ b/app/views/shared/menu/_cart.html.haml @@ -9,11 +9,7 @@ .joyride-tip-guide{"ng-class" => "{ in: open }", "ng-show" => "open"} %span.joyride-nub.top .joyride-content-wrapper - %h5.text-left Your shopping cart - .buttons.text-right - %a.button.secondary.tiny.add_to_cart{ href: cart_path, type: :submit, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }" } - {{ Cart.dirty ? 'Updating cart...' : (Cart.empty() ? 'Cart empty' : 'Edit your cart' ) }} - %a.button.primary.tiny{href: checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"} Checkout now + %h5 Your shopping cart %table %tr.product-cart{"ng-repeat" => "line_item in Cart.line_items_present()", "ng-controller" => "LineItemCtrl", "id" => "cart-variant-{{ line_item.variant.id }}"} diff --git a/app/views/spree/admin/products/_group_buy_form.html.haml b/app/views/spree/admin/products/_group_buy_form.html.haml index 8f1de2a884..6669563d15 100644 --- a/app/views/spree/admin/products/_group_buy_form.html.haml +++ b/app/views/spree/admin/products/_group_buy_form.html.haml @@ -9,6 +9,6 @@ = f.label :group_buy_0, 'No' %br.clear = f.field_container :group_buy_unit_size do - = f.label :group_buy_unit_size, "Bulk unit size" + = f.label :group_buy_unit_size %br = f.text_field :group_buy_unit_size diff --git a/app/views/spree/admin/products/_supplier_and_group_buy_for_new.html.haml b/app/views/spree/admin/products/_supplier_and_group_buy_for_new.html.haml new file mode 100644 index 0000000000..d17a45fa6c --- /dev/null +++ b/app/views/spree/admin/products/_supplier_and_group_buy_for_new.html.haml @@ -0,0 +1,20 @@ +.row + .alpha.six.columns + = f.field_container :supplier do + = f.label :supplier + = f.collection_select(:supplier_id, Enterprise.is_primary_producer.managed_by(spree_current_user).by_name, :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"}) + = f.error_message_on :supplier + .four.columns + = f.field_container :group_buy do + = f.label :group_buy, 'Group buy?' + %br + .alpha.two.columns + = f.radio_button :group_buy, '1', :checked => f.object.group_buy + = f.label :group_buy_1, 'Yes' + .omega.two.columns + = f.radio_button :group_buy, '0', :checked => !f.object.group_buy + = f.label :group_buy_0, 'No' + .omega.six.columns + = f.field_container :group_buy_unit_size do + = f.label :group_buy_unit_size + = f.text_field :group_buy_unit_size, :class => "fullwidth" diff --git a/app/views/spree/order_mailer/confirm_email_for_shop.html.haml b/app/views/spree/order_mailer/confirm_email_for_shop.html.haml index ac5d45d893..f62b3cdfb4 100644 --- a/app/views/spree/order_mailer/confirm_email_for_shop.html.haml +++ b/app/views/spree/order_mailer/confirm_email_for_shop.html.haml @@ -19,10 +19,9 @@ %h4 Order confirmation %strong ##{@order.number} -%h5 +%p %strong= "#{@order.bill_address.firstname} #{@order.bill_address.lastname}" - = " <#{@order.email}>" if @order.email - = @order.bill_address.phone if @order.bill_address.phone + completed the following order at your shopfront: = render 'order_summary' = render 'payment' diff --git a/lib/open_food_network/bulk_coop_report.rb b/lib/open_food_network/bulk_coop_report.rb index 57f34d9edc..d6bf23f85b 100644 --- a/lib/open_food_network/bulk_coop_report.rb +++ b/lib/open_food_network/bulk_coop_report.rb @@ -23,7 +23,7 @@ module OpenFoodNetwork when "bulk_coop_customer_payments" ["Customer", "Date of Order", "Total Cost", "Amount Owing", "Amount Paid"] else - ["Supplier", "Product", "Bulk Unit Size", "Variant", "Weight", "Sum Total", "Sum Max Total", "Units Required", "Remainder"] + ["Supplier", "Product", "Unit Size", "Variant", "Weight", "Sum Total", "Sum Max Total", "Units Required", "Remainder"] end end @@ -59,7 +59,7 @@ module OpenFoodNetwork sort_by: proc { |product| product.name }, summary_columns: [ proc { |lis| lis.first.variant.product.supplier.name }, proc { |lis| lis.first.variant.product.name }, - proc { |lis| lis.first.variant.product.group_buy_unit_size || 0.0 }, + proc { |lis| lis.first.variant.product.group_buy ? (lis.first.variant.product.group_buy_unit_size || 0.0) : "" }, proc { |lis| "" }, proc { |lis| "" }, proc { |lis| lis.sum { |li| li.quantity * (li.variant.weight || 0) } }, @@ -91,7 +91,7 @@ module OpenFoodNetwork else [ proc { |lis| lis.first.variant.product.supplier.name }, proc { |lis| lis.first.variant.product.name }, - proc { |lis| lis.first.variant.product.group_buy_unit_size || 0.0 }, + proc { |lis| lis.first.variant.product.group_buy ? (lis.first.variant.product.group_buy_unit_size || 0.0) : "" }, proc { |lis| lis.first.variant.full_name }, proc { |lis| lis.first.variant.weight || 0 }, proc { |lis| lis.sum { |li| li.quantity } }, diff --git a/lib/open_food_network/reports/bulk_coop_allocation_report.rb b/lib/open_food_network/reports/bulk_coop_allocation_report.rb index 2bd19ea66a..52efbc677c 100644 --- a/lib/open_food_network/reports/bulk_coop_allocation_report.rb +++ b/lib/open_food_network/reports/bulk_coop_allocation_report.rb @@ -2,7 +2,7 @@ require 'open_food_network/reports/bulk_coop_report' module OpenFoodNetwork::Reports class BulkCoopAllocationReport < BulkCoopReport - header "Customer", "Product", "Bulk Unit Size", "Variant", "Variant value", "Variant unit", "Weight", "Sum Total", "Total Available", "Unallocated", "Max quantity excess" + header "Customer", "Product", "Unit Size", "Variant", "Variant value", "Variant unit", "Weight", "Sum Total", "Total Available", "Unallocated", "Max quantity excess" organise do group { |li| li.variant.product } @@ -36,7 +36,7 @@ module OpenFoodNetwork::Reports columns do column { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname } column { |lis| lis.first.variant.product.name } - column { |lis| lis.first.variant.product.group_buy_unit_size || 0.0 } + column { |lis| lis.first.variant.product.group_buy ? (lis.first.variant.product.group_buy_unit_size || 0.0) : "" } column { |lis| lis.first.variant.full_name } column { |lis| OpenFoodNetwork::OptionValueNamer.new(lis.first.variant).value } column { |lis| OpenFoodNetwork::OptionValueNamer.new(lis.first.variant).unit } diff --git a/lib/open_food_network/reports/bulk_coop_report.rb b/lib/open_food_network/reports/bulk_coop_report.rb index dbce047963..5c0916585d 100644 --- a/lib/open_food_network/reports/bulk_coop_report.rb +++ b/lib/open_food_network/reports/bulk_coop_report.rb @@ -22,7 +22,11 @@ module OpenFoodNetwork::Reports end def group_buy_unit_size_f(lis) - group_buy_unit_size(lis) + if lis.first.variant.product.group_buy + group_buy_unit_size(lis) + else + "" + end end def total_amount(lis) diff --git a/lib/open_food_network/reports/bulk_coop_supplier_report.rb b/lib/open_food_network/reports/bulk_coop_supplier_report.rb index df3b40c519..b40557ea1a 100644 --- a/lib/open_food_network/reports/bulk_coop_supplier_report.rb +++ b/lib/open_food_network/reports/bulk_coop_supplier_report.rb @@ -2,7 +2,7 @@ require 'open_food_network/reports/bulk_coop_report' module OpenFoodNetwork::Reports class BulkCoopSupplierReport < BulkCoopReport - header "Supplier", "Product", "Bulk Unit Size", "Variant", "Variant value", "Variant unit", "Weight", "Sum Total", "Units Required", "Unallocated", "Max quantity excess" + header "Supplier", "Product", "Unit Size", "Variant", "Variant value", "Variant unit", "Weight", "Sum Total", "Units Required", "Unallocated", "Max quantity excess" organise do group { |li| li.variant.product.supplier } diff --git a/spec/features/admin/orders_spec.rb b/spec/features/admin/orders_spec.rb index 4a30c3a60c..eec021f1f9 100644 --- a/spec/features/admin/orders_spec.rb +++ b/spec/features/admin/orders_spec.rb @@ -50,12 +50,11 @@ feature %q{ scenario "can add a product to an existing order", js: true do login_to_admin_section visit '/admin/orders' + page.find('td.actions a.icon-edit').click - click_edit + targetted_select2_search @product.name, from: ".variant_autocomplete", dropdown_css: ".select2-search" - targetted_select2_search @product.name, from: '#add_variant_id', dropdown_css: '.select2-drop' - - click_link 'Add' + click_icon :plus page.should have_selector 'td', text: @product.name @order.line_items(true).map(&:product).should include @product @@ -154,21 +153,4 @@ feature %q{ end end - - # Working around intermittent click failing - # Possible causes of failure: - # - the link moves - # - the missing content (font icon only) - # - the screen is not big enough - # However, some operations before the click or a second click on failure work. - # - # A lot of people had similar problems: - # https://github.com/teampoltergeist/poltergeist/issues/520 - # https://github.com/thoughtbot/capybara-webkit/issues/494 - def click_edit - click_result = click_icon :edit - unless click_result['status'] == 'success' - click_icon :edit - end - end end diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 2aafc82b02..59748091b3 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -82,7 +82,7 @@ feature %q{ visit spree.edit_admin_product_path(product) choose 'product_group_buy_1' - fill_in 'Bulk unit size', :with => '10' + fill_in 'Group buy unit size', :with => '10' click_button 'Update' diff --git a/spec/features/consumer/shopping/variant_overrides_spec.rb b/spec/features/consumer/shopping/variant_overrides_spec.rb index f850436e52..a6855fc6d1 100644 --- a/spec/features/consumer/shopping/variant_overrides_spec.rb +++ b/spec/features/consumer/shopping/variant_overrides_spec.rb @@ -97,7 +97,9 @@ feature "shopping with variant overrides defined", js: true do it "shows the correct prices in the checkout" do fill_in "variants[#{v1.id}]", with: "2" - click_checkout + show_cart + wait_until_enabled 'li.cart a.button' + click_link 'Checkout now' page.should have_selector 'form.edit_order .cart-total', text: '$122.21' page.should have_selector 'form.edit_order .shipping', text: '$0.00' @@ -109,7 +111,9 @@ feature "shopping with variant overrides defined", js: true do describe "creating orders" do it "creates the order with the correct prices" do fill_in "variants[#{v1.id}]", with: "2" - click_checkout + show_cart + wait_until_enabled 'li.cart a.button' + click_link 'Checkout now' complete_checkout @@ -120,7 +124,9 @@ feature "shopping with variant overrides defined", js: true do it "subtracts stock from the override" do fill_in "variants[#{v4.id}]", with: "2" - click_checkout + show_cart + wait_until_enabled 'li.cart a.button' + click_link 'Checkout now' expect do expect do @@ -131,7 +137,9 @@ feature "shopping with variant overrides defined", js: true do it "subtracts stock from stock-overridden on_demand variants" do fill_in "variants[#{v6.id}]", with: "2" - click_checkout + show_cart + wait_until_enabled 'li.cart a.button' + click_link 'Checkout now' expect do expect do @@ -142,7 +150,9 @@ feature "shopping with variant overrides defined", js: true do it "does not subtract stock from overrides that do not override count_on_hand" do fill_in "variants[#{v1.id}]", with: "2" - click_checkout + show_cart + wait_until_enabled 'li.cart a.button' + click_link 'Checkout now' expect do complete_checkout @@ -153,7 +163,9 @@ feature "shopping with variant overrides defined", js: true do it "does not show out of stock flags on order confirmation page" do v4.update_attribute :count_on_hand, 0 fill_in "variants[#{v4.id}]", with: "2" - click_checkout + show_cart + wait_until_enabled 'li.cart a.button' + click_link 'Checkout now' complete_checkout @@ -196,11 +208,4 @@ feature "shopping with variant overrides defined", js: true do place_order page.should have_content "Your order has been processed successfully" end - - def click_checkout - show_cart - wait_until_enabled 'li.cart a.button' - click_link 'Checkout now', match: :first - end - end