Adding option to 'Inherit From Product' for enterprise_fee tax categories

This commit is contained in:
Rob Harrington
2016-02-04 15:35:49 +11:00
parent a66582a8fb
commit caa8818f02
11 changed files with 48 additions and 63 deletions

View File

@@ -1,6 +1,6 @@
angular.module('admin.enterpriseFees').controller 'enterpriseFeesCtrl', ($scope, $http, $window, enterprises, tax_categories, calculators) ->
$scope.enterprises = enterprises
$scope.tax_categories = tax_categories
$scope.tax_categories = [{id: -1, name: "Inherit From Product"}].concat tax_categories
$scope.calculators = calculators
$scope.enterpriseFeesUrl = ->

View File

@@ -0,0 +1,15 @@
angular.module("admin.enterpriseFees").directive 'watchTaxCategory', ->
# In order to have a nice user experience on this page, we're modelling tax_category
# inheritance using tax_category_id = -1.
# This directive acts as a parser for tax_category_id, storing the value the form as "" when
# tax_category is to be inherited and setting inherits_tax_category as appropriate.
(scope, element, attrs) ->
scope.$watch 'enterprise_fee.tax_category_id', (value) ->
if value == -1
scope.enterprise_fee.inherits_tax_category = true
element.val("")
else
scope.enterprise_fee.inherits_tax_category = false
element.val(value)
scope.enterprise_fee.tax_category_id = -1 if scope.enterprise_fee.inherits_tax_category