Rename methods

This commit is contained in:
Rohan Mitchell
2013-01-11 10:40:56 +11:00
parent d3189e333b
commit bb13ec0e02
3 changed files with 27 additions and 27 deletions

View File

@@ -3,12 +3,12 @@ function AdminCreateOrderCycleCtrl($scope, OrderCycle, Enterprise) {
$scope.order_cycle = OrderCycle.order_cycle;
$scope.exchangeVariantsSelected = function(exchange) {
return OrderCycle.exchangeVariantsSelected(exchange);
$scope.exchangeSelectedVariants = function(exchange) {
return OrderCycle.exchangeSelectedVariants(exchange);
};
$scope.enterpriseVariantsTotal = function(enterprise) {
return OrderCycle.enterpriseVariantsTotal(enterprise);
$scope.enterpriseTotalVariants = function(enterprise) {
return OrderCycle.enterpriseTotalVariants(enterprise);
};
$scope.toggleProducts = function($event, exchange) {
@@ -33,12 +33,12 @@ function AdminEditOrderCycleCtrl($scope, $location, OrderCycle, Enterprise) {
var order_cycle_id = $location.absUrl().match(/\/admin\/order_cycles\/(\d+)/)[1];
$scope.order_cycle = OrderCycle.load(order_cycle_id);
$scope.exchangeVariantsSelected = function(exchange) {
return OrderCycle.exchangeVariantsSelected(exchange);
$scope.exchangeSelectedVariants = function(exchange) {
return OrderCycle.exchangeSelectedVariants(exchange);
};
$scope.enterpriseVariantsTotal = function(enterprise) {
return OrderCycle.enterpriseVariantsTotal(enterprise);
$scope.enterpriseTotalVariants = function(enterprise) {
return OrderCycle.enterpriseTotalVariants(enterprise);
};
$scope.toggleProducts = function($event, exchange) {
@@ -72,7 +72,7 @@ angular.module('order_cycle', ['ngResource']).
order_cycle: {incoming_exchanges: [],
outgoing_exchanges: []},
exchangeVariantsSelected: function(exchange) {
exchangeSelectedVariants: function(exchange) {
var numActiveVariants = 0;
angular.forEach(exchange.variants, function(active, id) {
@@ -84,7 +84,7 @@ angular.module('order_cycle', ['ngResource']).
return numActiveVariants;
},
enterpriseVariantsTotal: function(enterprise) {
enterpriseTotalVariants: function(enterprise) {
var numVariants = 0;
angular.forEach(enterprise.supplied_products, function(product) {

View File

@@ -24,7 +24,7 @@
%td.supplier_name {{ enterprises[exchange.enterprise_id].name }}
%td.products
= f.submit 'Products', 'ng-click' => 'toggleProducts($event, exchange)'
{{ exchangeVariantsSelected(exchange) }} / {{ enterpriseVariantsTotal(enterprises[exchange.enterprise_id]) }} selected
{{ exchangeSelectedVariants(exchange) }} / {{ enterpriseTotalVariants(enterprises[exchange.enterprise_id]) }} selected
%tr.products{'ng-show' => 'exchange.showProducts'}
%td{:colspan => 3}
= render 'exchange_product_form'

View File

@@ -13,8 +13,8 @@ describe 'OrderCycle controllers', ->
preventDefault: jasmine.createSpy('preventDefault')
OrderCycle =
order_cycle: 'my order cycle'
exchangeVariantsSelected: jasmine.createSpy('exchangeVariantsSelected').andReturn('variants selected')
enterpriseVariantsTotal: jasmine.createSpy('enterpriseVariantsTotal').andReturn('variants total')
exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').andReturn('variants selected')
enterpriseTotalVariants: jasmine.createSpy('enterpriseTotalVariants').andReturn('variants total')
toggleProducts: jasmine.createSpy('toggleProducts')
addSupplier: jasmine.createSpy('addSupplier')
create: jasmine.createSpy('create')
@@ -29,11 +29,11 @@ describe 'OrderCycle controllers', ->
it 'Loads order cycles', ->
expect(scope.order_cycle).toEqual('my order cycle')
it 'Delegates exchangeVariantsSelected and enterpriseVariantsTotal to OrderCycle', ->
expect(scope.exchangeVariantsSelected('exchange')).toEqual('variants selected')
expect(OrderCycle.exchangeVariantsSelected).toHaveBeenCalledWith('exchange')
expect(scope.enterpriseVariantsTotal('enterprise')).toEqual('variants total')
expect(OrderCycle.enterpriseVariantsTotal).toHaveBeenCalledWith('enterprise')
it 'Delegates exchangeSelectedVariants and enterpriseTotalVariants to OrderCycle', ->
expect(scope.exchangeSelectedVariants('exchange')).toEqual('variants selected')
expect(OrderCycle.exchangeSelectedVariants).toHaveBeenCalledWith('exchange')
expect(scope.enterpriseTotalVariants('enterprise')).toEqual('variants total')
expect(OrderCycle.enterpriseTotalVariants).toHaveBeenCalledWith('enterprise')
it 'Delegates toggleProducts to OrderCycle', ->
scope.toggleProducts(event, 'exchange')
@@ -67,8 +67,8 @@ describe 'OrderCycle controllers', ->
'example.com/admin/order_cycles/27/edit'
OrderCycle =
load: jasmine.createSpy('load')
exchangeVariantsSelected: jasmine.createSpy('exchangeVariantsSelected').andReturn('variants selected')
enterpriseVariantsTotal: jasmine.createSpy('enterpriseVariantsTotal').andReturn('variants total')
exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').andReturn('variants selected')
enterpriseTotalVariants: jasmine.createSpy('enterpriseTotalVariants').andReturn('variants total')
toggleProducts: jasmine.createSpy('toggleProducts')
addSupplier: jasmine.createSpy('addSupplier')
update: jasmine.createSpy('update')
@@ -83,11 +83,11 @@ describe 'OrderCycle controllers', ->
it 'Loads order cycles', ->
expect(OrderCycle.load).toHaveBeenCalledWith('27')
it 'Delegates exchangeVariantsSelected and enterpriseVariantsTotal to OrderCycle', ->
expect(scope.exchangeVariantsSelected('exchange')).toEqual('variants selected')
expect(OrderCycle.exchangeVariantsSelected).toHaveBeenCalledWith('exchange')
expect(scope.enterpriseVariantsTotal('enterprise')).toEqual('variants total')
expect(OrderCycle.enterpriseVariantsTotal).toHaveBeenCalledWith('enterprise')
it 'Delegates exchangeSelectedVariants and enterpriseTotalVariants to OrderCycle', ->
expect(scope.exchangeSelectedVariants('exchange')).toEqual('variants selected')
expect(OrderCycle.exchangeSelectedVariants).toHaveBeenCalledWith('exchange')
expect(scope.enterpriseTotalVariants('enterprise')).toEqual('variants total')
expect(OrderCycle.enterpriseTotalVariants).toHaveBeenCalledWith('enterprise')
it 'Delegates toggleProducts to OrderCycle', ->
scope.toggleProducts(event, 'exchange')
@@ -161,7 +161,7 @@ describe 'OrderCycle services', ->
describe 'counting variants', ->
it 'counts selected variants in an exchange', ->
result = OrderCycle.exchangeVariantsSelected({variants: {1: true, 2: false, 3: true}})
result = OrderCycle.exchangeSelectedVariants({variants: {1: true, 2: false, 3: true}})
expect(result).toEqual(2)
it 'counts total variants supplied by an enterprise', ->
@@ -172,7 +172,7 @@ describe 'OrderCycle services', ->
{variants: [{}, {}, {}]}
]
expect(OrderCycle.enterpriseVariantsTotal(enterprise)).toEqual(5)
expect(OrderCycle.enterpriseTotalVariants(enterprise)).toEqual(5)
describe 'toggling products', ->
exchange = null