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>
</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 -->
--- /dev/null
+<!-- 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>
+
</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>
font-weight: bold;
}
-
/* -- end patron registration -- */
[%#
* 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;
}
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() {
// 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() {
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
$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.
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;
+ }
}