patron reg cont.
authorBill Erickson <berickxx@gmail.com>
Thu, 7 May 2015 02:41:09 +0000 (22:41 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 7 May 2015 02:41:09 +0000 (22:41 -0400)
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 98f0102..7320247 100644 (file)
     <div>{{selected_field_doc.string()}}</div>
 </fieldset>
 
+[% MACRO formfield(cls, field, path, input_type) BLOCK %]
+[% IF NOT input_type; input_type = 'text'; END %] 
+<div class="row pad-all-min form-group">
+    <div class="col-md-3 reg-field-label">
+        <label>{{idl_fields.[% cls %].[% field %].label}}</label>
+        <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">
+        [% IF path %]
+            <!-- linked object -->
+            <input type="[% input_type %]" 
+                class="form-control" ng-model="patron.[% path %].[% field %]"/>
+        [% ELSE %]
+            <input type="[% input_type %]" 
+                class="form-control" ng-model="patron.[% field %]"/>
+        [% END %]
+    </div>
+</div>
+[% END %]
 
-<div class="row pad-all-min">
+[% formfield('ac', 'barcode', 'card') %]
+[% formfield('au', 'usrname') %]
+[% formfield('au', 'passwd') %]
+[% formfield('au', 'prefix') %]
+[% formfield('au', 'first_given_name') %]
+[% formfield('au', 'second_given_name') %]
+[% formfield('au', 'family_name') %]
+[% formfield('au', 'suffix') %]
+[% formfield('au', 'alias') %]
+[% formfield('au', 'dob') %]
+[% formfield('au', 'juvenile', '', 'checkbox') %]
+
+<!-- ident_type -->
+
+[% formfield('au', 'ident_value') %]
+[% formfield('au', 'ident_value2') %]
+[% formfield('au', 'email') %]
+[% formfield('au', 'day_phone') %]
+[% formfield('au', 'evening_phone') %]
+[% formfield('au', 'other_phone') %]
+
+<!-- home org unit selector -->
+
+<div class="row pad-all-min form-group">
     <div class="col-md-3 reg-field-label">
-        <span>{{idl_fields.ac.barcode.label}}</span>
-        <img ng-show="field_doc.ac.barcode
-            ng-click="selected_field_doc=field_doc.ac.barcode"
+        <label>{{idl_fields.au.home_ou.label}}</label>
+        <img ng-show="field_doc.au.home_ou
+            ng-click="selected_field_doc=field_doc.au.home_ou"
             src='[% DOC_IMG %]'></img>
     </div>
     <div class="col-md-3 reg-field-input">
-        <input type="text" ng-model="patron.card.barcode"/>
+        <eg-org-selector selected="patron.home_ou_obj" 
+            onchange=""></eg-org-selector>
     </div>
 </div>
 
-<div class="row pad-all-min">
+<!-- profile selector -->
+
+<div class="row pad-all-min form-group">
     <div class="col-md-3 reg-field-label">
-        <span>{{idl_fields.au.usrname.label}}</span>
-        <img ng-show="field_doc.au.usrname
-            ng-click="selected_field_doc=field_doc.au.usrname"
+        <label>{{idl_fields.au.home_ou.label}}</label>
+        <img ng-show="field_doc.au.home_ou
+            ng-click="selected_field_doc=field_doc.au.home_ou"
             src='[% DOC_IMG %]'></img>
     </div>
     <div class="col-md-3 reg-field-input">
-        <input type="text" ng-model="patron.usrname"/>
+        <div class="btn-group" dropdown>
+          <button type="button" class="btn btn-default dropdown-toggle">
+            <span style="padding-right: 5px;">
+                {{patron.profile.name || "[% l('Profile Group') %]"}}
+            </span>
+            <span class="caret"></span>
+          </button>
+          <ul class="dropdown-menu">
+            <li ng-repeat="grp in profiles">
+              <a href dropdown-toggle
+                style="padding-left: {{pgt_depth(grp) * 10 + 5}}px"
+                ng-click="patron.profile = grp">{{grp.name()}}</a>
+            </li>
+          </ul>
+        </div>
     </div>
 </div>
 
+<div class="row pad-all-min form-group">
+    <div class="col-md-3 reg-field-label">
+        <label>{{idl_fields.au.expire_date.label}}</label>
+        <img ng-show="field_doc.au.expire_date" 
+            ng-click="selected_field_doc=field_doc.au.expire_date"
+            src='[% DOC_IMG %]'></img>
+    </div>
+    <div class="col-md-3 reg-field-input">
+        <input eg-date-input 
+            class="form-control" ng-model="patron.expire_date"/>
+    </div>
+</div>
+
+<!-- net_access_level -->
+
+[% formfield('au', 'active', '', 'checkbox') %]
+[% formfield('au', 'barred', '', 'checkbox') %]
+[% formfield('au', 'master_account', '', 'checkbox') %]
+[% formfield('au', 'claims_returned_count', '', 'number') %]
+[% formfield('au', 'claims_never_checked_out_count', '', 'number') %]
+[% formfield('au', 'alert_message') %]
+
+<!-- user settings -->
+<!-- addresses -->
+<!-- pending address -->
+<!-- stat cats -->
+<!-- surveys -->
+
 
index 1e72b75..76faf45 100644 (file)
@@ -4,17 +4,35 @@ angular.module('egCoreMod')
 
 .factory('patronRegSvc', ['$q', 'egCore', function($q, egCore) {
 
-    var service = {};
+    var service = {
+        field_doc : {},
+        profiles : []
+    };
 
     service.init = function(scope) {
         return $q.all([
             service.get_field_doc(),
+            service.get_perm_groups()
         ]);
     };
 
-    service.get_field_doc = function() {
+    service.get_perm_groups = function() {
+        if (egCore.env.pgt) {
+            service.profiles = egCore.env.pgt.list;
+            return $q.when();
+        } else {
+            return egCore.pcrud.search('pgt', {parent : null}, 
+                {flesh : -1, flesh_fields : {pgt : ['children']}}
+            ).then(
+                function(tree) {
+                    egCore.env.absorbTree(tree, 'pgt')
+                    service.profiles = egCore.env.pgt.list;
+                }
+            );
+        }
+    }
 
-        service.field_doc = {};
+    service.get_field_doc = function() {
 
         return egCore.pcrud.search('fdoc', {
             fm_class: ['au', 'ac', 'aua', 'actsc', 'asv', 'asvq', 'asva']})
@@ -34,9 +52,18 @@ angular.module('egCoreMod')
 function PatronRegCtrl($scope, $routeParams, 
     $location, egCore, patronSvc, patronRegSvc) {
 
+    // fetch needed data and toss it into the scope.
     patronRegSvc.init().then(function() {
         $scope.field_doc = patronRegSvc.field_doc;
+        $scope.profiles = patronRegSvc.profiles;
     });
+    
+    // determine the tree depth of the profile group
+    $scope.pgt_depth = function(grp) {
+        var d = 0;
+        while (grp = egCore.env.pgt.map[grp.parent()]) d++;
+        return d;
+    }
 
     // only add the classes we care about to the scope to avoid bloat
     $scope.idl_fields = {
@@ -48,10 +75,16 @@ function PatronRegCtrl($scope, $routeParams,
     if ($scope.initTab) {
         // Inside the patron app
         
-        $scope.initTab('other', $routeParams.id).then(function() {
+        $scope.initTab('edit', $routeParams.id).then(function() {
 
             $scope.patron = egCore.idl.toHash(patronSvc.current);
 
+            $scope.patron.home_ou_obj = 
+                egCore.org.get($scope.patron.home_ou.id);
+
+            $scope.patron.expire_date = 
+                new Date(Date.parse($scope.patron.expire_date));
+
         });
 
     } else {
@@ -65,6 +98,11 @@ function PatronRegCtrl($scope, $routeParams,
             card : {}
         };
         $scope.patron.isnew = true;
+
+        // default to local workstation org
+        $scope.patron.home_ou_obj = 
+            egCore.org.get(egCore.auth.user().ws_ou());
+
     }
 }