Starting to build out producers Angular page

This commit is contained in:
Will Marshall
2014-04-30 12:52:47 +10:00
parent e7d6e7e564
commit 0f6bd7049c
10 changed files with 67 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
Darkswarm.controller "ProducerNodeCtrl", ($scope, Navigation, $location, $anchorScroll) ->
$scope.toggle = ->
Navigation.navigate $scope.producer.path
$scope.open = ->
$location.path() == $scope.producer.path
if $scope.open()
$anchorScroll()

View File

@@ -0,0 +1,2 @@
Darkswarm.controller "ProducersCtrl", ($scope, Producers) ->
$scope.Producers = Producers

View File

@@ -0,0 +1,4 @@
Darkswarm.factory 'Producers', (producers) ->
new class Producers
constructor: ->
@producers = producers

View File

@@ -1,4 +1,7 @@
class ProducersController < BaseController
layout 'darkswarm'
def index
@producers = Enterprise.is_primary_producer.visible
end
end

View File

@@ -0,0 +1,6 @@
collection @producers
attributes :name, :id
node :path do |producer|
producer_path(producer)
end

View File

@@ -0,0 +1,16 @@
.row.active_table_row{"ng-show" => "open()"}
.columns.small-4
%strong Shop for
%p.trans-sentence
{{ producer.taxons | printArray }}
.columns.small-8
About Us
.row.active_table_row.link{"ng-show" => "open()", "ng-repeat" => "hub in producer.hubs"}
.columns.small-11
%a{"bo-href" => "hub.path"}
Shop at
%strong {{ hub.name }}
.columns.small-1.text-right
%a{"bo-href" => "hub.path"}
%i.fi-arrow-right

View File

@@ -0,0 +1,9 @@
.row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open()}"}
.columns.small-4
%strong {{ producer.name }}
.columns.small-3
{{ producer.address.city }}
.columns.small-4
{{ producer.address.state | uppercase }}
.columns.small-1.text-right
%i{"ng-class" => "{'fi-arrow-down' : !open(), 'fi-arrow-up' : open()}"}

View File

@@ -0,0 +1,15 @@
.producers{"ng-controller" => "ProducersCtrl"}
:javascript
angular.module('Darkswarm').value('producers', #{render partial: "json/producers", object: @producers})
.row{bindonce: true}
.small-12.columns
.active_table
%producer.active_table_node.row{id: "{{producer.path}}",
"ng-repeat" => "producer in Producers.producers",
"ng-controller" => "ProducerNodeCtrl",
"ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !producer.active}"}
.small-12.columns
= render partial: 'producers/skinny'
= render partial: 'producers/fat'

View File

@@ -7,7 +7,7 @@ Openfoodnetwork::Application.routes.draw do
get :order_cycle
end
resources :producers, only: :index
resources :producers
namespace :shop do
get '/checkout', :to => 'checkout#edit' , :as => :checkout

View File

@@ -2,7 +2,8 @@ require 'spec_helper'
describe ProducersController do
it "gets all active producers" do
Enterprise.stub_chain(:active)
Enterprise.stub_chain(:is_primary_producer, :visible)
Enterprise.should_receive(:is_primary_producer)
get :index
end
end