mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
12 lines
404 B
CoffeeScript
12 lines
404 B
CoffeeScript
angular.module("admin.enterprises").directive "invertNumber", ->
|
|
restrict: "A"
|
|
require: "ngModel"
|
|
link: (scope, element, attrs, ngModel) ->
|
|
ngModel.$parsers.push (viewValue) ->
|
|
return -parseInt(viewValue) unless isNaN(parseInt(viewValue))
|
|
viewValue
|
|
|
|
ngModel.$formatters.push (modelValue) ->
|
|
return -parseInt(modelValue) unless isNaN(parseInt(modelValue))
|
|
modelValue
|