Cleaning up handling of the page when no order cycle is selected

This commit is contained in:
Will Marshall
2014-01-22 14:25:41 +11:00
parent 7737a5da1d
commit 803f653d39
5 changed files with 21 additions and 19 deletions

View File

@@ -1,13 +1,4 @@
angular.module("Shop").controller "ProductsCtrl", ($scope, $rootScope, Product) ->
angular.module("Shop").controller "ProductsCtrl", ($scope, $rootScope, Product, OrderCycle) ->
$scope.data = Product.data
$scope.order_cycle = OrderCycle.order_cycle
Product.update()
#$scope.order_cycle = OrderCycle.order_cycle
#$scope.updateProducts = ->
#$scope.products = Product.all()
#$scope.$watch "order_cycle.order_cycle_id", $scope.updateProducts
#$scope.updateProducts()

View File

@@ -20,7 +20,6 @@
"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}"}
%closing
-#%img{src: "/icon/goes/here"}
Orders close

View File

@@ -1,4 +1,5 @@
%products{"ng-controller" => "ProductsCtrl"}
%products{"ng-controller" => "ProductsCtrl", "ng-show" => "order_cycle.order_cycle_id != null"}
%h5 Check out when you have selected everything you want
= form_for :order, :url => populate_orders_path, html: {:class => "custom"} do
%input#search.text{"ng-model" => "query", placeholder: "Search"}
%input.button.right{type: :submit, value: "Check Out"}
@@ -22,7 +23,6 @@
%td
{{ product.master.options_text }}
%span{"ng-show" => "product.variants.length > 0"}
%img.collapse{src: "/assets/collapse.png",
"ng-show" => "product.show_variants",

View File

@@ -12,11 +12,11 @@
= render partial: "shop/order_cycles"
-#%description
%tabs
.row
.section-container.auto{"data-section" => "", "data-options" => "one_up: false"}
%section#about
%section#about{class: current_order_cycle ? nil : "active" }
%p.title.avenir{"data-section-title" => ""}
%a{href: "#about"} About Us
.content{"data-section-content" => ""}
@@ -43,9 +43,7 @@
.content{"data-section-content" => ""}
%p Contact
%products.row
%h5 Check out when you have selected everything you want
= render partial: "shop/products"
#footer
%section.row

View File

@@ -58,14 +58,28 @@ feature "As a consumer I want to shop with a distributor", js: true do
exchange.update_attribute :pickup_time, "frogs"
exchange = Exchange.find(oc2.exchanges.to_enterprises(distributor).outgoing.first.id)
exchange.update_attribute :pickup_time, "turtles"
visit shop_path
end
it "shows a select with all order cycles" do
visit shop_path
page.should have_selector "option", text: 'frogs'
page.should have_selector "option", text: 'turtles'
end
it "shows the About Us by default if no order cycle is selected" do
page.should have_content "Hello, world!"
end
it "doesn't show the table before an order cycle is selected" do
page.should_not have_button "Check Out"
end
it "shows the table after an order cycle is selected" do
select "frogs", :from => "order_cycle_id"
save_and_open_page
page.should have_button "Check Out"
end
describe "with products in our order cycle" do
let(:product) { create(:simple_product) }
before do