From: Jason Boyer Date: Fri, 25 Aug 2017 15:13:22 +0000 (-0400) Subject: LP1713064: String / Float Value ACP Editor Fix X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0d0e404f3bd0a357e1def316d1ab48fa4358b130;p=working%2FEvergreen.git LP1713064: String / Float Value ACP Editor Fix Add an Angular directive to the vol/copy editor to convert and format numbers stored as strings in acp objects. Signed-off-by: Jason Boyer Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 b/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 index 70fac46e2b..6e40e32c41 100644 --- a/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 +++ b/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 @@ -225,7 +225,7 @@
- +
@@ -249,7 +249,7 @@
- +
@@ -319,7 +319,7 @@
- +
diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js index 19596b9c9c..285f5e8734 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -328,6 +328,34 @@ function(egCore , $q) { return service; }]) +.directive('stringToNumber', function() { + return { + require: 'ngModel', + link: function(scope, element, attrs, ngModel) { + var precision = attrs.precision || 0; + ngModel.$parsers.push(function(value) { + return value; + }); + + function updateDisplay() { + var value = parseFloat(ngModel.$viewValue); + if ( isNaN(value) ) { return; } + element.val(value.toFixed(precision)); + } + + ngModel.$formatters.push(function(value) { + return parseFloat(value); + }); + + ngModel.$viewChangeListeners.push(updateDisplay); + + ngModel.$render = function() { + updateDisplay(); + } + } + }; +}) + .directive("egVolCopyEdit", function () { return { restrict: 'E',