LP#1452950 required/suggested/all fields selectors
authorBill Erickson <berickxx@gmail.com>
Sat, 15 Aug 2015 19:41:59 +0000 (15:41 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 25 Feb 2016 22:31:55 +0000 (17:31 -0500)
Wire up links for Required, suggested, and All fields links.

Also move the patron control bar out to its own template since it must
be loaded from 2 different places in the markup, one for edit and one
for register.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/index.tt2
Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/circ/patron/t_edit.tt2
Open-ILS/src/templates/staff/css/circ.css.tt2
Open-ILS/src/templates/staff/css/style.css.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index a224fa1..1db25c2 100644 (file)
@@ -145,29 +145,7 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
       </li>
     </ul>
     <div class="flex-row patron-reg-actions-bar" ng-if="is_patron_edit()">
-      <div>
-        <span>
-          [% l('Show:') %]
-          <span class="pad-all-min" ng-show="!display_required_fields">
-            <a href>[% l('Required Fields') %]</a>
-          </span>
-          <span class="pad-all-min" ng-show="!display_suggested_fields">
-            <a href>[% l('Suggested Fields') %]</a>
-          </span>
-          <span class="pad-all-min" ng-show="!display_all_fields">
-            <a href>[% l('All Fields') %]</a>
-          </span>
-        </span>
-      </div>
-      <div class="flex-cell"></div>
-      <div>
-        <span class="pad-all-min">
-          <button type="button" class="btn btn-default">[% l('Save') %]</button>
-        </span>
-        <span class="pad-all-min">
-          <button type="button" class="btn btn-default">[% l('Save & Clone') %]</button>
-        </span>
-      </div>
+      [% INCLUDE 'staff/circ/patron/reg_actions.tt2' %]
     </div>
 
   </div><!-- col -->
diff --git a/Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2 b/Open-ILS/src/templates/staff/circ/patron/reg_actions.tt2
new file mode 100644 (file)
index 0000000..12aa57f
--- /dev/null
@@ -0,0 +1,32 @@
+<!-- actions bar shared by both variations of the patron edit UI -->
+
+<div>
+  <span>
+    [% l('Show:') %]
+    <span class="pad-all-min">
+      <a href 
+        ng-class="{disabled : edit_passthru.vis_level == 2}"
+        ng-click="edit_passthru.vis_level=2">[% l('Required Fields') %]</a>
+    </span>
+    <span class="pad-all-min">
+      <a href 
+        ng-class="{disabled : edit_passthru.vis_level == 1}"
+        ng-click="edit_passthru.vis_level=1">[% l('Suggested Fields') %]</a>
+    </span>
+    <span class="pad-all-min">
+      <a href 
+        ng-class="{disabled : edit_passthru.vis_level == 0}"
+        ng-click="edit_passthru.vis_level=0">[% l('All Fields') %]</a>
+    </span>
+  </span>
+</div>
+<div class="flex-cell"></div>
+<div>
+  <span class="pad-all-min">
+    <button type="button" class="btn btn-default">[% l('Save') %]</button>
+  </span>
+  <span class="pad-all-min">
+    <button type="button" class="btn btn-default">[% l('Save & Clone') %]</button>
+  </span>
+</div>
+
index 8d82201..29c15ec 100644 (file)
   </div>
 
   <div class="flex-row" class='patron-reg-actions-bar'>
-    <div>
-      <span>
-        [% l('Show:') %]
-        <span class="pad-all-min" ng-show="!display_required_fields">
-          <a href>[% l('Required Fields') %]</a>
-        </span>
-        <span class="pad-all-min" ng-show="!display_suggested_fields">
-          <a href>[% l('Suggested Fields') %]</a>
-        </span>
-        <span class="pad-all-min" ng-show="!display_all_fields">
-          <a href>[% l('All Fields') %]</a>
-        </span>
-      </span>
-    </div>
-    <div class="flex-cell"></div>
-    <div>
-      <span class="pad-all-min">
-        <button type="button" class="btn btn-default">[% l('Save') %]</button>
-      </span>
-      <span class="pad-all-min">
-        <button type="button" class="btn btn-default">[% l('Save & Clone') %]</button>
-      </span>
-    </div>
+    [% INCLUDE 'staff/circ/patron/reg_actions.tt2' %]
   </div>
 </div>
 
+
 <!-- edit banner -->
 <div ng-if="patron_id"
     class="strong-text-2">[% l('Patron Edit') %]</div>
 
   IF NOT input_type; input_type = 'text'; END %] 
 
-<div class="row reg-field-row">
+<div class="row reg-field-row" 
+  ng-show="show_field('[% cls _ '.' _ field %]')">
 
   <div class="col-md-3 reg-field-label"> <!-- field label -->
 
-  <label>{{idl_fields.[% cls %].[% field %].label}}</label>
+    <label>{{idl_fields.[% cls %].[% field %].label}}</label>
 
