LP1789982: Allow Null Values in Numeric ACP Fields user/jboyer/lp1789982_acp_numeric_fields
authorJason Boyer <jboyer@library.in.gov>
Fri, 19 Oct 2018 16:22:59 +0000 (12:22 -0400)
committerJason Boyer <jboyer@library.in.gov>
Fri, 19 Oct 2018 16:22:59 +0000 (12:22 -0400)
Because of the way Angular treats model values there needs
to be a translation between strings and numbers (hence the
str-to-* and *-to-str directives) but this can end up trying
to save empty numeric values as the literal string 'null',
which blows up when saving the item. In order to allow
saving items with empty prices, costs, or deposits, we're
better off treating them as plain strings with a regex
validator for now.

Signed-off-by: Jason Boyer <jboyer@library.in.gov>
Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index b133c7a..0cf06ac 100644 (file)
                     </div>
                 </div>
                 <div class="col-md-6" ng-class="{'bg-success': working.price !== undefined}">
-                    <input class="form-control" ng-disabled="!defaults.attributes.price" str-to-float ng-model="working.price" type="number" step="0.01"/>
+                    <input class="form-control" ng-disabled="!defaults.attributes.price" ng-model="working.price" type="text" pattern="\d+(?:|\.\d\d)"/>
                     <div class="container" ng-show="working.MultiMap.price.length > 1 && working.price === undefined">
                         <eg-list-counts label="[% l('Multiple prices') %]" list="working.MultiMap.price" on-select="select_by_price"></eg-list-counts>
                     </div>
                     </div>
                 </div>
                 <div class="col-md-6" ng-class="{'bg-success': working.cost !== undefined}">
-                    <input class="form-control" ng-disabled="!defaults.attributes.cost" str-to-float ng-model="working.cost" type="number" step="0.01"/>
+                    <input class="form-control" ng-disabled="!defaults.attributes.cost" ng-model="working.cost" type="text" pattern="\d+(?:|\.\d\d)"/>
                     <div class="container" ng-show="working.MultiMap.cost.length > 1 && working.cost === undefined">
                         <eg-list-counts label="[% l('Multiple costs') %]" list="working.MultiMap.cost" on-select="select_by_cost"></eg-list-counts>
                     </div>
                     </div>
                 </div>
                 <div class="col-md-6" ng-class="{'bg-success': working.deposit_amount !== undefined}">
-                    <input class="form-control" ng-disabled="!defaults.attributes.deposit_amount" str-to-float ng-model="working.deposit_amount" type="number" step="0.01"/>
+                    <input class="form-control" ng-disabled="!defaults.attributes.deposit_amount" ng-model="working.deposit_amount" type="text" pattern="\d+(?:|\.\d\d)"/>
                     <div class="container" ng-show="working.MultiMap.deposit_amount.length > 1 && working.deposit_amount === undefined">
                         <eg-list-counts label="[% l('Multiple amounts') %]" list="working.MultiMap.deposit_amount" on-select="select_by_deposit_amount"></eg-list-counts>
                     </div>
index a289134..4b43c21 100644 (file)
@@ -448,8 +448,6 @@ function(egCore , $q) {
         cp.circ_lib( owningLib );
         cp.call_number( callNumber );
         cp.deposit(0);
-        cp.price(0);
-        cp.deposit_amount(0);
         cp.fine_level(2); // Normal
         cp.loan_duration(2); // Normal
         cp.location(1); // Stacks