mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Starting to build out producers Angular page
This commit is contained in:
@@ -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()
|
||||
@@ -0,0 +1,2 @@
|
||||
Darkswarm.controller "ProducersCtrl", ($scope, Producers) ->
|
||||
$scope.Producers = Producers
|
||||
@@ -0,0 +1,4 @@
|
||||
Darkswarm.factory 'Producers', (producers) ->
|
||||
new class Producers
|
||||
constructor: ->
|
||||
@producers = producers
|
||||
@@ -1,4 +1,7 @@
|
||||
class ProducersController < BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
def index
|
||||
@producers = Enterprise.is_primary_producer.visible
|
||||
end
|
||||
end
|
||||
|
||||
6
app/views/json/_producers.rabl
Normal file
6
app/views/json/_producers.rabl
Normal file
@@ -0,0 +1,6 @@
|
||||
collection @producers
|
||||
attributes :name, :id
|
||||
|
||||
node :path do |producer|
|
||||
producer_path(producer)
|
||||
end
|
||||
16
app/views/producers/_fat.html.haml
Normal file
16
app/views/producers/_fat.html.haml
Normal 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
|
||||
9
app/views/producers/_skinny.html.haml
Normal file
9
app/views/producers/_skinny.html.haml
Normal 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()}"}
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user