mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
Adding groups to this branch, also tidying up the shop stuff for Laura
This commit is contained in:
3
app/assets/javascripts/groups.js.coffee
Normal file
3
app/assets/javascripts/groups.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
3
app/assets/stylesheets/groups.css.scss
Normal file
3
app/assets/stylesheets/groups.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the groups controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
5
app/controllers/groups_controller.rb
Normal file
5
app/controllers/groups_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class GroupsController < ApplicationController
|
||||
def index
|
||||
@groups = EnterpriseGroup.on_front_page.by_position
|
||||
end
|
||||
end
|
||||
2
app/helpers/groups_helper.rb
Normal file
2
app/helpers/groups_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module GroupsHelper
|
||||
end
|
||||
0
app/views/groups/index.html.haml
Normal file
0
app/views/groups/index.html.haml
Normal file
@@ -12,7 +12,7 @@
|
||||
.row
|
||||
.small-12.columns
|
||||
.product_table{bindonce: true}
|
||||
%product.row{"ng-controller" => "ProductNodeCtrl",
|
||||
%product{"ng-controller" => "ProductNodeCtrl",
|
||||
"ng-repeat" => "product in data.products | filter:query | orderBy:ordering.order | limitTo: limit track by product.id"}
|
||||
|
||||
= render partial: "shop/products/summary"
|
||||
@@ -20,7 +20,7 @@
|
||||
%div{"bo-if" => "hasVariants"}
|
||||
= render partial: "shop/products/variants"
|
||||
|
||||
.row{"bo-if" => "!hasVariants"}
|
||||
.row.variant{"bo-if" => "!hasVariants"}
|
||||
= render partial: "shop/products/master"
|
||||
|
||||
%input.button.right{type: :submit, value: "Add to Cart"}
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
%span.bulk{"bo-if" => "product.group_buy"} bulk
|
||||
|
||||
|
||||
.small-5.columns
|
||||
{{ product.name }}
|
||||
.small-4.columns
|
||||
({{ product.master.options_text }})
|
||||
|
||||
|
||||
-# WITHOUT GROUP BUY
|
||||
.small-5.columns{"bo-if" => "!product.group_buy"}
|
||||
%input{type: :number,
|
||||
@@ -16,7 +14,6 @@
|
||||
name: "variants[{{product.master.id}}]",
|
||||
id: "variants_{{product.master.id}}",
|
||||
"ng-model" => "product.quantity"}
|
||||
{{ product.master.options_text }}
|
||||
|
||||
-# WITH GROUP BUY
|
||||
.small-2.columns{"bo-if" => "product.group_buy"}
|
||||
@@ -27,7 +24,6 @@
|
||||
name: "variants[{{product.master.id}}]",
|
||||
id: "variants_{{product.master.id}}",
|
||||
"ng-model" => "product.quantity"}
|
||||
{{ product.master.options_text }}
|
||||
(min)
|
||||
|
||||
.small-3.columns{"bo-if" => "product.group_buy"}
|
||||
@@ -39,5 +35,5 @@
|
||||
"ng-model" => "product.max_quantity"}
|
||||
(max)
|
||||
|
||||
.small-1.column
|
||||
.small-2.columns.text-right
|
||||
{{ product.price | currency }}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
.row
|
||||
.row.summary
|
||||
.small-1.column
|
||||
%img{"bo-src" => "product.master.images[0].small_url"}
|
||||
|
||||
.small-4.columns
|
||||
%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"
|
||||
|
||||
.small-5.columns
|
||||
= render partial: "shop/products/modal"
|
||||
.small-4.columns
|
||||
{{ product.supplier.name }}
|
||||
.small-1.columns
|
||||
|
||||
.small-2.columns.text-right
|
||||
%span{"ng-if" => "hasVariants"} from
|
||||
{{ price() | currency }}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
.row{bindonce: true,
|
||||
"ng-repeat" => "variant in product.variants"}
|
||||
|
||||
.small-1.column
|
||||
%span.bulk{"bo-if" => "product.group_buy"} bulk
|
||||
|
||||
|
||||
.small-5.columns
|
||||
.small-4.columns
|
||||
{{ variant.options_text }}
|
||||
{{ variant.id }}
|
||||
|
||||
-# WITHOUT GROUP BUY
|
||||
.small-5.columns{"bo-if" => "!product.group_buy"}
|
||||
@@ -17,7 +17,6 @@
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}",
|
||||
"bo-model" => "variant.quantity"}
|
||||
{{ variant.options_text }}
|
||||
|
||||
-# WITH GROUP BUY
|
||||
.small-2.columns{"bo-if" => "product.group_buy"}
|
||||
@@ -28,7 +27,6 @@
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}",
|
||||
"bo-model" => "variant.quantity"}
|
||||
{{ variant.options_text }}
|
||||
(min)
|
||||
|
||||
.small-3.columns{"bo-if" => "product.group_buy"}
|
||||
@@ -40,5 +38,5 @@
|
||||
"ng-model" => "variant.max_quantity"}
|
||||
(max)
|
||||
|
||||
.small-1.columns
|
||||
.small-2.columns.text-right
|
||||
{{ variant.price | currency }}
|
||||
|
||||
9
spec/controllers/groups_controller_spec.rb
Normal file
9
spec/controllers/groups_controller_spec.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe GroupsController do
|
||||
it "gets all visible groups" do
|
||||
EnterpriseGroup.stub_chain :on_front_page, :by_position
|
||||
EnterpriseGroup.should_receive :on_front_page
|
||||
get :index
|
||||
end
|
||||
end
|
||||
15
spec/helpers/groups_helper_spec.rb
Normal file
15
spec/helpers/groups_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the GroupsHelper. For example:
|
||||
#
|
||||
# describe GroupsHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
describe GroupsHelper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Reference in New Issue
Block a user