From e89b782787ecef89387569ac8b3a64d7010049f7 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 2 Jul 2014 23:20:54 +0100 Subject: [PATCH] Use Kilolitres instead of Megalitres. Megalitres are REALLY big! --- .../admin/bulk_order_management.js.coffee | 4 ++-- .../admin/bulk_product_update.js.coffee | 6 +++--- .../admin/products/units_controller.js.coffee | 8 ++++---- .../admin/services/option_value_namer.js.coffee | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/admin/bulk_order_management.js.coffee b/app/assets/javascripts/admin/bulk_order_management.js.coffee index 9ba34790a8..a874944b4f 100644 --- a/app/assets/javascripts/admin/bulk_order_management.js.coffee +++ b/app/assets/javascripts/admin/bulk_order_management.js.coffee @@ -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) -> diff --git a/app/assets/javascripts/admin/bulk_product_update.js.coffee b/app/assets/javascripts/admin/bulk_product_update.js.coffee index ba9c1fa18d..9fd3b62f21 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js.coffee +++ b/app/assets/javascripts/admin/bulk_product_update.js.coffee @@ -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) -> diff --git a/app/assets/javascripts/admin/products/units_controller.js.coffee b/app/assets/javascripts/admin/products/units_controller.js.coffee index 9070648e21..c0fd9273ac 100644 --- a/app/assets/javascripts/admin/products/units_controller.js.coffee +++ b/app/assets/javascripts/admin/products/units_controller.js.coffee @@ -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? - \ No newline at end of file + diff --git a/app/assets/javascripts/admin/services/option_value_namer.js.coffee b/app/assets/javascripts/admin/services/option_value_namer.js.coffee index 8d127f01c7..ef8ed6e1aa 100644 --- a/app/assets/javascripts/admin/services/option_value_namer.js.coffee +++ b/app/assets/javascripts/admin/services/option_value_namer.js.coffee @@ -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 \ No newline at end of file + unit