From f7ba8cade0bc0bd629ecf8f4d8f505b7bc3d1661 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Tue, 24 Jun 2014 13:01:51 +1000 Subject: [PATCH 1/5] Bunch of minor bugfixes --- .../controllers/tabs/producers_controller.js.coffee | 3 ++- app/assets/javascripts/templates/partials/contact.html.haml | 5 +++-- app/views/home/_fat.html.haml | 2 +- app/views/json/partials/_hub.rabl | 6 ++++-- app/views/modals/_producer.html.haml | 5 +++-- app/views/shop/products/_master.html.haml | 4 ++-- app/views/shop/products/_variants.html.haml | 4 ++-- app/views/spree/orders/show.html.haml | 2 ++ 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/tabs/producers_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/tabs/producers_controller.js.coffee index 92cf8dedfc..6db73f7af3 100644 --- a/app/assets/javascripts/darkswarm/controllers/tabs/producers_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/tabs/producers_controller.js.coffee @@ -1,2 +1,3 @@ -Darkswarm.controller "ProducersTabCtrl", ($scope, CurrentHub) -> +Darkswarm.controller "ProducersTabCtrl", ($scope, CurrentHub, Enterprises) -> + # Injecting Enterprises so CurrentHub.producers is dereferenced $scope.CurrentHub = CurrentHub diff --git a/app/assets/javascripts/templates/partials/contact.html.haml b/app/assets/javascripts/templates/partials/contact.html.haml index 3a64615be1..8831a8436e 100644 --- a/app/assets/javascripts/templates/partials/contact.html.haml +++ b/app/assets/javascripts/templates/partials/contact.html.haml @@ -5,8 +5,9 @@ {{ enterprise.phone }} %p{"ng-if" => "enterprise.email"} - %a{"ng-href" => "mailto:{{enterprise.email | stripUrl}}", target: "_blank" } - {{ enterprise.email | stripUrl }} + %a{"ng-href" => "{{enterprise.email | stripUrl}}", target: "_blank", mailto: true} + %span.email + {{ enterprise.email | stripUrl }} %p{"ng-if" => "enterprise.website"} %a{"ng-href" => "http://{{enterprise.website | stripUrl}}", target: "_blank" } diff --git a/app/views/home/_fat.html.haml b/app/views/home/_fat.html.haml index f9c0db6810..15bff714f4 100644 --- a/app/views/home/_fat.html.haml +++ b/app/views/home/_fat.html.haml @@ -30,7 +30,7 @@ %li{"ng-repeat" => "enterprise in hub.producers"} = render partial: "modals/producer" -.row.active_table_row.link{"ng-show" => "open()", "bo-if" => "hub.active"} +.row.active_table_row.link{"ng-show" => "open()"} .cta-container.columns.small-12 .row .columns.small-12 diff --git a/app/views/json/partials/_hub.rabl b/app/views/json/partials/_hub.rabl index 2df71001cb..ed9520b43e 100644 --- a/app/views/json/partials/_hub.rabl +++ b/app/views/json/partials/_hub.rabl @@ -13,8 +13,10 @@ end node :delivery do |hub| hub.shipping_methods.where(:require_ship_address => true).present? end -node :active do |hub| - @active_distributors.include?(hub) +if @active_distributors + node :active do |hub| + @active_distributors.include?(hub) + end end node :orders_close_at do |hub| OrderCycle.first_closing_for(hub).andand.orders_close_at diff --git a/app/views/modals/_producer.html.haml b/app/views/modals/_producer.html.haml index 044cf3cdf0..6f8d8951f1 100644 --- a/app/views/modals/_producer.html.haml +++ b/app/views/modals/_producer.html.haml @@ -23,8 +23,9 @@ {{ enterprise.phone }} %p{"bo-if" => "enterprise.email"} - %a{"ng-href" => "mailto:{{enterprise.email | stripUrl}}", target: "_blank" } - {{ enterprise.email | stripUrl }} + %a{"ng-href" => "{{enterprise.email | stripUrl}}", target: "_blank", mailto: true } + %span.email + {{ enterprise.email | stripUrl }} %p{"bo-show" => "enterprise.website"} %a{"ng-href" => "http://{{enterprise.website}}", target: "_blank" } diff --git a/app/views/shop/products/_master.html.haml b/app/views/shop/products/_master.html.haml index c06acb5cb1..4c00365f71 100644 --- a/app/views/shop/products/_master.html.haml +++ b/app/views/shop/products/_master.html.haml @@ -15,7 +15,7 @@ name: "variants[{{product.master.id}}]", id: "variants_{{product.master.id}}", "ng-model" => "product.quantity"} - %small {{ product.master.unit_to_display }} + %small x {{ product.master.unit_to_display }} -# WITH GROUP BUY .small-2.columns{"bo-if" => "product.group_buy"} @@ -36,7 +36,7 @@ max: "{{product.on_demand && 9999 || product.count_on_hand }}", name: "variant_attributes[{{product.master.id}}][max_quantity]", "ng-model" => "product.max_quantity"} - {{ product.master.unit_to_display }} + %small x {{ product.master.unit_to_display }} .small-2.columns.text-right {{ product.price | currency }} diff --git a/app/views/shop/products/_variants.html.haml b/app/views/shop/products/_variants.html.haml index 9faaa5e8b1..fed7753ff3 100644 --- a/app/views/shop/products/_variants.html.haml +++ b/app/views/shop/products/_variants.html.haml @@ -18,7 +18,7 @@ max: "{{variant.on_demand && 9999 || variant.count_on_hand }}", name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}", "bo-model" => "variant.quantity"} - %small {{ variant.unit_to_display }} + %small x {{ variant.unit_to_display }} -# WITH GROUP BUY .small-2.columns{"bo-if" => "product.group_buy"} @@ -39,7 +39,7 @@ max: "{{variant.on_demand && 9999 || variant.count_on_hand }}", name: "variant_attributes[{{variant.id}}][max_quantity]", "ng-model" => "variant.max_quantity"} - %small {{ variant.unit_to_display }} + %small x {{ variant.unit_to_display }} .small-2.columns.text-right.price {{ variant.price | currency }} diff --git a/app/views/spree/orders/show.html.haml b/app/views/spree/orders/show.html.haml index f0fe766696..1f020f8c1f 100644 --- a/app/views/spree/orders/show.html.haml +++ b/app/views/spree/orders/show.html.haml @@ -1,3 +1,5 @@ += inject_enterprises + .darkswarm - content_for :order_cycle_form do %strong.avenir From 11872931a5f1ae841660cac75dfad07ef38f1b4e Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Tue, 24 Jun 2014 13:01:51 +1000 Subject: [PATCH 2/5] Bunch of minor bugfixes --- .../controllers/tabs/producers_controller.js.coffee | 3 ++- app/assets/javascripts/templates/partials/contact.html.haml | 5 +++-- app/views/home/_fat.html.haml | 2 +- app/views/json/partials/_hub.rabl | 6 ++++-- app/views/modals/_producer.html.haml | 5 +++-- app/views/shop/products/_master.html.haml | 4 ++-- app/views/shop/products/_variants.html.haml | 4 ++-- app/views/spree/orders/show.html.haml | 2 ++ 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/tabs/producers_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/tabs/producers_controller.js.coffee index 92cf8dedfc..6db73f7af3 100644 --- a/app/assets/javascripts/darkswarm/controllers/tabs/producers_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/tabs/producers_controller.js.coffee @@ -1,2 +1,3 @@ -Darkswarm.controller "ProducersTabCtrl", ($scope, CurrentHub) -> +Darkswarm.controller "ProducersTabCtrl", ($scope, CurrentHub, Enterprises) -> + # Injecting Enterprises so CurrentHub.producers is dereferenced $scope.CurrentHub = CurrentHub diff --git a/app/assets/javascripts/templates/partials/contact.html.haml b/app/assets/javascripts/templates/partials/contact.html.haml index 3a64615be1..8831a8436e 100644 --- a/app/assets/javascripts/templates/partials/contact.html.haml +++ b/app/assets/javascripts/templates/partials/contact.html.haml @@ -5,8 +5,9 @@ {{ enterprise.phone }} %p{"ng-if" => "enterprise.email"} - %a{"ng-href" => "mailto:{{enterprise.email | stripUrl}}", target: "_blank" } - {{ enterprise.email | stripUrl }} + %a{"ng-href" => "{{enterprise.email | stripUrl}}", target: "_blank", mailto: true} + %span.email + {{ enterprise.email | stripUrl }} %p{"ng-if" => "enterprise.website"} %a{"ng-href" => "http://{{enterprise.website | stripUrl}}", target: "_blank" } diff --git a/app/views/home/_fat.html.haml b/app/views/home/_fat.html.haml index f9c0db6810..15bff714f4 100644 --- a/app/views/home/_fat.html.haml +++ b/app/views/home/_fat.html.haml @@ -30,7 +30,7 @@ %li{"ng-repeat" => "enterprise in hub.producers"} = render partial: "modals/producer" -.row.active_table_row.link{"ng-show" => "open()", "bo-if" => "hub.active"} +.row.active_table_row.link{"ng-show" => "open()"} .cta-container.columns.small-12 .row .columns.small-12 diff --git a/app/views/json/partials/_hub.rabl b/app/views/json/partials/_hub.rabl index 2df71001cb..ed9520b43e 100644 --- a/app/views/json/partials/_hub.rabl +++ b/app/views/json/partials/_hub.rabl @@ -13,8 +13,10 @@ end node :delivery do |hub| hub.shipping_methods.where(:require_ship_address => true).present? end -node :active do |hub| - @active_distributors.include?(hub) +if @active_distributors + node :active do |hub| + @active_distributors.include?(hub) + end end node :orders_close_at do |hub| OrderCycle.first_closing_for(hub).andand.orders_close_at diff --git a/app/views/modals/_producer.html.haml b/app/views/modals/_producer.html.haml index 044cf3cdf0..6f8d8951f1 100644 --- a/app/views/modals/_producer.html.haml +++ b/app/views/modals/_producer.html.haml @@ -23,8 +23,9 @@ {{ enterprise.phone }} %p{"bo-if" => "enterprise.email"} - %a{"ng-href" => "mailto:{{enterprise.email | stripUrl}}", target: "_blank" } - {{ enterprise.email | stripUrl }} + %a{"ng-href" => "{{enterprise.email | stripUrl}}", target: "_blank", mailto: true } + %span.email + {{ enterprise.email | stripUrl }} %p{"bo-show" => "enterprise.website"} %a{"ng-href" => "http://{{enterprise.website}}", target: "_blank" } diff --git a/app/views/shop/products/_master.html.haml b/app/views/shop/products/_master.html.haml index c06acb5cb1..4c00365f71 100644 --- a/app/views/shop/products/_master.html.haml +++ b/app/views/shop/products/_master.html.haml @@ -15,7 +15,7 @@ name: "variants[{{product.master.id}}]", id: "variants_{{product.master.id}}", "ng-model" => "product.quantity"} - %small {{ product.master.unit_to_display }} + %small x {{ product.master.unit_to_display }} -# WITH GROUP BUY .small-2.columns{"bo-if" => "product.group_buy"} @@ -36,7 +36,7 @@ max: "{{product.on_demand && 9999 || product.count_on_hand }}", name: "variant_attributes[{{product.master.id}}][max_quantity]", "ng-model" => "product.max_quantity"} - {{ product.master.unit_to_display }} + %small x {{ product.master.unit_to_display }} .small-2.columns.text-right {{ product.price | currency }} diff --git a/app/views/shop/products/_variants.html.haml b/app/views/shop/products/_variants.html.haml index 9faaa5e8b1..fed7753ff3 100644 --- a/app/views/shop/products/_variants.html.haml +++ b/app/views/shop/products/_variants.html.haml @@ -18,7 +18,7 @@ max: "{{variant.on_demand && 9999 || variant.count_on_hand }}", name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}", "bo-model" => "variant.quantity"} - %small {{ variant.unit_to_display }} + %small x {{ variant.unit_to_display }} -# WITH GROUP BUY .small-2.columns{"bo-if" => "product.group_buy"} @@ -39,7 +39,7 @@ max: "{{variant.on_demand && 9999 || variant.count_on_hand }}", name: "variant_attributes[{{variant.id}}][max_quantity]", "ng-model" => "variant.max_quantity"} - %small {{ variant.unit_to_display }} + %small x {{ variant.unit_to_display }} .small-2.columns.text-right.price {{ variant.price | currency }} diff --git a/app/views/spree/orders/show.html.haml b/app/views/spree/orders/show.html.haml index f0fe766696..1f020f8c1f 100644 --- a/app/views/spree/orders/show.html.haml +++ b/app/views/spree/orders/show.html.haml @@ -1,3 +1,5 @@ += inject_enterprises + .darkswarm - content_for :order_cycle_form do %strong.avenir From c0ac3c1b1439fa1e8b6cc27d7d6275239886e91d Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Tue, 24 Jun 2014 14:09:21 +1000 Subject: [PATCH 3/5] Tab fixes, new tests, reworking modals --- .../directives/producer_modal.js.coffee | 7 ++ .../templates/map_modal_hub.html.haml | 55 +---------- .../templates/map_modal_producer.html.haml | 41 +------- .../templates/partials/close.html.haml | 2 + .../partials/enterprise_details.html.haml | 10 ++ .../partials/enterprise_header.html.haml | 8 ++ .../templates/partials/hub_actions.html.haml | 15 +++ .../templates/partials/hub_details.html.haml | 26 +++++ .../templates/producer_modal.html.haml | 3 + app/views/home/_fat.html.haml | 2 +- app/views/shopping_shared/_contact.html.haml | 97 +++++++++---------- app/views/shopping_shared/_groups.html.haml | 15 +-- .../shopping_shared/_producers.html.haml | 3 +- spec/features/consumer/home_spec.rb | 11 +++ 14 files changed, 147 insertions(+), 148 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee create mode 100644 app/assets/javascripts/templates/partials/close.html.haml create mode 100644 app/assets/javascripts/templates/partials/enterprise_details.html.haml create mode 100644 app/assets/javascripts/templates/partials/enterprise_header.html.haml create mode 100644 app/assets/javascripts/templates/partials/hub_actions.html.haml create mode 100644 app/assets/javascripts/templates/partials/hub_details.html.haml create mode 100644 app/assets/javascripts/templates/producer_modal.html.haml diff --git a/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee b/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee new file mode 100644 index 0000000000..d64b2663f7 --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee @@ -0,0 +1,7 @@ +Darkswarm.directive "producerModal", ($modal)-> + restrict: 'E' + replace: true + template: "{{enterprise.name}}" + link: (scope, elem, attrs, ctrl)-> + elem.on "click", => + scope.modalInstance = $modal.open(controller: ctrl, templateUrl: 'producer_modal.html', scope: scope) diff --git a/app/assets/javascripts/templates/map_modal_hub.html.haml b/app/assets/javascripts/templates/map_modal_hub.html.haml index 79301798c4..6b13f6ee78 100644 --- a/app/assets/javascripts/templates/map_modal_hub.html.haml +++ b/app/assets/javascripts/templates/map_modal_hub.html.haml @@ -1,51 +1,4 @@ -.highlight - .highlight-top - %p.right - {{ [enterprise.address.city, enterprise.address.state] | printArray}} - %h3 - %i.ofn-i_040-hub - {{ enterprise.name }} - %img.hero-img{"ng-src" => "{{enterprise.promo_image}}"} - -.row{bindonce: true} - .small-12.large-8.columns - %div{"ng-if" => "enterprise.long_description.length > 0 || enterprise.logo"} - %h5.modal-header About - .about-container - %img.enterprise-logo{"bo-src" => "enterprise.logo", "bo-if" => "enterprise.logo"} - %p.text-small{"ng-bind-html" => "enterprise.long_description"} - .small-12.large-4.columns - %ng-include{src: "'partials/contact.html'"} - %ng-include{src: "'partials/follow.html'"} - -.row.pad-top{bindonce: true} - .cta-container.small-12.columns - .row - .small-12.large-6.columns - %h5 - %i.ofn-i_029-shopping-basket - %span{"active-table-hub-link" => "enterprise", change: "Change hub to", shop: "Shop at"} - .small-12.large-6.columns.right - / Needs logic to hide if nothing populated: - .right{"bo-if" => "enterprise.pickup || enterprise.delivery"} - Delivery options: - %span{"bo-if" => "enterprise.pickup"} - %i.ofn-i_038-takeaway - Pickup - %span{"bo-if" => "enterprise.delivery"} - %i.ofn-i_039-delivery - Delivery - .row - .columns.small-12 - %a.button.hub.expand{"bo-href" => "enterprise.path", - "ng-class" => "{primary: enterprise.active, secondary: !enterprise.active}", - "ofn-empties-cart" => "enterprise"} - %i.ofn-i_033-open-sign{"bo-if" => "enterprise.active"} - %i.ofn-i_032-closed-sign{"bo-if" => "!enterprise.active"} - {{enterprise.name}} - .button-address {{ enterprise.address.city }} , {{enterprise.address.state}} - %i.ofn-i_007-caret-right - -%a.close-reveal-modal.outside{"ng-click" => "$close()"} - %i.ofn-i_009-close - +%ng-include{src: "'partials/enterprise_header.html'"} +%ng-include{src: "'partials/enterprise_details.html'"} +%ng-include{src: "'partials/hub_details.html'"} +%ng-include{src: "'partials/close.html'"} diff --git a/app/assets/javascripts/templates/map_modal_producer.html.haml b/app/assets/javascripts/templates/map_modal_producer.html.haml index 23ae109b3e..dff26519d3 100644 --- a/app/assets/javascripts/templates/map_modal_producer.html.haml +++ b/app/assets/javascripts/templates/map_modal_producer.html.haml @@ -1,37 +1,4 @@ -.highlight - .highlight-top - %p.right - {{ [enterprise.address.city, enterprise.address.state] | printArray}} - %h3 - %i.ofn-i_036-producers - {{ enterprise.name }} - %img.hero-img{"ng-src" => "{{enterprise.promo_image}}"} - -.row{bindonce: true} - .small-12.large-8.columns - %div{"ng-if" => "enterprise.long_description.length > 0 || enterprise.logo"} - %h5.modal-header About - .about-container - %img.enterprise-logo{"bo-src" => "enterprise.logo", "bo-if" => "enterprise.logo"} - %p.text-small{"ng-bind-html" => "enterprise.long_description"} - .small-12.large-4.columns - %ng-include{src: "'partials/contact.html'"} - %ng-include{src: "'partials/follow.html'"} - -.row.pad-top{bindonce: true, "ng-if" => "enterprise.hubs.length > 0"} - .cta-container.small-12.columns - %h5 - %i.ofn-i_029-shopping-basket - Shop for {{enterprise.name}} products at: - %a.button.hub{"ng-repeat" => "hub in enterprise.hubs", - "bo-href" => "hub.path", - "bo-class" => "{primary: hub.active, secondary: !hub.active}", - "ofn-empties-cart" => "hub"} - %i.ofn-i_033-open-sign{"bo-if" => "hub.active"} - %i.ofn-i_032-closed-sign{"bo-if" => "!hub.active"} - {{hub.name}} - .button-address {{ hub.address.city }} , {{hub.address.state}} - %i.ofn-i_007-caret-right - -%a.close-reveal-modal.outside{"ng-click" => "$close()"} - %i.ofn-i_009-close +%ng-include{src: "'partials/enterprise_header.html'"} +%ng-include{src: "'partials/enterprise_details.html'"} +%ng-include{src: "'partials/hub_actions.html'"} +%ng-include{src: "'partials/close.html'"} diff --git a/app/assets/javascripts/templates/partials/close.html.haml b/app/assets/javascripts/templates/partials/close.html.haml new file mode 100644 index 0000000000..1facd8edeb --- /dev/null +++ b/app/assets/javascripts/templates/partials/close.html.haml @@ -0,0 +1,2 @@ +%a.close-reveal-modal.outside{"ng-click" => "$close()"} + %i.ofn-i_009-close diff --git a/app/assets/javascripts/templates/partials/enterprise_details.html.haml b/app/assets/javascripts/templates/partials/enterprise_details.html.haml new file mode 100644 index 0000000000..2f88fe51f3 --- /dev/null +++ b/app/assets/javascripts/templates/partials/enterprise_details.html.haml @@ -0,0 +1,10 @@ +.row{bindonce: true} + .small-12.large-8.columns + %div{"ng-if" => "enterprise.long_description.length > 0 || enterprise.logo"} + %h5.modal-header About + .about-container + %img.enterprise-logo{"bo-src" => "enterprise.logo", "bo-if" => "enterprise.logo"} + %p.text-small{"ng-bind-html" => "enterprise.long_description"} + .small-12.large-4.columns + %ng-include{src: "'partials/contact.html'"} + %ng-include{src: "'partials/follow.html'"} diff --git a/app/assets/javascripts/templates/partials/enterprise_header.html.haml b/app/assets/javascripts/templates/partials/enterprise_header.html.haml new file mode 100644 index 0000000000..2e7da13794 --- /dev/null +++ b/app/assets/javascripts/templates/partials/enterprise_header.html.haml @@ -0,0 +1,8 @@ +.highlight + .highlight-top + %p.right + {{ [enterprise.address.city, enterprise.address.state] | printArray}} + %h3 + %i.ofn-i_036-producers + {{ enterprise.name }} + %img.hero-img{"ng-src" => "{{enterprise.promo_image}}"} diff --git a/app/assets/javascripts/templates/partials/hub_actions.html.haml b/app/assets/javascripts/templates/partials/hub_actions.html.haml new file mode 100644 index 0000000000..499f4f7ec8 --- /dev/null +++ b/app/assets/javascripts/templates/partials/hub_actions.html.haml @@ -0,0 +1,15 @@ +.row.pad-top{bindonce: true, "ng-if" => "enterprise.hubs.length > 0"} + .cta-container.small-12.columns + %h5 + %i.ofn-i_029-shopping-basket + Shop for {{enterprise.name}} products at: + %a.button.hub{"ng-repeat" => "hub in enterprise.hubs", + "bo-href" => "hub.path", + "bo-class" => "{primary: hub.active, secondary: !hub.active}", + "ofn-empties-cart" => "hub"} + %i.ofn-i_033-open-sign{"bo-if" => "hub.active"} + %i.ofn-i_032-closed-sign{"bo-if" => "!hub.active"} + {{hub.name}} + .button-address {{ hub.address.city }} , {{hub.address.state}} + %i.ofn-i_007-caret-right + diff --git a/app/assets/javascripts/templates/partials/hub_details.html.haml b/app/assets/javascripts/templates/partials/hub_details.html.haml new file mode 100644 index 0000000000..b3de842a3f --- /dev/null +++ b/app/assets/javascripts/templates/partials/hub_details.html.haml @@ -0,0 +1,26 @@ +.row.pad-top{bindonce: true} + .cta-container.small-12.columns + .row + .small-12.large-6.columns + %h5 + %i.ofn-i_029-shopping-basket + %span{"active-table-hub-link" => "enterprise", change: "Change hub to", shop: "Shop at"} + .small-12.large-6.columns.right + .right{"bo-if" => "enterprise.pickup || enterprise.delivery"} + Delivery options: + %span{"bo-if" => "enterprise.pickup"} + %i.ofn-i_038-takeaway + Pickup + %span{"bo-if" => "enterprise.delivery"} + %i.ofn-i_039-delivery + Delivery + .row + .columns.small-12 + %a.button.hub.expand{"bo-href" => "enterprise.path", + "ng-class" => "{primary: enterprise.active, secondary: !enterprise.active}", + "ofn-empties-cart" => "enterprise"} + %i.ofn-i_033-open-sign{"bo-if" => "enterprise.active"} + %i.ofn-i_032-closed-sign{"bo-if" => "!enterprise.active"} + {{enterprise.name}} + .button-address {{ enterprise.address.city }} , {{enterprise.address.state}} + %i.ofn-i_007-caret-right diff --git a/app/assets/javascripts/templates/producer_modal.html.haml b/app/assets/javascripts/templates/producer_modal.html.haml new file mode 100644 index 0000000000..db6f927e21 --- /dev/null +++ b/app/assets/javascripts/templates/producer_modal.html.haml @@ -0,0 +1,3 @@ +%ng-include{src: "'partials/enterprise_header.html'"} +%ng-include{src: "'partials/enterprise_details.html'"} +%ng-include{src: "'partials/close.html'"} diff --git a/app/views/home/_fat.html.haml b/app/views/home/_fat.html.haml index 15bff714f4..8de0524ea3 100644 --- a/app/views/home/_fat.html.haml +++ b/app/views/home/_fat.html.haml @@ -28,7 +28,7 @@ Our producers %ul.bullet-list %li{"ng-repeat" => "enterprise in hub.producers"} - = render partial: "modals/producer" + %producer-modal .row.active_table_row.link{"ng-show" => "open()"} .cta-container.columns.small-12 diff --git a/app/views/shopping_shared/_contact.html.haml b/app/views/shopping_shared/_contact.html.haml index 192b8a2422..f5ffd2e991 100644 --- a/app/views/shopping_shared/_contact.html.haml +++ b/app/views/shopping_shared/_contact.html.haml @@ -4,61 +4,58 @@ .panel .row .small-12.large-4.columns - / Will this is the logic - if all the things are blank, don't display - / {"ng-if" => "current_distributor.address.address1 || current_distributor.address.address2 || current_distributor.address.city || current_distributor.address.state || current_distributor.address.zipcode"} - %div.modal-centered - %h5.modal-header=current_distributor.name - %p - = current_distributor.address.address1 - - unless current_distributor.address.address2.blank? + - if current_distributor.address.address1 || current_distributor.address.address2 || current_distributor.address.city || current_distributor.address.state || current_distributor.address.zipcode + %div.modal-centered + %h5.modal-header=current_distributor.name + %p + = current_distributor.address.address1 + - unless current_distributor.address.address2.blank? + %br + = current_distributor.address.address2 %br - = current_distributor.address.address2 - %br - = current_distributor.address.city - = current_distributor.address.state - = current_distributor.address.zipcode + = current_distributor.address.city + = current_distributor.address.state + = current_distributor.address.zipcode .small-12.large-4.columns - / Will this is the logic - if all the things are blank, don't display - / {"ng-if" => "current_distributor.website || current_distributor.email"} - %div.modal-centered - %h5.modal-header Contact - - unless current_distributor.website.blank? - %p - %a{href: "http://#{current_distributor.website}", target: "_blank" } - = current_distributor.website - - unless current_distributor.email.blank? - %p - %a{href: current_distributor.email.reverse, mailto: true} - %span.email - = current_distributor.email.reverse + - if current_distributor.website || current_distributor.email + %div.modal-centered + %h5.modal-header Contact + - unless current_distributor.website.blank? + %p + %a{href: "http://#{current_distributor.website}", target: "_blank" } + = current_distributor.website + - unless current_distributor.email.blank? + %p + %a{href: current_distributor.email.reverse, mailto: true} + %span.email + = current_distributor.email.reverse .small-12.large-4.columns - / Will this is the logic - if all the things are blank, don't display - / {"ng-if" => "current_distributor.twitter || current_distributor.facebook || current_distributor.linkedin || current_distributor.instagram"} - %div.modal-centered - %h5.modal-header Follow - %div.follow-icons - - unless current_distributor.twitter.blank? - %span - %a{href: "http://twitter.com/#{current_distributor.twitter}", target: "_blank" } - %i.ofn-i_041-twitter - = current_distributor.facebook + - if current_distributor.twitter.present? || current_distributor.facebook.present? || current_distributor.linkedin.present? || current_distributor.instagram.present? + %div.modal-centered + %h5.modal-header Follow + %div.follow-icons + - unless current_distributor.twitter.blank? + %span + %a{href: "http://twitter.com/#{current_distributor.twitter}", target: "_blank" } + %i.ofn-i_041-twitter + = current_distributor.facebook - - unless current_distributor.facebook.blank? - %span - %a{href: "http://#{current_distributor.facebook}", target: "_blank" } - %i.ofn-i_044-facebook - = current_distributor.facebook + - unless current_distributor.facebook.blank? + %span + %a{href: "http://#{current_distributor.facebook}", target: "_blank" } + %i.ofn-i_044-facebook + = current_distributor.facebook - - unless current_distributor.linkedin.blank? - %span - %a{href: "http://#{current_distributor.linkedin}", target: "_blank" } - %i.ofn-i_042-linkedin - = current_distributor.linkedin + - unless current_distributor.linkedin.blank? + %span + %a{href: "http://#{current_distributor.linkedin}", target: "_blank" } + %i.ofn-i_042-linkedin + = current_distributor.linkedin - - unless current_distributor.instagram.blank? - %span - %a{href: "http://instagram.com.#{current_distributor.instagram}", target: "_blank" } - %i.ofn-i_043-instagram - = current_distributor.instagram + - unless current_distributor.instagram.blank? + %span + %a{href: "http://instagram.com.#{current_distributor.instagram}", target: "_blank" } + %i.ofn-i_043-instagram + = current_distributor.instagram diff --git a/app/views/shopping_shared/_groups.html.haml b/app/views/shopping_shared/_groups.html.haml index 138c2da5d8..19c0912ec6 100644 --- a/app/views/shopping_shared/_groups.html.haml +++ b/app/views/shopping_shared/_groups.html.haml @@ -1,10 +1,11 @@ .content .row .small-12.columns.panel - %h5 - =current_distributor.name - is part of: - %ul.bullet-list - - for group in current_distributor.groups - %li - %a{href: main_app.groups_path(anchor: "#/#group#{group.id}")}= group.name + - if current_distributor.groups.length > 0 + %h5 + =current_distributor.name + is part of: + %ul.bullet-list + - for group in current_distributor.groups + %li + %a{href: main_app.groups_path(anchor: "#/#group#{group.id}")}= group.name diff --git a/app/views/shopping_shared/_producers.html.haml b/app/views/shopping_shared/_producers.html.haml index 7ee26d7410..4c34ae917d 100644 --- a/app/views/shopping_shared/_producers.html.haml +++ b/app/views/shopping_shared/_producers.html.haml @@ -2,8 +2,7 @@ .row .small-12.columns.panel %h5 - Our producers: - / = "#{current_distributor.name}'s producers:" + {{CurrentHub.hub.name}}'s producers: %ul.bullet-list %li{"ng-repeat" => "enterprise in CurrentHub.hub.producers"} = render partial: "modals/producer" diff --git a/spec/features/consumer/home_spec.rb b/spec/features/consumer/home_spec.rb index 1b28af1489..d8d3d0a3e7 100644 --- a/spec/features/consumer/home_spec.rb +++ b/spec/features/consumer/home_spec.rb @@ -8,6 +8,8 @@ feature 'Home', js: true do let(:d1) { create(:distributor_enterprise) } let(:d2) { create(:distributor_enterprise) } let!(:order_cycle) { create(:order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) } + let!(:producer) { create(:supplier_enterprise) } + let!(:er) { create(:enterprise_relationship, parent: distributor, child: producer) } before do visit "/" @@ -30,4 +32,13 @@ feature 'Home', js: true do follow_active_table_node distributor.name current_path.should == "/shop" end + + it "should show hub producer modals" do + expand_active_table_node distributor.name + page.should have_content producer.name + find("a", text: producer.name).click + within ".reveal-modal" do + page.should have_content producer.name + end + end end From a9ce36d4025698793c98c999d9aaa26b7eea6c60 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Tue, 24 Jun 2014 14:15:15 +1000 Subject: [PATCH 4/5] Minor regression bug --- spec/features/consumer/shopping/shopping_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index e219e970a2..e75f7f6f21 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -196,7 +196,7 @@ feature "As a consumer I want to shop with a distributor", js: true do context "when no order cycles are available" do it "tells us orders are closed" do visit shop_path - page.should have_content "Orders are currently closed for this hub" + page.should have_content "Orders are closed" end it "shows the last order cycle" do oc1 = create(:simple_order_cycle, distributors: [distributor], orders_close_at: 10.days.ago) From 64cca8cf364bb6e3201a448e955fce8647051f59 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Tue, 24 Jun 2014 16:01:06 +1000 Subject: [PATCH 5/5] Enabling map on production --- config/routes.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index b151e4bae8..d166116086 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,11 +3,7 @@ Openfoodnetwork::Application.routes.draw do get "/#/login", to: "home#index", as: :spree_login - if Rails.env.production? - get "/map", to: "home#index", as: :map - else - get "/map", to: "map#index", as: :map - end + get "/map", to: "map#index", as: :map resource :shop, controller: "shop" do get :products