-  <!-- field documentation img/link -->
-  <img ng-show="field_doc.[% cls %].[% field %]" 
-    ng-click="selected_field_doc=field_doc.[% cls %].[% field %]"
-    src='[% DOC_IMG %]'></img>
+    <!-- field documentation img/link -->
+    <img ng-show="field_doc.[% cls %].[% field %]" 
+      ng-click="selected_field_doc=field_doc.[% cls %].[% field %]"
+      src='[% DOC_IMG %]'></img>
   </div>
 
   <div class="col-md-3 reg-field-input"> <!-- field form input -->
 [% formfield('au', 'suffix') %]
 [% formfield('au', 'alias') %]
 
-<div class="row reg-field-row">
+<div class="row reg-field-row" ng-show="show_field('au.dob')">
   <div class="col-md-3 reg-field-label">
     <label>{{idl_fields.au.dob.label}}</label>
     <img ng-show="field_doc.au.dob" 
 
 <!-- ident_type -->
 
-<div class="row reg-field-row">
+<div class="row reg-field-row" ng-show="show_field('au.ident_type')">
   <div class="col-md-3 reg-field-label">
     <label>{{idl_fields.au.ident_type.label}}</label>
     <img ng-show="field_doc.au.ident_type" 
 
 <!-- home org unit selector -->
 
-<div class="row reg-field-row">
+<div class="row reg-field-row" ng-show="show_field('au.home_ou')">
   <div class="col-md-3 reg-field-label">
     <label>{{idl_fields.au.home_ou.label}}</label>
     <img ng-show="field_doc.au.home_ou" 
 
 <!-- profile selector -->
 
-<div class="row reg-field-row">
+<div class="row reg-field-row" ng-show="show_field('au.profile')">
   <div class="col-md-3 reg-field-label">
     <label>{{idl_fields.au.profile.label}}</label>
     <img ng-show="field_doc.au.profile" 
   </div>
 </div>
 
-<div class="row reg-field-row">
+<div class="row reg-field-row" ng-show="show_field('au.expire_date')">
   <div class="col-md-3 reg-field-label">
   <label>{{idl_fields.au.expire_date.label}}</label>
     <img ng-show="field_doc.au.expire_date" 
 
 <!-- net_access_level -->
 
-<div class="row reg-field-row">
+<div class="row reg-field-row" ng-show="show_field('au.net_access_level')">
   <div class="col-md-3 reg-field-label">
     <label>{{idl_fields.au.net_access_level.label}}</label>
     <img ng-show="field_doc.au.net_access_level" 
 
 <!-- pending address -->
 
-<div class="alert alert-success row" role="alert" ng-if="stat_cats.length > 0">
+<div class="alert alert-success row" role="alert" 
+    ng-show="show_field('stat_cats')" ng-if="stat_cats.length > 0">
     <div class="col-md-6">[% l('Statistical Categories') %]</div>
 </div>
 
-<div class="row reg-field-row" ng-repeat="cat in stat_cats">
+<div class="row reg-field-row" 
+    ng-show="show_field('stat_cats')" ng-repeat="cat in stat_cats">
   <div class="col-md-3 reg-field-label">
     <label>{{cat.name()}}</label>
   </div>
 
 <!-- surveys -->
 
-<div class="alert alert-success row" role="alert" ng-if="surveys.length > 0">
+<div class="alert alert-success row" role="alert" 
+    ng-show="show_field('surveys')" ng-if="surveys.length > 0">
     <div class="col-md-6">[% l('Surveys') %]</div>
 </div>
 
-<div class="row reg-field-row" ng-repeat="survey in surveys">
+<div class="row reg-field-row" 
+    ng-show="show_field('surveys')" ng-repeat="survey in surveys">
   <div class="col-md-3 reg-field-label">
     <label>{{survey.name()}}</label>
   </div>
index b2049ad..551883e 100644 (file)
@@ -136,7 +136,6 @@ but the ones I'm finding aren't quite cutting it..*/
   font-weight: bold;
 }
 
-
 /* -- end patron registration -- */
 
 [%# 
index 5c367b8..c2ff924 100644 (file)
  * Local style
  */
 
+/* no bootstrap way to directly disable a link.  */
+a.disabled {
+  pointer-events: none;
+  cursor: default;
+  color: #888;
+}
+
 #splash-nav .panel-body div {
     padding-bottom: 10px;
 }
index 9d98693..117d8f8 100644 (file)
@@ -561,6 +561,12 @@ function($scope,  $q,  $location , $filter,  egCore,  egUser,  patronSvc) {
         return Boolean($location.path().match(/patron\/\d+\/edit$/));
     }
 
