mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Use Kilolitres instead of Megalitres. Megalitres are REALLY big!
This commit is contained in:
@@ -139,7 +139,7 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [
|
||||
validScales = []
|
||||
unitScales =
|
||||
'weight': [1.0, 1000.0, 1000000.0]
|
||||
'volume': [0.001, 1.0, 1000000.0]
|
||||
'volume': [0.001, 1.0, 1000.0]
|
||||
|
||||
validScales.unshift scale for scale in unitScales[unitType] when value/scale >= 1
|
||||
if validScales.length > 0
|
||||
@@ -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', 1000000.0: 'ML'}
|
||||
'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 (ML)", "volume_1000000"],
|
||||
["Volume (KL)", "volume_1000"],
|
||||
["Items", "items"]
|
||||
]
|
||||
|
||||
@@ -511,12 +511,12 @@ filterSubmitVariant = (variant) ->
|
||||
|
||||
toObjectWithIDKeys = (array) ->
|
||||
object = {}
|
||||
|
||||
|
||||
for i of array
|
||||
if array[i] instanceof Object and array[i].hasOwnProperty("id")
|
||||
object[array[i].id] = angular.copy(array[i])
|
||||
object[array[i].id].variants = toObjectWithIDKeys(array[i].variants) if array[i].hasOwnProperty("variants") and array[i].variants instanceof Array
|
||||
|
||||
|
||||
object
|
||||
|
||||
subset = (bigArray,smallArray) ->
|
||||
|
||||
@@ -2,7 +2,7 @@ angular.module("admin.products")
|
||||
.controller "unitsCtrl", ($scope) ->
|
||||
$scope.product = { master: {} }
|
||||
|
||||
$scope.$watch ->
|
||||
$scope.$watch ->
|
||||
$scope.product.variant_unit_with_scale
|
||||
, ->
|
||||
if $scope.product.variant_unit_with_scale
|
||||
@@ -16,7 +16,7 @@ angular.module("admin.products")
|
||||
else
|
||||
$scope.product.variant_unit = $scope.product.variant_unit_scale = null
|
||||
|
||||
$scope.$watch ->
|
||||
$scope.$watch ->
|
||||
$scope.product.master.unit_value_with_description
|
||||
, ->
|
||||
if $scope.product.master.hasOwnProperty("unit_value_with_description")
|
||||
@@ -33,7 +33,7 @@ angular.module("admin.products")
|
||||
["Weight (T)", "weight_1000000"],
|
||||
["Volume (mL)", "volume_0.001"],
|
||||
["Volume (L)", "volume_1"],
|
||||
["Volume (ML)", "volume_1000000"],
|
||||
["Volume (KL)", "volume_1000"],
|
||||
["Items", "items"]
|
||||
]
|
||||
|
||||
@@ -43,4 +43,4 @@ angular.module("admin.products")
|
||||
$scope.hasUnit = (product) ->
|
||||
product.variant_unit_with_scale?
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,18 +18,18 @@ angular.module("ofn.admin").factory "optionValueNamer", ($resource) ->
|
||||
if @variant.unit_value?
|
||||
if @variant.product.variant_unit in ["weight", "volume"]
|
||||
[value, unit_name] = @option_value_value_unit_scaled()
|
||||
|
||||
|
||||
else
|
||||
value = @variant.unit_value
|
||||
unit_name = @variant.product.variant_unit_name
|
||||
# TODO needs to add pluralize to line below
|
||||
# unit_name = unit_name if value > 1
|
||||
|
||||
|
||||
value = parseInt(value, 10) if value == parseInt(value, 10)
|
||||
|
||||
|
||||
else
|
||||
value = unit_name = null
|
||||
|
||||
|
||||
[value, unit_name]
|
||||
|
||||
option_value_value_unit_scaled: ->
|
||||
@@ -40,7 +40,7 @@ angular.module("ofn.admin").factory "optionValueNamer", ($resource) ->
|
||||
[value, unit_name]
|
||||
|
||||
scale_for_unit_value: ->
|
||||
units =
|
||||
units =
|
||||
'weight':
|
||||
1.0: 'g'
|
||||
1000.0: 'kg'
|
||||
@@ -48,7 +48,7 @@ angular.module("ofn.admin").factory "optionValueNamer", ($resource) ->
|
||||
'volume':
|
||||
0.001: 'mL'
|
||||
1.0: 'L'
|
||||
1000000.0: 'ML'
|
||||
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.
|
||||
@@ -63,4 +63,4 @@ angular.module("ofn.admin").factory "optionValueNamer", ($resource) ->
|
||||
if scale < unit[0] then [scale, unit_name] else unit
|
||||
, [Infinity,""]
|
||||
|
||||
unit
|
||||
unit
|
||||
|
||||
Reference in New Issue
Block a user