mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Change KL to kL, update specs for ML to kL change
This commit is contained in:
@@ -150,7 +150,7 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [
|
||||
$scope.getUnitName = (scale, unitType) ->
|
||||
unitNames =
|
||||
'weight': {1.0: 'g', 1000.0: 'kg', 1000000.0: 'T'}
|
||||
'volume': {0.001: 'mL', 1.0: 'L', 1000.0: 'KL'}
|
||||
'volume': {0.001: 'mL', 1.0: 'L', 1000.0: 'kL'}
|
||||
unitNames[unitType][scale]
|
||||
|
||||
$scope.formattedValueWithUnitName = (value, unitsProduct, unitsVariant) ->
|
||||
|
||||
@@ -20,7 +20,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", [
|
||||
["Weight (T)", "weight_1000000"],
|
||||
["Volume (mL)", "volume_0.001"],
|
||||
["Volume (L)", "volume_1"],
|
||||
["Volume (KL)", "volume_1000"],
|
||||
["Volume (kL)", "volume_1000"],
|
||||
["Items", "items"]
|
||||
]
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ angular.module("admin.products")
|
||||
["Weight (T)", "weight_1000000"],
|
||||
["Volume (mL)", "volume_0.001"],
|
||||
["Volume (L)", "volume_1"],
|
||||
["Volume (KL)", "volume_1000"],
|
||||
["Volume (kL)", "volume_1000"],
|
||||
["Items", "items"]
|
||||
]
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ angular.module("admin.products").factory "optionValueNamer", ->
|
||||
'volume':
|
||||
0.001: 'mL'
|
||||
1.0: 'L'
|
||||
1000.0: 'KL'
|
||||
1000.0: 'kL'
|
||||
|
||||
# Find the largest available unit where unit_value comes to >= 1 when expressed in it.
|
||||
# If there is none available where this is true, use the smallest available unit.
|
||||
|
||||
@@ -44,7 +44,7 @@ module OpenFoodNetwork
|
||||
|
||||
def scale_for_unit_value
|
||||
units = {'weight' => {1.0 => 'g', 1000.0 => 'kg', 1000000.0 => 'T'},
|
||||
'volume' => {0.001 => 'mL', 1.0 => 'L', 1000.0 => 'KL'}}
|
||||
'volume' => {0.001 => 'mL', 1.0 => 'L', 1000.0 => 'kL'}}
|
||||
|
||||
# Find the largest available unit where unit_value comes to >= 1 when expressed in it.
|
||||
# If there is none available where this is true, use the smallest available unit.
|
||||
|
||||
@@ -87,7 +87,7 @@ describe "Option Value Namer", ->
|
||||
expect(namer.option_value_value_unit()).toEqual [100, unit]
|
||||
|
||||
it "generates values for all volume scales", ->
|
||||
for units in [[0.001, 'mL'], [1.0, 'L'], [1000000.0, 'ML']]
|
||||
for units in [[0.001, 'mL'], [1.0, 'L'], [1000.0, 'kL']]
|
||||
[scale, unit] = units
|
||||
p.variant_unit = 'volume'
|
||||
p.variant_unit_scale = scale
|
||||
|
||||
@@ -352,7 +352,7 @@ describe "AdminOrderMgmtCtrl", ->
|
||||
expect(scope.getScale(1.2,"weight")).toEqual 1.0
|
||||
expect(scope.getScale(1000,"weight")).toEqual 1000.0
|
||||
expect(scope.getScale(0.0012,"volume")).toEqual 0.001
|
||||
expect(scope.getScale(1001,"volume")).toEqual 1.0
|
||||
expect(scope.getScale(1001,"volume")).toEqual 1000.0
|
||||
|
||||
it "returns the smallest unit available when value is smaller", ->
|
||||
expect(scope.getScale(0.4,"weight")).toEqual 1
|
||||
@@ -365,7 +365,7 @@ describe "AdminOrderMgmtCtrl", ->
|
||||
expect(scope.getUnitName(1000000,"weight")).toEqual "T"
|
||||
expect(scope.getUnitName(0.001,"volume")).toEqual "mL"
|
||||
expect(scope.getUnitName(1,"volume")).toEqual "L"
|
||||
expect(scope.getUnitName(1000000,"volume")).toEqual "ML"
|
||||
expect(scope.getUnitName(1000,"volume")).toEqual "kL"
|
||||
|
||||
describe "managing pending changes", ->
|
||||
dataSubmitter = pendingChangesService = null
|
||||
|
||||
@@ -94,7 +94,7 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
it "generates values for all volume scales" do
|
||||
[[0.001, 'mL'], [1.0, 'L'], [1000000.0, 'ML']].each do |scale, unit|
|
||||
[[0.001, 'mL'], [1.0, 'L'], [1000.0, 'kL']].each do |scale, unit|
|
||||
p = double(:product, variant_unit: 'volume', variant_unit_scale: scale)
|
||||
v.stub(:product) { p }
|
||||
v.stub(:unit_value) { 100 * scale }
|
||||
@@ -133,4 +133,4 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user