From 0140472fbc2240bd5dd73f62da876a836fc95434 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Wed, 21 May 2014 14:09:48 +1000 Subject: [PATCH] Adding working modals --- .../controllers/products/product_node_controller.js.coffee | 2 ++ app/assets/javascripts/darkswarm/directives/modal.js.coffee | 5 ++++- app/views/modals/_producer.html.haml | 5 ++--- .../products/_modal.html.haml => modals/_product.html.haml} | 2 ++ app/views/shop/products/_summary.html.haml | 5 ++--- 5 files changed, 12 insertions(+), 7 deletions(-) rename app/views/{shop/products/_modal.html.haml => modals/_product.html.haml} (73%) diff --git a/app/assets/javascripts/darkswarm/controllers/products/product_node_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/products/product_node_controller.js.coffee index 4ec316e65f..3e24f006ae 100644 --- a/app/assets/javascripts/darkswarm/controllers/products/product_node_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/products/product_node_controller.js.coffee @@ -6,4 +6,6 @@ Darkswarm.controller "ProductNodeCtrl", ($scope) -> else $scope.product.price + $scope.producer = $scope.product.supplier + $scope.hasVariants = $scope.product.variants.length > 0 diff --git a/app/assets/javascripts/darkswarm/directives/modal.js.coffee b/app/assets/javascripts/darkswarm/directives/modal.js.coffee index 73217b3812..6f62c7cb45 100644 --- a/app/assets/javascripts/darkswarm/directives/modal.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/modal.js.coffee @@ -8,7 +8,10 @@ Darkswarm.directive "ofnModal", ($modal)-> link: (scope, elem, attrs, ctrl, transclude)-> scope.title = attrs.title contents = null - transclude scope, (clone)-> + + # We're using an isolate scope, which is a child of the original scope + # We have to compile the transclude against the original scope, not the isolate + transclude scope.$parent, (clone)-> contents = clone elem.on "click", => diff --git a/app/views/modals/_producer.html.haml b/app/views/modals/_producer.html.haml index 691e9378d3..056f9e488f 100644 --- a/app/views/modals/_producer.html.haml +++ b/app/views/modals/_producer.html.haml @@ -1,10 +1,9 @@ %ofn-modal{title: "{{ producer.name }}"} - #producer_modal{bindonce: true} + #producer_modal .row .small-12.columns - %img{"bo-src" => "producer.promo_image"} + %img{"ng-src" => "producer.promo_image"} %h3 {{ producer.name }} - .row .small-6.columns %p diff --git a/app/views/shop/products/_modal.html.haml b/app/views/modals/_product.html.haml similarity index 73% rename from app/views/shop/products/_modal.html.haml rename to app/views/modals/_product.html.haml index 29a023704f..acca8f919b 100644 --- a/app/views/shop/products/_modal.html.haml +++ b/app/views/modals/_product.html.haml @@ -1,2 +1,4 @@ %ofn-modal{title: "{{product.name}}"} + + {{ product | json }} {{ product.description }} diff --git a/app/views/shop/products/_summary.html.haml b/app/views/shop/products/_summary.html.haml index 5e777a5dbb..e41c6ef440 100644 --- a/app/views/shop/products/_summary.html.haml +++ b/app/views/shop/products/_summary.html.haml @@ -6,11 +6,10 @@ %img{"bo-src" => "product.primary_taxon.icon", "ng-click" => "ordering.order = 'primary_taxon.name'", name: "{{product.primary_taxon.name}}"} - {{ product.name}} - -#= render partial: "shop/products/modal" + = render partial: "modals/product" .small-5.columns.summary-header - {{ product.supplier.name }} + = render partial: "modals/producer" .small-2.columns.summary-price.text-right.price %span{"ng-if" => "hasVariants"}