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:
Jean-Baptiste Bellet
2021-03-08 12:22:58 +01:00
parent 8ad3109e95
commit fa4974ddb2
3 changed files with 26 additions and 8 deletions

View File

@@ -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