From 902eefa8bbfb651bd7f9833ddd556c967596a70a Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Mon, 7 Apr 2014 14:10:22 +1000 Subject: [PATCH] Patching one test and simplifying the modifications to order cycle tooltip --- .../controllers/order_cycle_controller.js.coffee | 15 ++++++++++----- .../javascripts/darkswarm/darkswarm.js.coffee | 4 +++- app/views/shop/shop/show.html.haml | 3 ++- spec/features/consumer/shopping/checkout_spec.rb | 4 ++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee index 3d8dc31fda..29e81ae861 100644 --- a/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee @@ -1,10 +1,15 @@ -Darkswarm.controller "OrderCycleCtrl", ($scope, $rootScope, OrderCycle, $tour) -> +Darkswarm.controller "OrderCycleCtrl", ($scope, $rootScope, OrderCycle, $timeout) -> $scope.order_cycle = OrderCycle.order_cycle $scope.OrderCycle = OrderCycle + $scope.changeOrderCycle = -> - $tour.end() OrderCycle.push_order_cycle() + $timeout -> + $("#order_cycle_id").trigger("closeTrigger") - if !OrderCycle.selected() - $tour.start() - + # Timeout forces this to be evaluated after everything is loaded + # This is a hack. We should probably write our own "popover" directive + # That takes an expression instead of a trigger, and binds to that + $timeout => + if !$scope.OrderCycle.selected() + $("#order_cycle_id").trigger("openTrigger") diff --git a/app/assets/javascripts/darkswarm/darkswarm.js.coffee b/app/assets/javascripts/darkswarm/darkswarm.js.coffee index bffcc780e3..3d4f3b804e 100644 --- a/app/assets/javascripts/darkswarm/darkswarm.js.coffee +++ b/app/assets/javascripts/darkswarm/darkswarm.js.coffee @@ -1,4 +1,6 @@ -window.Darkswarm = angular.module("Darkswarm", ["ngResource", "filters", 'mm.foundation']).config ($httpProvider) -> +window.Darkswarm = angular.module("Darkswarm", ["ngResource", "filters", 'mm.foundation']).config ($httpProvider, $tooltipProvider) -> $httpProvider.defaults.headers.post['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content') $httpProvider.defaults.headers['common']['X-Requested-With'] = 'XMLHttpRequest' $httpProvider.defaults.headers.common.Accept = "application/json, text/javascript, */*" + + $tooltipProvider.setTriggers( 'openTrigger': 'closeTrigger' ) diff --git a/app/views/shop/shop/show.html.haml b/app/views/shop/shop/show.html.haml index 62d25b9670..f8380c6c39 100644 --- a/app/views/shop/shop/show.html.haml +++ b/app/views/shop/shop/show.html.haml @@ -5,11 +5,12 @@ %select.avenir#order_cycle_id{"ng-model" => "order_cycle.order_cycle_id", "ng-change" => "changeOrderCycle()", "ng-options" => "oc.id as oc.time for oc in #{@order_cycles.map {|oc| {time: pickup_time(oc), id: oc.id}}.to_json}", - step: "Please select an order cycle", "step-index" => "1","step-placement" => "bottom", "step-append-to-body" => "true"} + "popover-placement" => "bottom", "popover" => "testy", "popover-trigger" => "openTrigger"} %closing{"ng-if" => "OrderCycle.selected()"} Orders close %strong {{ OrderCycle.orders_close_at() | date_in_words }} + = render partial: "shop/details" %products.row diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index d7507189b9..7cf28675e1 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -112,7 +112,7 @@ feature "As a consumer I want to check out my cart", js: true do within "#details" do fill_in "First Name", with: "Will" fill_in "Last Name", with: "Marshall" - fill_in "Billing Address", with: "123 Your Face" + fill_in "Address", with: "123 Your Face" select "Australia", from: "Country" select "Victoria", from: "State" fill_in "Customer E-Mail", with: "test@test.com" @@ -130,7 +130,7 @@ feature "As a consumer I want to check out my cart", js: true do within "#details" do fill_in "First Name", with: "Will" fill_in "Last Name", with: "Marshall" - fill_in "Billing Address", with: "123 Your Face" + fill_in "Address", with: "123 Your Face" select "Australia", from: "Country" select "Victoria", from: "State" fill_in "Customer E-Mail", with: "test@test.com"