LP#1618949 Always show required stat cats in patron edit user/berick/lp1618949-webstaff-patron-edit-required-cats
authorBill Erickson <berickxx@gmail.com>
Tue, 13 Dec 2016 18:50:08 +0000 (13:50 -0500)
committerBill Erickson <berickxx@gmail.com>
Tue, 13 Dec 2016 18:55:06 +0000 (13:55 -0500)
Required stat cats are now always visible in the browser client
patron editor.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/circ/patron/t_edit.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index 5543e9d..57d508b 100644 (file)
@@ -845,12 +845,20 @@ within the "form" by name for validation.
 </div>
 
 <div class="alert alert-success row" role="alert" 
-    ng-show="show_field('stat_cats')" ng-if="stat_cats.length > 0">
+    ng-show="show_field('stat_cats') || has_required_stat_cat" 
+    ng-if="stat_cats.length > 0">
     <div class="col-md-6">[% l('Statistical Categories') %]</div>
 </div>
 
 <div class="row reg-field-row" 
-    ng-show="show_field('stat_cats')" ng-repeat="cat in stat_cats">
+    ng-show="show_field('stat_cats') || has_required_stat_cat" 
+    ng-repeat="cat in stat_cats">
+
+  <!-- Display this stat cat when displaying all stat cats
+       or when this stat cat is required.  Wrap the body of 
+       stat cat display in a div for easy show/hide.  -->
+  <div ng-if="show_field('stat_cats') || cat.required() == 1">
+
   <div class="col-md-3 reg-field-label">
     <label>{{cat.name()}}</label>
   </div>
@@ -891,6 +899,7 @@ within the "form" by name for validation.
   <div class="col-md-3 reg-field-input" ng-if="cat.allow_freetext() == '1'">
     <input type="text" ng-model="stat_cat_entry_maps[cat.id()]"/>
   </div>
+  </div><!-- show/hide -->
 </div>
 
 <!-- surveys -->
index 1005453..e77d487 100644 (file)
@@ -1215,6 +1215,9 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
         if ($scope.patron.isnew) 
             set_new_patron_defaults(prs);
 
+        $scope.has_required_stat_cat = prs.stat_cats.filter(
+                function(cat) {return cat.required() == 1} ).length > 0;
+
         $scope.page_data_loaded = true;
 
         prs.set_field_patterns(field_patterns);