mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-01 21:47:16 +00:00
React to form changes, compute unit price and display accurate values.
- Add method `processUnitPrice` which is responsible for computing the right unit price, that depends on `price`, `variant_unit_scale`, `variant_unit`, `unit_value` and `variant_unit_name` - Watch the needed model to compute the unit price: `product.price` and `product.variant_unit_name` - Add dependencies : UnitPrices and localizeCurrencyFilter - Add currencyconfig to spec, as it's needed by localizeCurrencyFilter - Put `'ng-controller' => 'unitsCtrl'` to the relevant node. - Add new ng-model, as it's needed to watch it in order to compute unit price : `product.price` - Finally display the needed information: `product.unit_price_value` and `product.unit_price_unit`
This commit is contained in:
@@ -2,11 +2,17 @@ describe "unitsCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
product = null
|
||||
currencyconfig =
|
||||
symbol: "$"
|
||||
symbol_position: "before"
|
||||
currency: "D"
|
||||
hide_cents: "false"
|
||||
|
||||
beforeEach ->
|
||||
module('admin.products')
|
||||
module ($provide)->
|
||||
$provide.value "availableUnits", "g,kg,T,mL,L,kL"
|
||||
$provide.value "currencyConfig", currencyconfig
|
||||
null
|
||||
inject ($rootScope, $controller, VariantUnitManager) ->
|
||||
scope = $rootScope
|
||||
|
||||
Reference in New Issue
Block a user