mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Adding option to 'Inherit From Product' for enterprise_fee tax categories
This commit is contained in:
@@ -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 = ->
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user