From f54834da01a98de8c0ef7643ba941f473b359fb2 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Tue, 17 Jun 2014 16:33:43 +1000 Subject: [PATCH] Changing our composition of producers and hubs --- .../darkswarm/services/map_modal.js.coffee | 3 +- .../darkswarm/services/producers.js.coffee | 8 +++ .../templates/authentication.html.haml | 2 +- .../templates/map_modal_producer.html.haml | 66 +++++++------------ .../templates/partials/contact.html.haml | 16 +++++ .../templates/partials/follow.html.haml | 20 ++++++ app/views/json/_enterprises.rabl | 4 ++ app/views/json/_enterprises_for_map.rabl | 8 +++ app/views/json/partials/_address.rabl | 2 +- 9 files changed, 84 insertions(+), 45 deletions(-) create mode 100644 app/assets/javascripts/templates/partials/contact.html.haml create mode 100644 app/assets/javascripts/templates/partials/follow.html.haml diff --git a/app/assets/javascripts/darkswarm/services/map_modal.js.coffee b/app/assets/javascripts/darkswarm/services/map_modal.js.coffee index d26384cc48..f5c8d3d065 100644 --- a/app/assets/javascripts/darkswarm/services/map_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/services/map_modal.js.coffee @@ -2,8 +2,9 @@ Darkswarm.factory "MapModal", ($modal, $rootScope)-> new class MapModal open: (enterprise)-> scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise - scope.enterprise = enterprise if enterprise['is_primary_producer?'] + scope.producer = enterprise $modal.open(templateUrl: "map_modal_producer.html", scope: scope) else + scope.hub = enterprise $modal.open(templateUrl: "map_modal_hub.html", scope: scope) diff --git a/app/assets/javascripts/darkswarm/services/producers.js.coffee b/app/assets/javascripts/darkswarm/services/producers.js.coffee index 62a5087642..6c393660de 100644 --- a/app/assets/javascripts/darkswarm/services/producers.js.coffee +++ b/app/assets/javascripts/darkswarm/services/producers.js.coffee @@ -2,3 +2,11 @@ Darkswarm.factory 'Producers', (producers) -> new class Producers constructor: -> @producers = producers + + # TODO: start adding functionality to producers like so + #@producers = (@extend(producer) for producer in producers) + + #extend: (producer)-> + #new class Producer + #constructor: -> + #@[k] = v for k, v of Producer diff --git a/app/assets/javascripts/templates/authentication.html.haml b/app/assets/javascripts/templates/authentication.html.haml index 3f219240e6..db1b5ecd7d 100644 --- a/app/assets/javascripts/templates/authentication.html.haml +++ b/app/assets/javascripts/templates/authentication.html.haml @@ -4,4 +4,4 @@ %ng-include{src: "'signup.html'"} %ng-include{src: "'forgot.html'"} %a.close-reveal-modal{"ng-click" => "$close()"} - %i.ofn-i_009-close \ No newline at end of file + %i.ofn-i_009-close diff --git a/app/assets/javascripts/templates/map_modal_producer.html.haml b/app/assets/javascripts/templates/map_modal_producer.html.haml index 54c834253a..d09eb3e7f6 100644 --- a/app/assets/javascripts/templates/map_modal_producer.html.haml +++ b/app/assets/javascripts/templates/map_modal_producer.html.haml @@ -2,48 +2,30 @@ .small-12.columns.producer-hero %h3.producer-name %i.ofn-i_036-producers - {{ enterprise.name }} - {{ enterprise.id }} - %img.producer-hero-img{"ng-src" => "{{enterprise.promo_image}}"} + {{ producer.name }} + %img.producer-hero-img{"ng-src" => "{{producer.promo_image}}"} -.row +.row{bindonce: true} .small-12.large-6.columns - %p{"ng-bind-html" => "enterprise.long_description"} - .small-12.large-6.columns - %img.producer-logo{"ng-src" => "{{enterprise.logo}}", "ng-if" => "enterprise.logo"} - %h5 Stay in touch with {{ enterprise.name }} - - %ul.small-block-grid-1{bindonce: true} - - %li{"ng-if" => "enterprise.website"} - %a{"ng-href" => "http://{{enterprise.website | stripUrl}}", target: "_blank" } - %i.ofn-i_049-web - {{ enterprise.website | stripUrl }} - - %li{"ng-if" => "enterprise.email"} - %a{"ng-href" => "mailto:{{enterprise.email | stripUrl}}", target: "_blank" } - %i.ofn-i_050-mail-circle - {{ enterprise.email | stripUrl }} - - %li{"ng-if" => "enterprise.twitter"} - %a{"ng-href" => "http://twitter.com/{{enterprise.twitter}}", target: "_blank"} - %i.ofn-i_041-twitter - {{ enterprise.twitter }} - - %li{"ng-if" => "enterprise.facebook"} - %a{"ng-href" => "http://{{enterprise.facebook | stripUrl}}", target: "_blank"} - %i.ofn-i_044-facebook - {{ enterprise.facebook | stripUrl }} - - %li{"ng-if" => "enterprise.linkedin"} - %a{"ng-href" => "http://{{enterprise.linkedin | stripUrl}}", target: "_blank"} - %i.ofn-i_042-linkedin - {{ enterprise.linkedin | stripUrl }} - - %li{"ng-if" => "enterprise.instagram"} - %a{"ng-href" => "http://instagram.com/{{enterprise.instagram}}", target: "_blank"} - %i.ofn-i_043-instagram - {{ enterprise.instagram }} + %img.producer-logo{"bo-src" => "producer.logo", "bo-if" => "producer.logo"} + %p{"ng-bind-html" => "producer.long_description"} - %a.close-reveal-modal{"ng-click" => "$close()"} - %i.ofn-i_009-close + .small-12.large-6.columns + + %ng-include{src: "'partials/contact.html'"} + %ng-include{src: "'partials/follow.html'"} + +.row{bindonce: true} + .hubs + %h4 Shop for {{producer.name}} products at: + %a.hub{"ng-repeat" => "hub in producer.hubs", + "bo-href" => "hub.path", + "bo-class" => "{active: hub.active, inactive: !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}} + ( {{ hub.address.city }} , {{hub.address.state}} ) + +%a.close-reveal-modal{"ng-click" => "$close()"} + %i.ofn-i_009-close diff --git a/app/assets/javascripts/templates/partials/contact.html.haml b/app/assets/javascripts/templates/partials/contact.html.haml new file mode 100644 index 0000000000..3dc3dd028c --- /dev/null +++ b/app/assets/javascripts/templates/partials/contact.html.haml @@ -0,0 +1,16 @@ +%div{"bo-if" => "producer.email || producer.website || producer.address.phone"} + %h3 Contact + + %p{"bo-if" => "producer.email"} + %a{"ng-href" => "mailto:{{producer.email | stripUrl}}", target: "_blank" } + %i.ofn-i_050-mail-circle + {{ producer.email | stripUrl }} + + %p{"ng-if" => "producer.address.phone"} + WE NEED A PHONE ICON + {{ producer.address.phone }} + + %p{"ng-if" => "producer.website"} + %a{"ng-href" => "http://{{producer.website | stripUrl}}", target: "_blank" } + %i.ofn-i_049-web + {{ producer.website | stripUrl }} diff --git a/app/assets/javascripts/templates/partials/follow.html.haml b/app/assets/javascripts/templates/partials/follow.html.haml new file mode 100644 index 0000000000..41a91022a9 --- /dev/null +++ b/app/assets/javascripts/templates/partials/follow.html.haml @@ -0,0 +1,20 @@ +%div{"bo-if" => "producer.twitter || producer.facebook || producer.linkedin || producer.instagram"} + %h3 Follow + + %ul.small-block-grid-1{bindonce: true} + %li{"ng-if" => "producer.twitter"} + %a{"ng-href" => "http://twitter.com/{{producer.twitter}}", target: "_blank"} + %i.ofn-i_041-twitter + + %li{"ng-if" => "producer.facebook"} + %a{"ng-href" => "http://{{producer.facebook | stripUrl}}", target: "_blank"} + %i.ofn-i_044-facebook + + %li{"ng-if" => "producer.linkedin"} + %a{"ng-href" => "http://{{producer.linkedin | stripUrl}}", target: "_blank"} + %i.ofn-i_042-linkedin + + %li{"ng-if" => "producer.instagram"} + %a{"ng-href" => "http://instagram.com/{{producer.instagram}}", target: "_blank"} + %i.ofn-i_043-instagram + diff --git a/app/views/json/_enterprises.rabl b/app/views/json/_enterprises.rabl index 2f2f82c944..733bf79e19 100644 --- a/app/views/json/_enterprises.rabl +++ b/app/views/json/_enterprises.rabl @@ -1,6 +1,10 @@ # DON'T USE DIRECTLY - for inheritance attributes :name, :id, :description +node :email do |enterprise| + enterprise.email.to_s.reverse +end + child :address do extends "json/partials/address" end diff --git a/app/views/json/_enterprises_for_map.rabl b/app/views/json/_enterprises_for_map.rabl index 4da6309abc..a2c6eb06ac 100644 --- a/app/views/json/_enterprises_for_map.rabl +++ b/app/views/json/_enterprises_for_map.rabl @@ -14,6 +14,14 @@ node :active do |enterprise| @active_distributors.include?(enterprise) end +child distributors: :hubs do + extends 'json/enterprises' + node :active do |hub| + @active_distributors.include?(hub) + end +end + + node :icon do |e| if e.is_primary_producer? and e.is_distributor? image_path "map-icon-both.svg" diff --git a/app/views/json/partials/_address.rabl b/app/views/json/partials/_address.rabl index b40bbc790b..04cc456a29 100644 --- a/app/views/json/partials/_address.rabl +++ b/app/views/json/partials/_address.rabl @@ -1,4 +1,4 @@ -attributes :city, :zipcode +attributes :city, :zipcode, :phone node :state do |address| address.state.abbr end