Merge branch 'laura_and_will' into icon_font

Conflicts:
	app/views/groups/index.html.haml
	app/views/modals/_producers.html.haml
This commit is contained in:
summerscope
2014-05-30 12:12:07 +10:00
128 changed files with 1012 additions and 497 deletions

View File

@@ -1,3 +1,3 @@
window.Admin = angular.module("ofn.admin", ["ngResource", "ngAnimate", "ofn.dropdown"]).config ($httpProvider) ->
angular.module("ofn.admin", ["ngResource", "ngAnimate", "ofn.dropdown"]).config ($httpProvider) ->
$httpProvider.defaults.headers.common["X-CSRF-Token"] = $("meta[name=csrf-token]").attr("content")
$httpProvider.defaults.headers.common["Accept"] = "application/json, text/javascript, */*"

View File

@@ -16,5 +16,6 @@
//= require admin/spree_auth
//= require admin/spree_promo
//= require ./admin
//= require ./products/products
//= require_tree .

View File

@@ -1,4 +1,4 @@
Admin.controller "AdminOrderMgmtCtrl", [
angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [
"$scope", "$http", "dataFetcher", "blankOption", "pendingChanges"
($scope, $http, dataFetcher, blankOption, pendingChanges) ->

View File

@@ -1,4 +1,4 @@
Admin.controller "AdminProductEditCtrl", [
angular.module("ofn.admin").controller "AdminProductEditCtrl", [
"$scope", "$timeout", "$http", "dataFetcher", "DirtyProducts"
($scope, $timeout, $http, dataFetcher, DirtyProducts) ->
$scope.updateStatusMessage =

View File

@@ -1,4 +1,4 @@
Admin.controller "AdminEnterpriseRelationshipsCtrl", ($scope, EnterpriseRelationships, Enterprises) ->
angular.module("ofn.admin").controller "AdminEnterpriseRelationshipsCtrl", ($scope, EnterpriseRelationships, Enterprises) ->
$scope.EnterpriseRelationships = EnterpriseRelationships
$scope.Enterprises = Enterprises

View File

@@ -0,0 +1,5 @@
angular.module("ofn.admin").controller "enterprisesDashboardCtrl", [
"$scope"
($scope) ->
$scope.activeTab = "hubs"
]

View File

@@ -1,4 +1,4 @@
Admin.directive "ofnConfirmLinkPath", (ofnConfirmHandler) ->
angular.module("ofn.admin").directive "ofnConfirmLinkPath", (ofnConfirmHandler) ->
restrict: "A"
scope:
path: "@ofnConfirmLinkPath"

View File

@@ -1,4 +1,4 @@
Admin.directive "ofnConfirmModelChange", (ofnConfirmHandler,$timeout) ->
angular.module("ofn.admin").directive "ofnConfirmModelChange", (ofnConfirmHandler,$timeout) ->
restrict: "A"
link: (scope, element, attrs) ->
handler = ofnConfirmHandler scope, -> scope.fetchOrders()

View File

@@ -1,4 +1,4 @@
Admin.directive "datepicker", ->
angular.module("ofn.admin").directive "datepicker", ->
require: "ngModel"
link: (scope, element, attrs, ngModel) ->
element.datepicker

View File

@@ -1,4 +1,4 @@
Admin.directive "datetimepicker", ->
angular.module("ofn.admin").directive "datetimepicker", ->
require: "ngModel"
link: (scope, element, attrs, ngModel) ->
element.datetimepicker

View File

@@ -1,4 +1,4 @@
Admin.directive "ofnDecimal", ->
angular.module("ofn.admin").directive "ofnDecimal", ->
require: "ngModel"
link: (scope, element, attrs, ngModel) ->
numRegExp = /^\d+(\.\d+)?$/

View File

@@ -1,4 +1,4 @@
Admin.directive "ofnLineItemUpdAttr", [
angular.module("ofn.admin").directive "ofnLineItemUpdAttr", [
"switchClass", "pendingChanges"
(switchClass, pendingChanges) ->
require: "ngModel"

View File

@@ -1,4 +1,4 @@
Admin.directive "ofnSelect2MinSearch", ->
angular.module("ofn.admin").directive "ofnSelect2MinSearch", ->
require: 'ngModel'
link: (scope, element, attrs, ngModel) ->
element.select2

View File

@@ -1,4 +1,4 @@
Admin.directive "ofnTaxonAutocomplete", (Taxons) ->
angular.module("ofn.admin").directive "ofnTaxonAutocomplete", (Taxons) ->
# Adapted from Spree's existing taxon autocompletion
require: "ngModel"
link: (scope,element,attrs,ngModel) ->

View File

@@ -1,4 +1,4 @@
Admin.directive "ofnToggleColumn", ->
angular.module("ofn.admin").directive "ofnToggleColumn", ->
link: (scope, element, attrs) ->
element.addClass "selected" if scope.column.visible
element.click "click", ->

View File

@@ -1,4 +1,4 @@
Admin.directive "ofnToggleVariants", ->
angular.module("ofn.admin").directive "ofnToggleVariants", ->
link: (scope, element, attrs) ->
if scope.displayProperties[scope.product.id].showVariants
element.removeClass "icon-chevron-right"

View File

@@ -1,4 +1,4 @@
Admin.directive "ofnTrackProduct", ["DirtyProducts", (DirtyProducts) ->
angular.module("ofn.admin").directive "ofnTrackProduct", ["DirtyProducts", (DirtyProducts) ->
require: "ngModel"
link: (scope, element, attrs, ngModel) ->
ngModel.$parsers.push (viewValue) ->

View File

@@ -1,4 +1,4 @@
Admin.directive "ofnTrackVariant", ["DirtyProducts", (DirtyProducts) ->
angular.module("ofn.admin").directive "ofnTrackVariant", ["DirtyProducts", (DirtyProducts) ->
require: "ngModel"
link: (scope, element, attrs, ngModel) ->
ngModel.$parsers.push (viewValue) ->

View File

@@ -1,4 +1,4 @@
Admin.filter "rangeArray", ->
angular.module("ofn.admin").filter "rangeArray", ->
return (input,start,end) ->
input.push(i) for i in [start..end]
input

View File

@@ -1,4 +1,4 @@
Admin.filter "selectFilter", (blankOption) ->
angular.module("ofn.admin").filter "selectFilter", (blankOption) ->
return (lineItems,selectedSupplier,selectedDistributor,selectedOrderCycle) ->
filtered = []
filtered.push lineItem for lineItem in lineItems when (angular.equals(selectedSupplier,"0") || lineItem.supplier.id == selectedSupplier) &&

View File

@@ -1,4 +1,4 @@
Admin.filter "variantFilter", ->
angular.module("ofn.admin").filter "variantFilter", ->
return (lineItems,selectedUnitsProduct,selectedUnitsVariant,sharedResource) ->
filtered = []
filtered.push lineItem for lineItem in lineItems when (angular.equals(selectedUnitsProduct,{}) ||

View File

@@ -0,0 +1 @@
angular.module("admin.products", [])

View File

@@ -0,0 +1,46 @@
angular.module("admin.products")
.controller "unitsCtrl", ($scope) ->
$scope.product = { master: {} }
$scope.$watch ->
$scope.product.variant_unit_with_scale
, ->
if $scope.product.variant_unit_with_scale
match = $scope.product.variant_unit_with_scale.match(/^([^_]+)_([\d\.]+)$/)
if match
$scope.product.variant_unit = match[1]
$scope.product.variant_unit_scale = parseFloat(match[2])
else
$scope.product.variant_unit = $scope.product.variant_unit_with_scale
$scope.product.variant_unit_scale = null
else
$scope.product.variant_unit = $scope.product.variant_unit_scale = null
$scope.$watch ->
$scope.product.master.unit_value_with_description
, ->
if $scope.product.master.hasOwnProperty("unit_value_with_description")
match = $scope.product.master.unit_value_with_description.match(/^([\d\.]+(?= |$)|)( |)(.*)$/)
if match
$scope.product.master.unit_value = parseFloat(match[1])
$scope.product.master.unit_value = null if isNaN($scope.product.master.unit_value)
$scope.product.master.unit_value *= $scope.product.variant_unit_scale if $scope.product.master.unit_value && $scope.product.variant_unit_scale
$scope.product.master.unit_description = match[3]
$scope.variant_unit_options = [
["Weight (g)", "weight_1"],
["Weight (kg)", "weight_1000"],
["Weight (T)", "weight_1000000"],
["Volume (mL)", "volume_0.001"],
["Volume (L)", "volume_1"],
["Volume (ML)", "volume_1000000"],
["Items", "items"]
]
$scope.hasVariants = (product) ->
Object.keys(product.variants).length > 0
$scope.hasUnit = (product) ->
product.variant_unit_with_scale?

View File

@@ -1,2 +1,2 @@
Admin.value "blankOption", ->
angular.module("ofn.admin").value "blankOption", ->
{ id: "0", name: "All" }

View File

@@ -1,4 +1,4 @@
Admin.factory "ofnConfirmHandler", (pendingChanges, $compile, $q) ->
angular.module("ofn.admin").factory "ofnConfirmHandler", (pendingChanges, $compile, $q) ->
return (scope, callback) ->
template = "<div id='dialog-div' style='padding: 10px'><h6>Unsaved changes currently exist, save now or ignore?</h6></div>"
dialogDiv = $compile(template)(scope)

View File

@@ -1,4 +1,4 @@
Admin.factory "dataFetcher", [
angular.module("ofn.admin").factory "dataFetcher", [
"$http", "$q"
($http, $q) ->
return (dataLocation) ->

View File

@@ -1,4 +1,4 @@
Admin.factory "dataSubmitter", [
angular.module("ofn.admin").factory "dataSubmitter", [
"$http", "$q", "switchClass"
($http, $q, switchClass) ->
return (changeObj) ->

View File

@@ -1,4 +1,4 @@
Admin.factory "DirtyProducts", ($parse) ->
angular.module("ofn.admin").factory "DirtyProducts", ($parse) ->
# Temporary service to track changes in products on admin bulk product edit
dirtyProducts = {}

View File

@@ -1,4 +1,4 @@
Admin.factory 'EnterpriseRelationships', ($http, enterprise_relationships) ->
angular.module("ofn.admin").factory 'EnterpriseRelationships', ($http, enterprise_relationships) ->
new class EnterpriseRelationships
create_errors: ""

View File

@@ -1,4 +1,5 @@
Admin.factory 'Enterprises', (enterprises) ->
angular.module("ofn.admin").factory 'Enterprises', (my_enterprises, all_enterprises) ->
new class Enterprises
constructor: ->
@enterprises = enterprises
@my_enterprises = my_enterprises
@all_enterprises = all_enterprises

View File

@@ -1,4 +1,4 @@
Admin.factory "pendingChanges",[
angular.module("ofn.admin").factory "pendingChanges",[
"dataSubmitter"
(dataSubmitter) ->
pendingChanges: {}

View File

@@ -1,4 +1,4 @@
Admin.factory "switchClass", [
angular.module("ofn.admin").factory "switchClass", [
"$timeout"
($timeout) ->
return (element,classToAdd,removeClasses,timeout) ->

View File

@@ -1,4 +1,4 @@
Admin.factory "Taxons", ($resource) ->
angular.module("ofn.admin").factory "Taxons", ($resource) ->
resource = $resource "/admin/taxons/search"
return {

View File

@@ -5,6 +5,7 @@
#
#= require angular
#= require angular-cookies
#= require angular-sanitize
#= require angular-resource
#= require ../shared/mm-foundation-tpls-0.2.0-SNAPSHOT
#= require ../shared/bindonce.min.js

View File

@@ -1,4 +1,4 @@
Darkswarm.controller "AccordionCtrl", ($scope, storage) ->
Darkswarm.controller "AccordionCtrl", ($scope, storage, $timeout) ->
$scope.accordion =
details: true
shipping: false
@@ -9,3 +9,8 @@ Darkswarm.controller "AccordionCtrl", ($scope, storage) ->
$scope.show = (name)->
$scope.accordion[name] = true
$timeout =>
if $scope.checkout.$valid
for k, v of $scope.accordion
$scope.accordion[k] = false

View File

@@ -1,5 +1,6 @@
Darkswarm.controller "DetailsCtrl", ($scope) ->
angular.extend(this, new FieldsetMixin($scope))
$scope.name = "details"
$scope.nextPanel = "billing"
@@ -11,11 +12,3 @@ Darkswarm.controller "DetailsCtrl", ($scope) ->
$scope.fullName = ->
[$scope.order.bill_address.firstname ? null,
$scope.order.bill_address.lastname ? null].join(" ").trim()
#$scope.$watch ->
#$scope.detailsValid()
#, (valid)->
#if valid
#$scope.show("billing")

View File

@@ -1,3 +1,6 @@
Darkswarm.controller "GroupsCtrl", ($scope, Groups) ->
Darkswarm.controller "GroupsCtrl", ($scope, Groups, $anchorScroll, $rootScope) ->
$scope.Groups = Groups
$scope.order = 'position'
$rootScope.$on "$locationChangeSuccess", (newRoute, oldRoute) ->
$anchorScroll()

View File

@@ -1,15 +1,17 @@
Darkswarm.controller "OrderCycleCtrl", ($scope, $rootScope, OrderCycle, $timeout) ->
Darkswarm.controller "OrderCycleCtrl", ($scope, OrderCycle, $timeout) ->
$scope.order_cycle = OrderCycle.order_cycle
$scope.OrderCycle = OrderCycle
$scope.changeOrderCycle = ->
OrderCycle.push_order_cycle()
$timeout ->
$("#order_cycle_id").trigger("closeTrigger")
# Timeout forces this to be evaluated after everything is loaded
# This is a hack. We should probably write our own "popover" directive
# That takes an expression instead of a trigger, and binds to that
$timeout =>
if !$scope.OrderCycle.selected()
$("#order_cycle_id").trigger("openTrigger")
Darkswarm.controller "OrderCycleChangeCtrl", ($scope, OrderCycle, Product, $timeout) ->
$scope.changeOrderCycle = ->
OrderCycle.push_order_cycle Product.update
$timeout ->
$("#order_cycle_id").trigger("closeTrigger")

View File

@@ -1,6 +1,6 @@
Darkswarm.controller "ProducerNodeCtrl", ($scope, HashNavigation, $anchorScroll) ->
$scope.toggle = ->
HashNavigation.navigate $scope.producer.hash
HashNavigation.toggle $scope.producer.hash
$scope.open = ->
HashNavigation.active($scope.producer.hash)

View File

@@ -8,5 +8,4 @@ Darkswarm.controller "ProductNodeCtrl", ($scope) ->
$scope.product.price
$scope.producer = $scope.product.supplier
$scope.hasVariants = $scope.product.variants.length > 0

View File

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

View File

@@ -5,6 +5,7 @@ window.Darkswarm = angular.module("Darkswarm", ["ngResource",
'infinite-scroll',
'angular-flash.service',
'templates',
'ngSanitize',
'backstretch']).config ($httpProvider, $tooltipProvider, $locationProvider, $anchorScrollProvider) ->
$httpProvider.defaults.headers.post['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')
$httpProvider.defaults.headers.put['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')

View File

@@ -8,11 +8,10 @@ Darkswarm.directive "ofnModal", ($modal)->
link: (scope, elem, attrs, ctrl, transclude)->
scope.title = attrs.title
contents = null
# 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", =>
scope.modalInstance = $modal.open(controller: ctrl, template: contents)
scope.modalInstance = $modal.open(controller: ctrl, template: contents, scope: scope.$parent)

View File

@@ -0,0 +1,6 @@
Darkswarm.filter "stripUrl", ->
stripper = /(https?:\/\/)?(www\.)?(.*)/
(url) ->
url.match(stripper).pop()

View File

@@ -1,3 +1,3 @@
Darkswarm.factory 'CheckoutFormState', ()->
# Just a singleton place to store data about the form statr
# Just a singleton place to store data about the form state
new class CheckoutFormState

View File

@@ -1,4 +1,4 @@
Darkswarm.factory 'Order', ($resource, Product, order, $http, CheckoutFormState, flash, Navigation)->
Darkswarm.factory 'Order', ($resource, order, $http, CheckoutFormState, flash, Navigation)->
new class Order
errors: {}

View File

@@ -1,10 +1,10 @@
Darkswarm.factory 'OrderCycle', ($resource, Product, orderCycleData) ->
Darkswarm.factory 'OrderCycle', ($resource, orderCycleData) ->
class OrderCycle
@order_cycle = orderCycleData # Object or {} due to RABL
@push_order_cycle: ->
@push_order_cycle: (callback) ->
new $resource("/shop/order_cycle").save {order_cycle_id: @order_cycle.order_cycle_id}, (order_data)->
OrderCycle.order_cycle.orders_close_at = order_data.orders_close_at
Product.update()
callback()
@orders_close_at: ->
@order_cycle.orders_close_at if @selected()

View File

@@ -9,7 +9,7 @@ Darkswarm.factory 'Product', ($resource) ->
products: null
loading: true
update: ->
update: =>
@data.products = $resource("/shop/products").query =>
@data.loading = false
@data

View File

@@ -4,7 +4,23 @@ div.dashboard_item
.centered
text-align: center
.text-icon
margin-top: 8px
display: block
font-size: 16px
font-weight: bold
color: #fff
padding: 0px 6px
border-radius: 10px
&.green
background-color: #9fc820
&.red
background-color: #DA5354
&.orange
background-color: #DA7F52
div.header
height: 50px
border-radius: 6px 6px 0px 0px
border: 1px solid #5498da
position: relative
@@ -26,16 +42,41 @@ div.dashboard_item
h3
color: #DA7F52
h3
padding: 10px 5px 10px 3%
h3.alpha
height: 100%
padding: 10px 5px 0px 3%
a
border-radius: 0px 4px 0px 0px
margin-left: 8px
height: 100%
padding: 15px 2px 0px 2px
.tabs
height: 30px
border: solid #5498da
border-width: 0px 0px 1px 0px
margin-top: 3px
div.dashboard_tab
cursor: pointer
height: 30px
color: #fff
background-color: #5498da
padding: 5px 5px 0px 5px
text-align: center
font-weight: bold
border: solid #5498da
border-width: 1px 1px 0px 1px
&:hover
background-color: #9fc820
&.selected
color: #5498da
background-color: #fff
.list
max-height: 250px
overflow-y: auto
overflow-x: hidden
.list-title
border: solid #5498da
@@ -50,10 +91,11 @@ div.dashboard_item
.list-item
border: solid #5498da
border-width: 0px 1px 0px 1px
height: 38px
span.alpha
font-weight: bold
margin-left: -3px
padding: 10px 2px 10px 5%
padding: 10px 2px 0px 5%
span.omega
padding-right: 13px
margin-right: -3px
@@ -94,10 +136,13 @@ div.dashboard_item
color: #fff
.icon-ok-sign
color: #fff
.text-icon
&.green
color: #9fc820
background-color: #fff
a.button
color: #fff
padding: 15px 15px
font-size: 110%
font-weight: bold
text-align: center
@@ -110,4 +155,5 @@ div.dashboard_item
&:hover
background-color: #9fc820
&.bottom
border-radius: 0px 0px 6px 6px
border-radius: 0px 0px 6px 6px
padding: 15px 15px

View File

@@ -17,10 +17,22 @@ div.sidebar_item
.list
max-height: 400px
overflow-y: auto
.list-item
overflow-x: hidden
border: solid #5498da
border-width: 0px 1px 0px 1px
&.red
color: #DA5354
border: solid #DA5354
border-width: 0px 3px 0px 3px
.list-item
&.odd
background-color: #fcf6ef
&:hover
background-color: #9fc820
a
color: #DA5354
.list-item
span.alpha
font-weight: bold
margin-left: -3px
@@ -29,16 +41,12 @@ div.sidebar_item
max-width: 160px
text-overflow: ellipsis
span.omega
padding: 8px 13px 8px 0px
padding: 8px 18px 8px 0px
margin-right: -3px
text-align: right
.icon-remove-sign
color: #DA5354
font-size: 18px
&.red
color: #DA5354
border: solid #DA5354
border-width: 0px 3px 0px 3px
&.even
background-color: #fff
&.odd

View File

@@ -9,3 +9,6 @@
*/
@import 'foundation-icons';
ofn-modal {
display: block;
}

View File

@@ -1,46 +0,0 @@
@import mixins
@import variables
@import branding
.product-img
border-bottom: 40px white solid
border-top: 20px white solid
border-left: 20px white solid
border-right: 20px white solid
outline: 1px solid #ccc
@include box-shadow(0 1px 2px 1px rgba(0,0,0,0.25))
.producer-hero
position: relative
padding: 0
.producer-hero-img
background-color: #999
width: 100%
height: inherit
max-height: 260px
overflow: hidden
margin-top: 2em
margin-bottom: 1em
h3.producer-name
background-color: rgba(255,255,255,0.65)
height: 2.5em
width: 100%
position: absolute
bottom: 0
padding: 0.5em
.producer-logo
max-width: 220px
@media only screen and (max-width: 1024px)
.product-img
margin-top: 2em
margin-bottom: 1em

View File

@@ -1,2 +1,5 @@
.row
max-width: 74em
.reveal-modal
position: fixed

View File

@@ -27,7 +27,6 @@
margin-right: 12px
location
font-family: "AvenirBla_IE", "AvenirBla"
padding-right: 16px
@media all and (max-width: 768px)
location, location + small
display: block
@@ -58,21 +57,23 @@
@media all and (max-width: 768px)
font-size: 1.2em
select
width: 280px
width: inherit
display: inline-block
vackground: transparent
border-width: 2px
border-color: #666666
border-width: 1px
border-color: #999
color: #666
font-size: 1em
margin-bottom: 0
padding: 8px 0px 8px 12px
padding: 8px 20px 8px 12px
@media all and (max-width: 768px)
font-size: 1.2em
width: 180px
// width: 180px
closing
font-size: 0.875em
color: black
font-size: 1.5em
display: block
padding-top: 14px
padding-bottom: 20px
products
display: block
@@ -81,7 +82,8 @@
padding-top: 1em
input.button.right
float: left
product:hover, product:focus, product:active
border-color: $clr-brick
@include box-shadow(0 0 3px 0 $clr-brick-bright)

View File

@@ -1,8 +1,9 @@
module Admin
class EnterpriseRelationshipsController < ResourceController
def index
@enterprises = Enterprise.managed_by(spree_current_user).by_name
@enterprise_relationships = EnterpriseRelationship.by_name
@my_enterprises = Enterprise.managed_by(spree_current_user).by_name
@all_enterprises = Enterprise.by_name
@enterprise_relationships = EnterpriseRelationship.by_name.involving_enterprises @my_enterprises
end
def create

View File

@@ -23,7 +23,7 @@ module Admin
respond_to do |format|
if @order_cycle.save
OpenFoodNetwork::OrderCycleFormApplicator.new(@order_cycle).go!
OpenFoodNetwork::OrderCycleFormApplicator.new(@order_cycle, managed_enterprises).go!
flash[:notice] = 'Your order cycle has been created.'
format.html { redirect_to admin_order_cycles_path }
@@ -40,7 +40,7 @@ module Admin
respond_to do |format|
if @order_cycle.update_attributes(params[:order_cycle])
OpenFoodNetwork::OrderCycleFormApplicator.new(@order_cycle).go!
OpenFoodNetwork::OrderCycleFormApplicator.new(@order_cycle, managed_enterprises).go!
flash[:notice] = 'Your order cycle has been updated.'
format.html { redirect_to admin_order_cycles_path }

View File

@@ -15,11 +15,10 @@ Spree::Admin::OrdersController.class_eval do
per(params[:per_page] || Spree::Config[:orders_per_page])
} } }
private
def load_spree_api_key
current_user.generate_spree_api_key! unless spree_current_user.spree_api_key
@spree_api_key = spree_current_user.spree_api_key
end
end
end

View File

@@ -0,0 +1,7 @@
class Spree::StoreController
layout 'darkswarm'
def unauthorized
render 'shared/unauthorized', :status => 401
end
end

View File

@@ -2,6 +2,10 @@ module EnterprisesHelper
def current_distributor
@current_distributor ||= current_order(false).andand.distributor
end
def managed_enterprises
Enterprise.managed_by(spree_current_user)
end
def enterprises_options enterprises
enterprises.map { |enterprise| [enterprise.name + ": " + enterprise.address.address1 + ", " + enterprise.address.city, enterprise.id.to_i] }

View File

@@ -14,16 +14,6 @@ module SharedHelper
klass
end
# all suppliers of current distributor's products
def current_producers
if current_distributor && current_order_cycle
variants = current_order_cycle.variants_distributed_by(current_distributor)
Enterprise.supplying_variant_in(variants)
else
[]
end
end
def enterprise_user?
spree_current_user.andand.enterprises.andand.count.to_i > 0
end

View File

@@ -18,8 +18,8 @@ class Enterprise < ActiveRecord::Base
delegate :latitude, :longitude, :city, :state_name, :to => :address
accepts_nested_attributes_for :address
has_attached_file :logo, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
has_attached_file :promo_image, :styles => { :large => "570x380>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
has_attached_file :logo, :styles => { :medium => "300x300>", :thumb => "100x100>" }
has_attached_file :promo_image, :styles => { :large => "260x1200#", :thumb => "100x100>" }
validates_presence_of :name
validates_presence_of :address
@@ -123,6 +123,14 @@ class Enterprise < ActiveRecord::Base
self.supplied_products.where('count_on_hand > 0').present?
end
def supplied_and_active_products_on_hand
self.supplied_products.where('spree_products.count_on_hand > 0').active
end
def active_products_in_order_cycles
self.supplied_and_active_products_on_hand.in_an_active_order_cycle
end
def to_param
"#{id}-#{name.parameterize}"
end

View File

@@ -9,7 +9,7 @@ class EnterpriseGroup < ActiveRecord::Base
attr_accessible :name, :description, :long_description, :on_front_page, :enterprise_ids
attr_accessible :promo_image
has_attached_file :promo_image, styles: {medium: "800>400"}
has_attached_file :promo_image, styles: {large: "260x1200#"}
validates_attachment_content_type :promo_image, :content_type => /\Aimage\/.*\Z/
attr_accessible :logo

View File

@@ -9,4 +9,8 @@ class EnterpriseRelationship < ActiveRecord::Base
joins('LEFT JOIN enterprises AS parent_enterprises ON parent_enterprises.id = enterprise_relationships.parent_id').
joins('LEFT JOIN enterprises AS child_enterprises ON child_enterprises.id = enterprise_relationships.child_id')
scope :by_name, with_enterprises.order('parent_enterprises.name, child_enterprises.name')
scope :involving_enterprises, ->(enterprises) {
where('parent_id IN (?) OR child_id IN (?)', enterprises, enterprises)
}
end

View File

@@ -54,6 +54,10 @@ class Exchange < ActiveRecord::Base
incoming? ? 'supplier' : 'distributor'
end
def participant
incoming? ? sender : receiver
end
def to_h(core_only=false)
h = attributes.merge({ 'variant_ids' => variant_ids.sort, 'enterprise_fee_ids' => enterprise_fee_ids.sort })
h.reject! { |k| %w(id order_cycle_id created_at updated_at).include? k } if core_only

View File

@@ -1,6 +1,6 @@
class AbilityDecorator
include CanCan::Ability
def initialize(user)
if user.enterprises.count > 0
@@ -53,6 +53,11 @@ class AbilityDecorator
(user.enterprises & shipping_method.distributors).any?
end
can [:admin, :index, :create], EnterpriseRelationship
can [:destroy], EnterpriseRelationship do |enterprise_relationship|
user.enterprises.include? enterprise_relationship.parent
end
can [:create], OrderCycle
can [:admin, :index, :read, :edit, :update, :bulk_update, :clone], OrderCycle do |order_cycle|
user.enterprises.include? order_cycle.coordinator

View File

@@ -75,6 +75,12 @@ Spree::Product.class_eval do
scope :in_order_cycle, lambda { |order_cycle| with_order_cycles_inner.
merge(Exchange.outgoing).
where('order_cycles.id = ?', order_cycle) }
scope :in_an_active_order_cycle, lambda { with_order_cycles_inner.
merge(OrderCycle.active).
merge(Exchange.outgoing).
where('order_cycles.id IS NOT NULL') }
scope :managed_by, lambda { |user|
if user.has_spree_role?('admin')
scoped

View File

@@ -0,0 +1,3 @@
/ insert_top "[data-hook='admin_product_form_right']"
= render 'spree/admin/products/primary_taxon_form', f: f

View File

@@ -0,0 +1,63 @@
/ replace "fieldset[data-hook='new_product']"
%fieldset{ id: "new_product" }
%legend{align: "center"}= t(:new_product)
.row
.alpha.eleven.columns
= f.field_container :name do
= f.label :name, t(:name)
%span.required *
%br/
= f.text_field :name, :class => 'fullwidth title'
= f.error_message_on :name
.five.columns.omega
= f.field_container :supplier do
= f.label :supplier
%span.required *
= f.collection_select(:supplier_id, Enterprise.is_primary_producer.managed_by(spree_current_user).by_name, :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"})
= f.error_message_on :supplier
.row
.alpha.six.columns
= render 'spree/admin/products/primary_taxon_form', f: f
.five.columns
= f.field_container :price do
= f.label :price, t(:price)
%span.required *
%br/
= f.text_field :price, :class => 'fullwidth'
= f.error_message_on :price
.five.columns.omega
= f.field_container :on_hand do
= f.label :on_hand, t(:on_hand)
%span.required *
%br/
= f.text_field :on_hand, :class => 'fullwidth'
= f.error_message_on :on_hand
.row{ 'ng-controller' => 'unitsCtrl' }
.six.columns.alpha
= f.label :variant_unit_with_scale, :units
%select.select2.fullwidth{ id: 'product_variant_unit_with_scale', 'ng-model' => 'product.variant_unit_with_scale', 'ng-options' => 'unit[1] as unit[0] for unit in variant_unit_options' }
%option{'value' => '', 'ng-hide' => "hasUnit(product)"}
%input{ type: 'hidden', 'ng-value' => 'product.variant_unit', name: 'product[variant_unit]' }
%input{ type: 'hidden', 'ng-value' => 'product.variant_unit_scale', name: 'product[variant_unit_scale]' }
.five.columns
= f.label :product_unit_value_with_description, :value
%input.fullwidth{ id: 'product_unit_value_with_description', 'ng-model' => 'product.master.unit_value_with_description', :type => 'text', :placeholder => 'eg. 2', 'ng-disabled' => "!hasUnit(product)" }
%input{ type: 'hidden', 'ng-value' => 'product.master.unit_value', name: 'product[unit_value]' }
%input{ type: 'hidden', 'ng-value' => 'product.master.unit_description', name: 'product[unit_description]' }
.five.columns.omega{ 'ng-show' => "product.variant_unit_with_scale == 'items'" }
= f.label :product_variant_unit_name, :unit_name
%input.fullwidth{ id: 'product_variant_unit_name','ng-model' => 'product.variant_unit_name', :name => 'product[variant_unit_name]', :placeholder => 'eg. bunches', :type => 'text' }
#product-from-prototype.clearfix{"data-hook" => "product-from-prototype"}
= render :file => 'spree/admin/prototypes/show' if @prototype
= render :partial => 'spree/admin/shared/new_resource_links'
:javascript
angular.element(document.getElementById("new_product")).ready(function() {
angular.bootstrap(document.getElementById("new_product"), ['admin.products']);
});

View File

@@ -1,3 +1,4 @@
:javascript
angular.module('ofn.admin').value('enterprise_relationships', #{render partial: "admin/json/enterprise_relationships", object: @enterprise_relationships});
angular.module('ofn.admin').value('enterprises', #{render partial: "admin/json/enterprises", object: @enterprises});
angular.module('ofn.admin').value('my_enterprises', #{render partial: "admin/json/enterprises", object: @my_enterprises});
angular.module('ofn.admin').value('all_enterprises', #{render partial: "admin/json/enterprises", object: @all_enterprises});

View File

@@ -1,9 +1,9 @@
%tr
%td
%select{name: "enterprise_relationship_parent_name", "ng-model" => "parent_id", "ng-options" => "e.id as e.name for e in Enterprises.enterprises"}
%select{name: "enterprise_relationship_parent_id", "ng-model" => "parent_id", "ng-options" => "e.id as e.name for e in Enterprises.my_enterprises"}
%td permits
%td
%select{name: "enterprise_relationship_child_name", "ng-model" => "child_id", "ng-options" => "e.id as e.name for e in Enterprises.enterprises"}
%select{name: "enterprise_relationship_child_id", "ng-model" => "child_id", "ng-options" => "e.id as e.name for e in Enterprises.all_enterprises"}
%td.actions
%input{type: "button", value: "Create", "ng-click" => "create()"}
.errors {{ EnterpriseRelationships.create_errors }}

View File

@@ -1,59 +1,63 @@
- payment_methods_color = @payment_methods.count > 0 ? (@enterprise.payment_methods.count > 0 ? "blue" : "red") : "red"
.sidebar_item.four.columns.alpha#payment_methods
.four.columns.alpha.header{ class: "#{@payment_methods.count > 0 ? "blue" : "red"}" }
.four.columns.alpha.header{ class: "#{payment_methods_color}" }
%span.four.columns.alpha.centered Payment Methods
- if @payment_methods.count > 0
.four.columns.alpha.list
.four.columns.alpha.list{ class: "#{payment_methods_color}" }
- if @payment_methods.count > 0
-# = hidden_field_tag "enterprise[payment_method_ids][]", []
- @payment_methods.each do |payment_method|
%a.four.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{edit_admin_payment_method_path(payment_method)}" }
%span.three.columns.alpha
= payment_method.name
%span.one.column.omega
= f.check_box :payment_method_ids, { :multiple => true }, payment_method.id, nil
- else
.four.columns.alpha.list-item.red
%span.three.columns.alpha None Available
%span.one.column.omega
%span.icon-remove-sign
%a.four.columns.alpha.button{ href: "#{new_admin_payment_method_path}", class: "#{@payment_methods.count > 0 ? "blue" : "red"}" }
= f.check_box :payment_method_ids, { multiple: true }, payment_method.id, nil
- else
.four.columns.alpha.list-item
%span.three.columns.alpha None Available
%span.one.column.omega
%span.icon-remove-sign
%a.four.columns.alpha.button{ href: "#{new_admin_payment_method_path}", class: "#{payment_methods_color}" }
CREATE NEW
%span.icon-arrow-right
- shipping_methods_color = @shipping_methods.count > 0 ? (@enterprise.shipping_methods.count > 0 ? "blue" : "red") : "red"
.sidebar_item.four.columns.alpha#shipping_methods
.four.columns.alpha.header{ class: "#{@shipping_methods.count > 0 ? "blue" : "red"}" }
.four.columns.alpha.header{ class: "#{shipping_methods_color}" }
%span.four.columns.alpha.centered Shipping Methods
- if @shipping_methods.count > 0
.four.columns.alpha.list
.four.columns.alpha.list{ class: "#{shipping_methods_color}" }
- if @shipping_methods.count > 0
- @shipping_methods.each do |shipping_method|
%a.four.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{edit_admin_shipping_method_path(shipping_method)}" }
%span.three.columns.alpha
= shipping_method.name
%span.one.column.omega
= f.check_box :shipping_method_ids, { :multiple => true }, shipping_method.id, nil
- else
.four.columns.alpha.list-item.red
%span.three.columns.alpha None Available
%span.one.column.omega
%span.icon-remove-sign
%a.four.columns.alpha.button{ href: "#{new_admin_shipping_method_path}", class: "#{@payment_methods.count > 0 ? "blue" : "red"}" }
- else
.four.columns.alpha.list-item
%span.three.columns.alpha None Available
%span.one.column.omega
%span.icon-remove-sign
%a.four.columns.alpha.button{ href: "#{new_admin_shipping_method_path}", class: "#{shipping_methods_color}" }
CREATE NEW
%span.icon-arrow-right
- enterprise_fees_color = @enterprise_fees.count > 0 ? "blue" : "red"
.sidebar_item.four.columns.alpha#enterprise_fees
.four.columns.alpha.header{ class: "#{@enterprise_fees.count > 0 ? "blue" : "red"}" }
.four.columns.alpha.header{ class: "#{enterprise_fees_color}" }
%span.four.columns.alpha.centered Enterprise Fees
- if @enterprise_fees.count > 0
.four.columns.alpha.list
.four.columns.alpha.list{ class: "#{enterprise_fees_color}" }
- if @enterprise_fees.count > 0
- @enterprise_fees.each do |enterprise_fee|
%a.four.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{main_app.admin_enterprise_fees_path}" }
%span.three.columns.alpha
= enterprise_fee.name
%span.one.column.omega
&nbsp;
- else
.four.columns.alpha.list-item.red
%span.three.columns.alpha None Available
%span.one.column.omega
%span.icon-remove-sign
%a.four.columns.alpha.button{ href: "#{main_app.admin_enterprise_fees_path}", class: "#{@enterprise_fees.count > 0 ? "blue" : "red"}" }
- else
.four.columns.alpha.list-item.red
%span.three.columns.alpha None Available
%span.one.column.omega
%span.icon-remove-sign
%a.four.columns.alpha.button{ href: "#{main_app.admin_enterprise_fees_path}", class: "#{enterprise_fees_color}" }
CREATE NEW
%span.icon-arrow-right

View File

@@ -0,0 +1,14 @@
collection @collection
attributes :id, :name
child supplied_products: :supplied_products do |product|
attributes :name
node(:supplier_name) { |p| p.supplier.andand.name }
node(:image_url) { |p| p.images.present? ? p.images.first.attachment.url(:mini) : nil }
node(:master_id) { |p| p.master.id }
child variants: :variants do |variant|
attributes :id
node(:label) { |v| v.options_text }
end
end

View File

@@ -1,15 +0,0 @@
r.list_of :enterprises, @collection do
r.element :id
r.element :name
r.list_of :supplied_products do |product|
r.element :name
r.element :supplier_name, product.supplier.andand.name
r.element :image_url, product.images.present? ? product.images.first.attachment.url(:mini) : nil
r.element :master_id, product.master.id
r.list_of :variants do |variant|
r.element :id
r.element :label, variant.options_text
end
end
end

View File

@@ -1,7 +1,7 @@
%td{:colspan => 3}
.exchange-select-all-variants
%label
= check_box_tag 'order_cycle_outgoing_exchange_{{ $parent.$index }}_select_all_variants', 1, 1, 'ng-model' => 'exchange.select_all_variants', 'ng-click' => 'setExchangeVariants(exchange, incomingExchangesVariants(), exchange.select_all_variants)', 'id' => 'order_cycle_outgoing_exchange_{{ $parent.$index }}_select_all_variants'
= check_box_tag 'order_cycle_outgoing_exchange_{{ $parent.$index }}_select_all_variants', 1, 1, 'ng-model' => 'exchange.select_all_variants', 'ng-change' => 'setExchangeVariants(exchange, incomingExchangesVariants(), exchange.select_all_variants)', 'id' => 'order_cycle_outgoing_exchange_{{ $parent.$index }}_select_all_variants'
Select all
.exchange-product{'ng-repeat' => 'product in supplied_products | filter:productSuppliedToOrderCycle'}

View File

@@ -2,7 +2,7 @@
%td{:colspan => 3}
.exchange-select-all-variants
%label
= check_box_tag 'order_cycle_incoming_exchange_{{ $parent.$index }}_select_all_variants', 1, 1, 'ng-model' => 'exchange.select_all_variants', 'ng-click' => 'setExchangeVariants(exchange, suppliedVariants(exchange.enterprise_id), exchange.select_all_variants)', 'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_select_all_variants'
= check_box_tag 'order_cycle_incoming_exchange_{{ $parent.$index }}_select_all_variants', 1, 1, 'ng-model' => 'exchange.select_all_variants', 'ng-change' => 'setExchangeVariants(exchange, suppliedVariants(exchange.enterprise_id), exchange.select_all_variants)', 'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_select_all_variants'
Select all
.exchange-product{'ng-repeat' => 'product in enterprises[exchange.enterprise_id].supplied_products'}

View File

@@ -1,7 +1,7 @@
%fieldset#billing
%ng-form{"ng-controller" => "BillingCtrl", name: "billing"}
%h5{"ng-class" => "{valid: billing.$valid, dirty: details.$dirty}"}
%h5{"ng-class" => "{valid: billing.$valid, dirty: billing.$dirty}"}
%span.right
%label.label.round.alert.right
%i.ofn-i_009-close

View File

@@ -1,7 +1,7 @@
%fieldset#payment
%ng-form{"ng-controller" => "PaymentCtrl", name: "payment"}
%h5{"ng-class" => "{valid: payment.$valid, dirty: details.$dirty}"}
%h5{"ng-class" => "{valid: payment.$valid, dirty: payment.$dirty}"}
%span.right
%label.label.round.alert.right
%i.ofn-i_009-close

View File

@@ -1,7 +1,7 @@
%fieldset#shipping
%ng-form{"ng-controller" => "ShippingCtrl", name: "shipping"}
%h5{"ng-class" => "{valid: shipping.$valid, dirty: details.$dirty}"}
%h5{"ng-class" => "{valid: shipping.$valid, dirty: shipping.$dirty}"}
%span.right
%label.label.round.alert.right
%i.ofn-i_009-close

View File

@@ -17,18 +17,18 @@
"ng-debounce" => "150",
"ofn-disable-enter" => true}
.group{"ng-repeat" => "group in Groups.groups | filter:query | orderBy:order"}
.group{"ng-repeat" => "group in Groups.groups | filter:query | orderBy:order",
name: "group{{group.id}}",
id: "group{{group.id}}"}
.row.pad-top{bindonce: true}
.small-12.columns
.group-hero
%img.group-hero-img{"bo-src" => "{{group.promo_image}}"}
%img.group-logo{"bo-src" => "group.logo"}
%img.group-hero-img{"bo-src" => "group.promo_image"}
%img.group-logo{"bo-src" => "group.logo", "bo-if" => "group.logo"}
%h3.group-name
%i.ofn-i_035-groups
{{ group.name }}
%h5.group-description {{ group.description }}
/ Will - scale large images down to 1200px wide, crop in to img aspect ratio 60W:13H
.row.pad-top{bindonce: true}
.small-6.columns

View File

@@ -1,2 +1,8 @@
object current_distributor
attributes :name, :id
if current_distributor
child suppliers: :producers do
extends "json/producer"
end
end

View File

@@ -6,5 +6,9 @@ child enterprises: :enterprises do
end
node :logo do |group|
group.logo(:original)
group.logo(:medium) if group.logo.exists?
end
node :promo_image do |group|
group.promo_image(:large) if group.promo_image.exists?
end

View File

@@ -6,11 +6,7 @@ child distributed_taxons: :taxons do
end
child suppliers: :producers do
attributes :name, :id, :description, :long_description
node :promo_image do |producer|
producer.promo_image.url
end
extends "json/producer"
end
node :pickup do |hub|

View File

@@ -0,0 +1,5 @@
attributes :name, :id, :description, :long_description
node :promo_image do |producer|
producer.promo_image.url
end

View File

@@ -5,39 +5,35 @@
/ Will - scale large images down to 1200px wide, crop in to img aspect ratio 60W:13H
%h3.producer-name {{ producer.name }}
.row
.columns.small-12.large-6{"ng-bind-html" => "{{producer.long_description}}"}
/ Will to fix this
.columns.small-12.large-6{"ng-bind-html" => "producer.long_description"}
.columns.small-12.large-6
/ Will needs logic to add in following only if data is available for each type:
/ Will needs better formatting of URLs printed on-screen (minus http://www.)
/ Will needs formatting of URLs driving %a regardless of user input (plus http://www.)
%img.producer-logo{"ng-src" => "{{producer.logo}}"}
%img.producer-logo{"ng-src" => "{{producer.logo}}", "ng-if" => "producer.logo"}
%h4 Stay in touch with {{ producer.name }}
%ul.small-block-grid-1
%li
%a{href: "{{producer.website}}", target: "_blank" }
%ul.small-block-grid-1{bindonce: true}
%li{"ng-if" => "producer.website"}
%a{"ng-href" => "http://{{producer.website | stripUrl}}", target: "_blank" }
%i.fi-web
{{ producer.website }}
%li
%a{href: "{{producer.twitter}}", target: "_blank"}
/ Will needs logic to allow user to input @twitterhandle to drive a logical URL
{{ producer.website | stripUrl }}
%li{"ng-if" => "producer.twitter"}
%a{"ng-href" => "http://twitter.com/{{producer.twitter}}", target: "_blank"}
%i.fi-social-twitter
{{ producer.twitter }}
%li
%a{href: "{{producer.facebook}}", target: "_blank"}
%li{"ng-if" => "producer.facebook"}
%a{"ng-href" => "http://{{producer.facebook | stripUrl}}", target: "_blank"}
%i.fi-social-facebook
{{ producer.facebook }}
%li
%a{href: "{{producer.linkedin}}", target: "_blank"}
{{ producer.facebook | stripUrl }}
%li{"ng-if" => "producer.linkedin"}
%a{"ng-href" => "http://{{producer.linkedin | stripUrl}}", target: "_blank"}
%i.fi-social-linkedin
{{ producer.linkedin }}
%li
%a{href: "{{producer.instagram}}", target: "_blank"}
/ Will needs logic to allow user to input @instagramhandle to drive a logical URL
{{ producer.linkedin | stripUrl }}
%li{"ng-if" => "producer.instagram"}
%a{"ng-href" => "http://instagram.com/{{producer.instagram}}", target: "_blank"}
%i.fi-social-instagram
{{ producer.instagram }}
/ %pre
/ {{ producer | json }}
%a.close-reveal-modal{"ng-click" => "$close()"} &#215;
%a.close-reveal-modal{"ng-click" => "$close()"} &#215;

View File

@@ -1,14 +1,10 @@
%ofn-modal{title: "{{product.name}}"}
.row
.columns.small-12.large-6
%img.product-img{"ng-src" => "{{product.master.images[0].large_url}}"}
%img.product-img{"ng-src" => "{{product.master.images[0].large_url}}", "ng-if" => "product.master.images[0]"}
.columns.small-12.large-6
%h2
%img{"ng-src" => "{{product.primary_taxon.icon}}"}
{{product.name}}
%p {{product.description}}
/ %pre
/ {{ product | json }}
%a.close-reveal-modal{"ng-click" => "$close()"} &#215;

View File

@@ -5,7 +5,7 @@
{{ producer.taxons | printArrayOfObjects }}
.columns.small-8
%strong About us
%p.trans-sentence
%p
{{ producer.description }}
.row.active_table_row.link{"ng-show" => "open()", "ng-repeat" => "hub in producer.distributors"}

View File

@@ -0,0 +1 @@
Unauthorized

View File

@@ -13,10 +13,10 @@ child :supplier => :supplier do
attributes :id, :name, :description, :long_description, :website, :instagram, :facebook, :linkedin, :twitter
node :logo do |supplier|
supplier.logo.url
supplier.logo(:medium) if supplier.logo.exists?
end
node :promo_image do |supplier|
supplier.promo_image.url
supplier.promo_image(:large) if supplier.promo_image.exists?
end
end

View File

@@ -21,7 +21,7 @@
%div{"bo-if" => "hasVariants"}
= render partial: "shop/products/variants"
.variant.row{"bo-if" => "!hasVariants"}
.variants.row{"bo-if" => "!hasVariants"}
= render partial: "shop/products/master"
.row

View File

@@ -1,4 +1,4 @@
.small-1.column
.small-1.columns
%span.bulk{"bo-if" => "product.group_buy"} bulk
&nbsp;

View File

@@ -1,5 +1,5 @@
.row.summary
.small-1.column
.small-1.columns
%img{"bo-src" => "product.master.images[0].small_url"}
.small-4.columns.summary-header

View File

@@ -1,7 +1,7 @@
.row.variants{bindonce: true,
"ng-repeat" => "variant in product.variants"}
.small-1.column
.small-1.columns
%span.bulk{"bo-if" => "product.group_buy"} bulk
&nbsp;

View File

@@ -1,19 +1,25 @@
%shop.darkswarm
- content_for :order_cycle_form do
%strong.avenir Ready for
%select.avenir#order_cycle_id{"ng-model" => "order_cycle.order_cycle_id",
"ng-change" => "changeOrderCycle()",
"ng-options" => "oc.id as oc.time for oc in #{@order_cycles.map {|oc| {time: pickup_time(oc), id: oc.id}}.to_json}",
"popover-placement" => "bottom", "popover" => "When do you want to get your order?", "popover-trigger" => "openTrigger"}
%div{"ng-controller" => "OrderCycleChangeCtrl"}
%closing{"ng-if" => "OrderCycle.selected()"}
Next order closing
%strong {{ OrderCycle.orders_close_at() | date_in_words }}
%closing{"ng-if" => "OrderCycle.selected()"}
Orders close
%strong {{ OrderCycle.orders_close_at() | date_in_words }}
%span Ready for pickup
/ Will this label should be a variable to reflect pickup or delivery as appropriate
%select.avenir#order_cycle_id{"ng-model" => "order_cycle.order_cycle_id",
"ng-change" => "changeOrderCycle()",
"ng-options" => "oc.id as oc.time for oc in #{@order_cycles.map {|oc| {time: pickup_time(oc), id: oc.id}}.to_json}",
"popover-placement" => "bottom", "popover" => "When do you want to get your order?", "popover-trigger" => "openTrigger"}
= render partial: "shopping_shared/details"
.row
= render partial: "shop/products/form"
= render partial: "shared/footer"
= render partial: "shared/footer"

View File

@@ -1,14 +1,11 @@
= render partial: "shopping_shared/modals"
%navigation
%distributor.details.row
#distributor_title
%img.left{src: current_distributor.logo.url(:thumb)}
%h4
%h3
= current_distributor.name
%location= current_distributor.address.city
%small
%a{href: "/"} Change location
/ Will this needs to be a drop-down to choose either pick-up point or delivery once shipping methods are implemented
= render partial: "shopping_shared/order_cycles"

View File

@@ -1,10 +1,5 @@
.content#groups
.content
%ul
- for group in current_distributor.groups
%li
%h4= group.name
%ul
- for sibling in group.enterprises.except(current_distributor)
%li
%a{"data-reveal-id" => "sibling_details_#{sibling.id}", "data-reveal" => ""}
= sibling.name
%a{href: main_app.groups_path(anchor: "#/#group#{group.id}")}= group.name

View File

@@ -1,36 +0,0 @@
- for producer in current_producers
.reveal-modal{id: "producer_details_#{producer.id}", "data-reveal" => ""}
.row
- if producer.logo.exists?
.large-1.columns
%img.left{src: producer.logo.url(:thumb)}
.large-11.columns
%h2
= producer.name
.row
.large-8.columns
= producer.long_description.andand.html_safe
- if producer.promo_image.exists?
.large-4.columns
%img.about.right{src: producer.promo_image.url(:large)}
%a.close-reveal-modal &#215;
- for group in current_distributor.groups
- for sibling in group.enterprises.except(current_distributor)
.reveal-modal{id: "sibling_details_#{sibling.id}", "data-reveal" => ""}
.row
- if sibling.logo.exists?
.large-1.columns
%img.left{src: sibling.logo.url(:thumb)}
.large-11.columns
%h2
= sibling.name
.row
.large-8.columns
= sibling.long_description.andand.html_safe
- if sibling.promo_image.exists?
.large-4.columns
%img.about.right{src: sibling.promo_image.url(:large)}
%a.close-reveal-modal &#215;

View File

@@ -14,5 +14,3 @@
- else
%form.custom
= yield :order_cycle_form

View File

@@ -1,6 +1,4 @@
.content#producers
.content#producers{"ng-controller" => "ProducersTabCtrl"}
%ul
- for producer in current_producers
%li
%a{"data-reveal-id" => "producer_details_#{producer.id}", "data-reveal" => ""}
= producer.name
%li{"ng-repeat" => "producer in CurrentHub.producers"}
= render partial: "modals/producer"

View File

@@ -1,11 +1,15 @@
%div.dashboard_item.sixteen.columns.alpha#enterprises
%div.dashboard_item.sixteen.columns.alpha#enterprises{ 'ng-app' => 'ofn.admin', 'ng-controller' => "enterprisesDashboardCtrl" }
%div.header.sixteen.columns.alpha{ :class => "#{@enterprises.count > 0 ? "" : "red"}"}
%h3.thirteen.columns.alpha My Enterprises
- if @enterprises.any?
%a.three.columns.omega.icon-plus.button.blue{ href: "#{main_app.new_admin_enterprise_path}" }
%a.three.columns.omega.icon-plus.button.blue.white-bottom{ href: "#{main_app.new_admin_enterprise_path}" }
CREATE NEW
- else
%a.with-tip{ title: "Enterprises are Producers and/or Hubs and are the basic unit of organisation within the Open Food Network." } What's this?
- if @enterprises.any?
%div.sixteen.columns.alpha.tabs
%div.dashboard_tab.eight.columns.alpha.blue{ ng: { class: "{selected: activeTab == 'hubs'}", click: "activeTab = 'hubs'" } } HUBS
%div.dashboard_tab.eight.columns.omega.blue{ ng: { class: "{selected: activeTab == 'producers'}", click: "activeTab = 'producers'" } } PRODUCERS
- if @enterprises.empty?
%div.sixteen.columns.alpha.list-item.red
%span.text.fifteen.columns.alpha You don't have any enterprises yet.
@@ -15,40 +19,69 @@
CREATE A NEW ENTERPRISE
%span.icon-arrow-right
- else
%div.sixteen.columns.alpha.list-title
%span.five.columns.alpha Name
%span.centered.three.columns Payment Methods
%span.centered.three.columns Shipping Methods
%span.centered.three.columns Enterprise Fees
%div.sixteen.columns.alpha.list
- @enterprises.each do |enterprise|
%a.sixteen.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{main_app.edit_admin_enterprise_path(enterprise)}" }
%span.five.columns.alpha
= enterprise.name
%span.symbol.three.columns.centered
- payment_method_count = enterprise.payment_methods.count
- if payment_method_count < 1 && enterprise.is_distributor
%span.icon-remove-sign.with-tip{ title: "#{enterprise.name} has no Payment Methods" }
- elsif enterprise.is_primary_producer
%span.icon-ok-sign.with-tip{ title: "Producers (like #{enterprise.name}) do not require Payment Methods." }
- else
%span.icon-ok-sign.with-tip{ title: "#{payment_method_count} Payment Method#{payment_method_count > 1 ? "s" : ""}" }
%span.symbol.three.columns.centered
- shipping_method_count = enterprise.shipping_methods.count
- if shipping_method_count < 1 && enterprise.is_distributor
%span.icon-remove-sign.with-tip{ title: "#{enterprise.name} has no Shipping Methods" }
- elsif enterprise.is_primary_producer
%span.icon-ok-sign.with-tip{ title: "Producers (like #{enterprise.name}) do not require Shipping Methods." }
-else
%span.icon-ok-sign.with-tip{ title: "#{shipping_method_count} Shipping Method#{shipping_method_count > 1 ? "s" : ""}" }
%span.symbol.three.columns.centered
- fee_count = enterprise.enterprise_fees.count
- if fee_count > 0
%span.icon-ok-sign.with-tip{ title: "#{fee_count} Fee#{fee_count > 1 ? "s" : ""}" }
- else
%span.icon-warning-sign.with-tip{ title: "#{enterprise.name} has no Enterprise Fees" }
%span.two.columns.omega.right
%span.icon-arrow-right
%div.hubs_tab{ ng: { show: "activeTab == 'hubs'"} }
%div.sixteen.columns.alpha.list-title
%span.five.columns.alpha Name
%span.centered.three.columns Payment Methods
%span.centered.three.columns Shipping Methods
%span.centered.three.columns Enterprise Fees
%div.sixteen.columns.alpha.list
- @enterprises.is_distributor.each do |enterprise|
%a.sixteen.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{main_app.edit_admin_enterprise_path(enterprise)}" }
%span.five.columns.alpha
= enterprise.name
%span.symbol.three.columns.centered
- payment_method_count = enterprise.payment_methods.count
- if payment_method_count < 1 && enterprise.is_distributor
%span.icon-remove-sign.with-tip{ title: "#{enterprise.name} has no Payment Methods" }
- elsif enterprise.is_primary_producer
%span.icon-ok-sign.with-tip{ title: "Producers (like #{enterprise.name}) do not require Payment Methods." }
- else
%span.icon-ok-sign.with-tip{ title: "#{payment_method_count} Payment Method#{payment_method_count > 1 ? "s" : ""}" }
%span.symbol.three.columns.centered
- shipping_method_count = enterprise.shipping_methods.count
- if shipping_method_count < 1 && enterprise.is_distributor
%span.icon-remove-sign.with-tip{ title: "#{enterprise.name} has no Shipping Methods" }
- elsif enterprise.is_primary_producer
%span.icon-ok-sign.with-tip{ title: "Producers (like #{enterprise.name}) do not require Shipping Methods." }
-else
%span.icon-ok-sign.with-tip{ title: "#{shipping_method_count} Shipping Method#{shipping_method_count > 1 ? "s" : ""}" }
%span.symbol.three.columns.centered
- fee_count = enterprise.enterprise_fees.count
- if fee_count > 0
%span.icon-ok-sign.with-tip{ title: "#{fee_count} Fee#{fee_count > 1 ? "s" : ""}" }
- else
%span.icon-warning-sign.with-tip{ title: "#{enterprise.name} has no Enterprise Fees" }
%span.two.columns.omega.right
%span.icon-arrow-right
%div.producers_tab{ ng: { show: "activeTab == 'producers'"} }
%div.list-title.sixteen.columns.alpha
%span.five.columns.alpha Name
%span.centered.three.columns Total Products
%span.centered.three.columns Active Products
%span.centered.three.columns Products in OCs
%div.sixteen.columns.alpha.list
- @enterprises.is_primary_producer.each do |enterprise|
%a.sixteen.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{main_app.edit_admin_enterprise_path(enterprise)}" }
%span.five.columns.alpha
= enterprise.name
%span.symbol.three.columns.centered
%span.one.column.alpha &nbsp;
%span.text-icon.one.column.centered{ class: "#{enterprise.supplied_products.not_deleted.count > 0 ? "green" : "red" }" }
= enterprise.supplied_products.not_deleted.count
%span.one.column.omega &nbsp;
%span.symbol.three.columns.centered
%span.one.column.alpha &nbsp;
%span.text-icon.one.column.centered{ class: "#{enterprise.supplied_and_active_products_on_hand.count > 0 ? "green" : "red" }" }
= enterprise.supplied_and_active_products_on_hand.count
%span.one.column.omega &nbsp;
%span.symbol.three.columns.centered
%span.one.column.alpha &nbsp;
%span.text-icon.one.column.centered{ class: "#{enterprise.active_products_in_order_cycles.count > 0 ? "green" : "orange" }" }
= enterprise.active_products_in_order_cycles.count
%span.one.column.omega &nbsp;
%span.two.columns.omega.right
%span.icon-arrow-right
%a.sixteen.columns.alpha.button.bottom.blue{ href: "#{main_app.admin_enterprises_path}" }
MANAGE MY ENTERPRISES
%span.icon-arrow-right

View File

@@ -0,0 +1,5 @@
= f.field_container :primary_taxon_id do
= f.label :primary_taxon_id
%br
= f.collection_select(:primary_taxon_id, Spree::Taxon.all, :id, :name, {:include_blank => true}, {:class => "select2 fullwidth"})
= f.error_message_on :primary_taxon_id

Some files were not shown because too many files have changed in this diff Show More