+    // To support the fixed position patron edit actions bar,
+    // its markup has to live outside the scope of the patron 
+    // edit controller.  Insert a scope blob here that can be
+    // modifed from within the patron edit controller.
+    $scope.edit_passthru = {};
+
     // returns true if a redirect occurs
     function redirectToAlertPanel() {
 
index b940514..f8aef69 100644 (file)
@@ -134,20 +134,30 @@ angular.module('egCoreMod')
     // some org settings require the retrieval of additional data
     service.process_org_settings = function(settings) {
 
-        if (!settings['sms.enable']) {
-            return $q.when();
+        var promises = [];
+
+        if (settings['sms.enable']) {
+            // fetch SMS carriers
+            promises.push(
+                egCore.pcrud.search('csc', 
+                    {active: 'true'}, 
+                    {'order_by':[
+                        {'class':'csc', 'field':'name'},
+                        {'class':'csc', 'field':'region'}
+                    ]}, {atomic : true}
+                ).then(function(carriers) {
+                    service.sms_carriers = carriers;
+                })
+            );
+        } else {
+            // if other promises are added below, this is not necessary.
+            promises.push($q.when());  
         }
 
-        return egCore.pcrud.search('csc', 
-            {active: 'true'}, 
-            {'order_by':[
-                {'class':'csc', 'field':'name'},
-                {'class':'csc', 'field':'region'}
-            ]},
-            {atomic : true}
-        ).then(function(carriers) {
-            service.sms_carriers = carriers;
-        });
+        // other post-org-settings processing goes here,
+        // adding to promises as needed.
+
+        return $q.all(promises);
     };
 
     service.get_ident_types = function() {
@@ -313,11 +323,23 @@ angular.module('egCoreMod')
 function PatronRegCtrl($scope, $routeParams, 
     $q, egCore, patronSvc, patronRegSvc) {
 
+
     $scope.clone_id = $routeParams.clone_id;
     $scope.stage_username = $routeParams.stage_username;
     $scope.patron_id = 
         patronRegSvc.patron_id = $routeParams.edit_id || $routeParams.id;
 
+    if (!$scope.edit_passthru) {
+        // in edit more, scope.edit_passthru is delivered to us by
+        // the enclosing controller.  In register mode, there is 
+        // no enclosing controller, so we create our own.
+        $scope.edit_passthru = {};
+    }
+
+    // 0=all, 1=suggested, 2=all
+    $scope.edit_passthru.vis_level = 0; 
+    // TODO: add save/clone handlers here
+
     $q.all([
 
         $scope.initTab ? // initTab comes from patron app
@@ -342,6 +364,9 @@ function PatronRegCtrl($scope, $routeParams,
         $scope.sms_carriers = prs.sms_carriers;
         $scope.stat_cats = prs.stat_cats;
         $scope.surveys = prs.surveys;
+
+        if ($scope.org_settings['ui.patron.edit.default_suggested'])
+            $scope.edit_passthru.vis_level = 1;
     });
 
     // returns the tree depth of the selected profile group tree node.
@@ -358,6 +383,60 @@ function PatronRegCtrl($scope, $routeParams,
         aua : egCore.idl.classes.aua.field_map
     };
 
+    // field visibility cache.  Some fields are universally required.
+    var field_visibility = {
+        'ac.barcode' : 2,
+        'au.usrname' : 2,
+        'au.passwd' :  2,
+        // TODO passwd2 2,
+        'au.first_given_name' : 2,
+        'au.family_name' : 2,
+        'au.ident_type' : 2,
+        'au.home_ou' : 2,
+        'au.profile' : 2,
+        'au.expire_date' : 2,
+        'au.net_access_level' : 2,
+        'aua.address_type' : 2,
+        'aua.post_code' : 2,
+        'aua.street1' : 2,
+        'aua.street2' : 2,
+        'aua.city' : 2,
+        'aua.county' : 2,
+        'aua.state' : 2,
+        'aua.country' : 2,
+        'aua.valid' : 2,
+        'aua.within_city_limits' : 2,
+        'stat_cats' : 1,
+        'surveys' : 1
+    }; 
+
+    // returns true if the selected field should be visible
+    // given the current required/suggested/all setting.
+    $scope.show_field = function(field_key) {
+
+        if (field_visibility[field_key] == undefined) {
+            // compile and cache the visibility for the selected field
+
+            // org settings have not been received yet.
+            if (!$scope.org_settings) return false;
+
+            var req_set = 'ui.patron.edit.' + field_key + '.require';
+            var sho_set = 'ui.patron.edit.' + field_key + '.show';
+            var sug_set = 'ui.patron.edit.' + field_key + '.suggest';
+
+            if ($scope.org_settings[req_set]) {
+                field_visibility[field_key] = 2;
+            } else if ($scope.org_settings[sho_set]) {
+                field_visibility[field_key] = 2;
+            } else if ($scope.org_settings[sug_set]) {
+                field_visibility[field_key] = 1;
+            } else {
+                field_visibility[field_key] = 0;
+            }
+        }
+
+        return field_visibility[field_key] >= $scope.edit_passthru.vis_level;
+    }
 }