[open-ils-commits] [GIT] Evergreen ILS branch master updated. 3a787aebee4b689a3fd4c5a54357da8db878ec5a

Evergreen Git git at git.evergreen-ils.org
Fri Jan 5 10:47:35 EST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  3a787aebee4b689a3fd4c5a54357da8db878ec5a (commit)
      from  5cbd3ed1a981d7157c21997a88cd847389e928ae (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3a787aebee4b689a3fd4c5a54357da8db878ec5a
Author: Jason Boyer <jboyer at library.in.gov>
Date:   Thu Jan 4 12:55:16 2018 -0500

    LP1741072: Global String<->Num Directives for ngModel
    
    To increase flexibility the stringToNumber directive
    has been separated into int and float versions and
    aditional directives are added to convert in the other
    direction. The existing use of stringToNumber in the
    volume/copy editor are also converted to strToFloat.
    
    Signed-off-by: Jason Boyer <jboyer at library.in.gov>
    Signed-off-by: Bill Erickson <berickxx at gmail.com>

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 775c77b..8b61610 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
@@ -226,7 +226,7 @@
                     </select>
                 </div>
                 <div class="col-md-6" ng-class="{'bg-success': working.price !== undefined}">
-                    <input class="form-control" ng-disabled="!defaults.attributes.price" string-to-number ng-model="working.price" type="number" step="0.01"/>
+                    <input class="form-control" ng-disabled="!defaults.attributes.price" str-to-float ng-model="working.price" type="number" step="0.01"/>
                 </div>
             </div>
 
@@ -243,14 +243,14 @@
 
             <div class="row">
                 <div class="col-md-6" ng-class="{'bg-success': working.loan_duration !== undefined}">
-                    <select class="form-control" ng-disabled="!defaults.attributes.loan_duration" ng-model="working.loan_duration">
+                    <select class="form-control" int-to-str ng-disabled="!defaults.attributes.loan_duration" ng-model="working.loan_duration">
                         <option value="1">[% l('Short') %]</option>
                         <option value="2" selected>[% l('Normal') %]</option>
                         <option value="3">[% l('Extended') %]</option>
                     </select>
                 </div>
                 <div class="col-md-6" ng-class="{'bg-success': working.cost !== undefined}">
-                    <input class="form-control" ng-disabled="!defaults.attributes.cost" string-to-number ng-model="working.cost" type="number" step="0.01"/>
+                    <input class="form-control" ng-disabled="!defaults.attributes.cost" str-to-float ng-model="working.cost" type="number" step="0.01"/>
                 </div>
             </div>
 
@@ -370,7 +370,7 @@
 
             <div class="row">
                 <div class="col-md-6" ng-class="{'bg-success': working.fine_level !== undefined}">
-                    <select class="form-control" ng-disabled="!defaults.attributes.fine_level" ng-model="working.fine_level">
+                    <select class="form-control" int-to-str ng-disabled="!defaults.attributes.fine_level" ng-model="working.fine_level">
                         <option value="1">[% l('Low') %]</option>
                         <option value="2" selected>[% l('Normal') %]</option>
                         <option value="3">[% l('High') %]</option>
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 d856ce6..2efd975 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
@@ -333,11 +333,6 @@ function(egCore , $q) {
                         if ( curr_field["type"] === "stat_cat" ) {
                             stat_cats[field_name] = parseInt(curr_field["value"]);
                         } else {
-                            tmp_val = curr_field['value']; // so... some of the number fields are actually strings. Groovy.
-                            if ( tmp_val.toString().match(/^[-0-9.]+$/) && !(field_name.match(/(?:loan_duration|fine_level)/))) {
-                                tmp_val = parseFloat(tmp_val);
-                            }
-
                             if (field_name.match(/^batch_.*_menulist$/)) {
                                 // special handling for volume fields
                                 if (!("callnumber" in curr_templ)) curr_templ["callnumber"] = {};
@@ -446,21 +441,6 @@ function(egCore , $q) {
     return service;
 }])
 
-.directive('stringToNumber', function() {
-    return {
-        require: 'ngModel',
-        link: function(scope, element, attrs, ngModel) {
-            ngModel.$parsers.push(function(value) {
-                return value;
-            });
-
-            ngModel.$formatters.push(function(value) {
-                return parseFloat(value);
-            });
-        }
-    };
-})
-
 .directive("egVolCopyEdit", function () {
     return {
         restrict: 'E',
diff --git a/Open-ILS/web/js/ui/default/staff/services/ui.js b/Open-ILS/web/js/ui/default/staff/services/ui.js
index 76d5425..47632ed 100644
--- a/Open-ILS/web/js/ui/default/staff/services/ui.js
+++ b/Open-ILS/web/js/ui/default/staff/services/ui.js
@@ -73,6 +73,69 @@ function($timeout , $parse) {
     };
 }])
 
+// <select int-to-str ><option value="1">Value</option></select>
+// use integer models for string values
+.directive('intToStr', function() {
+    return {
+        restrict: 'A',
+        require: 'ngModel',
+        link: function(scope, element, attrs, ngModel) {
+            ngModel.$parsers.push(function(value) {
+                return parseInt(value);
+            });
+            ngModel.$formatters.push(function(value) {
+                return '' + value;
+            });
+        }
+    };
+})
+
+// <input str-to-int value="10"/>
+.directive('strToInt', function() {
+    return {
+        restrict: 'A',
+        require: 'ngModel',
+        link: function(scope, element, attrs, ngModel) {
+            ngModel.$parsers.push(function(value) {
+                return '' + value;
+            });
+            ngModel.$formatters.push(function(value) {
+                return parseInt(value);
+            });
+        }
+    };
+})
+
+// <input float-to-str
+.directive('floatToStr', function() {
+    return {
+        restrict: 'A',
+        require: 'ngModel',
+        link: function(scope, element, attrs, ngModel) {
+            ngModel.$parsers.push(function(value) {
+                return parseFloat(value);
+            });
+            ngModel.$formatters.push(function(value) {
+                return '' + value;
+            });
+        }
+    };
+})
+
+.directive('strToFloat', function() {
+    return {
+        restrict: 'A',
+        require: 'ngModel',
+        link: function(scope, element, attrs, ngModel) {
+            ngModel.$parsers.push(function(value) {
+                return '' + value;
+            });
+            ngModel.$formatters.push(function(value) {
+                return parseFloat(value);
+            });
+        }
+    };
+})
 
 // 'reverse' filter 
 // <div ng-repeat="item in items | reverse">{{item.name}}</div>

-----------------------------------------------------------------------

Summary of changes:
 .../templates/staff/cat/volcopy/t_attr_edit.tt2    |    8 +-
 .../web/js/ui/default/staff/cat/volcopy/app.js     |   20 ------
 Open-ILS/web/js/ui/default/staff/services/ui.js    |   63 ++++++++++++++++++++
 3 files changed, 67 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list