From 0d0e404f3bd0a357e1def316d1ab48fa4358b130 Mon Sep 17 00:00:00 2001 From: Jason Boyer Date: Fri, 25 Aug 2017 11:13:22 -0400 Subject: [PATCH] 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 --- .../staff/cat/volcopy/t_attr_edit.tt2 | 6 ++-- .../js/ui/default/staff/cat/volcopy/app.js | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) 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', -- 2.43.2