Switch to class case for OptionValueNamer

This commit is contained in:
Rohan Mitchell
2014-07-18 10:06:13 +10:00
parent 91e4f24fde
commit 6c59ffc16f
6 changed files with 19 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [
"$scope", "$http", "dataFetcher", "blankOption", "pendingChanges", "optionValueNamer",
($scope, $http, dataFetcher, blankOption, pendingChanges, optionValueNamer) ->
"$scope", "$http", "dataFetcher", "blankOption", "pendingChanges", "OptionValueNamer",
($scope, $http, dataFetcher, blankOption, pendingChanges, OptionValueNamer) ->
$scope.initialiseVariables = ->
start = daysFromToday -7
@@ -137,7 +137,7 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [
$scope.getScale = (value, unitType) ->
scaledValue = null
validScales = []
unitScales = optionValueNamer.unitScales(unitType)
unitScales = OptionValueNamer.unitScales(unitType)
validScales.unshift scale for scale in unitScales when value/scale >= 1
if validScales.length > 0
@@ -146,7 +146,7 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [
unitScales[0]
$scope.getUnitName = (scale, unitType) ->
optionValueNamer.getUnitName(scale, unitType)
OptionValueNamer.getUnitName(scale, unitType)
$scope.formattedValueWithUnitName = (value, unitsProduct, unitsVariant) ->
# A Units Variant is an API object which holds unit properies of a variant

View File

@@ -1,6 +1,6 @@
angular.module("ofn.admin").controller "AdminProductEditCtrl", [
"$scope", "$timeout", "$http", "dataFetcher", "DirtyProducts", "optionValueNamer",
($scope, $timeout, $http, dataFetcher, DirtyProducts, optionValueNamer) ->
"$scope", "$timeout", "$http", "dataFetcher", "DirtyProducts", "OptionValueNamer",
($scope, $timeout, $http, dataFetcher, DirtyProducts, OptionValueNamer) ->
$scope.updateStatusMessage =
text: ""
style: {}
@@ -14,7 +14,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", [
taxons: {name: "Taxons", visible: false}
available_on: {name: "Available On", visible: false}
$scope.variant_unit_options = optionValueNamer.variant_unit_options
$scope.variant_unit_options = OptionValueNamer.variant_unit_options
$scope.filterableColumns = [
{ name: "Supplier", db_column: "supplier_name" },

View File

@@ -1,4 +1,4 @@
angular.module("ofn.admin").directive "ofnDisplayAs", (optionValueNamer) ->
angular.module("ofn.admin").directive "ofnDisplayAs", (OptionValueNamer) ->
link: (scope, element, attrs) ->
scope.$watchCollection ->
@@ -18,7 +18,7 @@ angular.module("ofn.admin").directive "ofnDisplayAs", (optionValueNamer) ->
variant_unit: variant_unit
variant_unit_name: scope.product.variant_unit_name
scope.placeholder_text = new optionValueNamer(variant_object).name()
scope.placeholder_text = new OptionValueNamer(variant_object).name()
productUnitProperties = ->
# get relevant product properties

View File

@@ -1,5 +1,5 @@
angular.module("admin.products")
.controller "unitsCtrl", ($scope, optionValueNamer) ->
.controller "unitsCtrl", ($scope, OptionValueNamer) ->
$scope.product = { master: {} }
$scope.product.master.product = $scope.product
$scope.placeholder_text = ""
@@ -24,9 +24,9 @@ angular.module("admin.products")
$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.placeholder_text = new optionValueNamer($scope.product.master).name()
$scope.placeholder_text = new OptionValueNamer($scope.product.master).name()
$scope.variant_unit_options = optionValueNamer.variant_unit_options
$scope.variant_unit_options = OptionValueNamer.variant_unit_options
$scope.hasVariants = (product) ->
Object.keys(product.variants).length > 0

View File

@@ -1,4 +1,4 @@
angular.module("admin.products").factory "optionValueNamer", ->
angular.module("admin.products").factory "OptionValueNamer", ->
class OptionValueNamer
@getUnitName: (scale, unitType) ->
unitNames =

View File

@@ -1,17 +1,17 @@
describe "Option Value Namer", ->
optionValueNamer = null
OptionValueNamer = null
beforeEach ->
module "ofn.admin"
beforeEach inject (_optionValueNamer_) ->
optionValueNamer = _optionValueNamer_
beforeEach inject (_OptionValueNamer_) ->
OptionValueNamer = _OptionValueNamer_
describe "generating option value name", ->
v = namer = null
beforeEach ->
v = {}
namer = new optionValueNamer(v)
namer = new OptionValueNamer(v)
it "when description is blank", ->
v.unit_description = null
@@ -43,7 +43,7 @@ describe "Option Value Namer", ->
beforeEach ->
p = {}
v = { product: p }
namer = new optionValueNamer(v)
namer = new OptionValueNamer(v)
it "returns true when the product has a scale", ->
p.variant_unit_scale = 1000
@@ -58,7 +58,7 @@ describe "Option Value Namer", ->
beforeEach ->
p = {}
v = { product: p }
namer = new optionValueNamer(v)
namer = new OptionValueNamer(v)
it "generates simple values", ->
p.variant_unit = 'weight'