ng-required="field_required('[% cls %]', '[% field %]')"
ng-blur="handle_field_changed([% base_obj %], '[% field %]')"
ng-pattern="field_pattern('[% cls %]', '[% field %]')"
- ng-class="{'patron-reg-invalid-field' : field_is_invalid('[% model %]')}"
ng-model="[% model %]"/>
</div>
[% END %]
has been loaded. Setting ng-form and a name lets us refer to fields
within the "form" by name for validation.
-->
-<div ng-form name="reg_form" ng-show="page_data_loaded">
+<div ng-form id="patron-reg-container"
+ name="reg_form" ng-show="page_data_loaded">
<!-- BARCODE -->
<input type="text"
name="barcode"
ng-model="patron.card.barcode"
- ng-class="{'patron-reg-invalid-field' : field_is_invalid('barcode')}"
ng-pattern="field_pattern('ac', 'barcode')"
ng-required="field_required('ac', 'barcode')"
focus-me="focus_bc"
ng-change="field_modified()"
ng-disabled="disable_bc"
- ng-blur="handle_field_changed(patron.card, 'barcode')"
class="form-control"
ng-blur="handle_field_changed(patron.card, 'barcode')"/>
</div>
<div class="col-md-3 reg-field-input">
<input type="text"
name='usrname'
- ng-class="{'patron-reg-invalid-field' : field_is_invalid('usrname')}"
ng-required="field_required('au', 'usrname')"
focus-me="focus_usrname"
ng-change="field_modified()"
name="dob"
ng-change="field_modified()"
ng-blur="handle_field_changed(patron, 'dob')"
- ng-class="{'patron-reg-invalid-field' : field_is_invalid('dob')}"
class="form-control" ng-model="patron.dob"/>
</div>
<div class="col-md-6 patron-reg-example">
<div class="row reg-field-row" ng-show="show_field('au.juvenile')">
[% draw_field_label('au', 'juvenile') %]
- [% draw_form_input('au', 'alias', '', 'checkbox'); %]
+ [% draw_form_input('au', 'juvenile', '', 'checkbox'); %]
</div>
<!-- ident_type -->
<div class="row reg-field-row" ng-show="show_field('au.ident_type')">
[% draw_field_label('au', 'ident_type') %]
<div class="col-md-3 reg-field-input">
- <div class="btn-group" dropdown>
- <button type="button" class="btn btn-default dropdown-toggle">
- <span style="padding-right: 5px;">
- {{patron.ident_type.name() || "[% l('Primary Ident Type') %]"}}
- </span>
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- <li ng-repeat="type in ident_types">
- <a href ng-click="patron.ident_type = type; handle_field_changed(patron, 'ident_type')">
- {{type.name()}}
- </a>
- </li>
- </ul>
- </div>
+ <select
+ class="form-control"
+ ng-model="patron.ident_type"
+ ng-required="field_required('au', 'ident_type')"
+ ng-blur="handle_field_changed(patron, 'ident_type')"
+ ng-options="type.name() for type in ident_types track by type.id()">
+ </select>
</div>
</div>
[% draw_field_label('au', 'profile') %]
<div class="col-md-3 reg-field-input">
<div class="btn-group" dropdown>
- <button type="button" class="btn btn-default dropdown-toggle">
+ <button type="button" class="btn btn-default dropdown-toggle"
+ ng-class="{'ng-invalid' : invalid_profile()}">
<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 edit_profiles">
+ <li ng-repeat="grp in edit_profiles"
+ ng-class="{disabled : grp.usergroup() == 'f'}">
<a href
style="padding-left: {{pgt_depth(grp) * 10 + 5}}px"
ng-click="set_profile(grp)">{{grp.name()}}</a>
// See $scope.show_field().
// A field with visbility level 3 means it's required.
$scope.field_required = function(cls, field) {
+
+ // Value in the password field is not required
+ // for existing patrons.
+ if (field == 'passwd' && $scope.patron && !$scope.patron.isnew)
+ return false;
+
return (field_visibility[cls + '.' + field] == 3);
}
$scope.field_modified();
}
+ $scope.invalid_profile = function() {
+ return !(
+ $scope.patron &&
+ $scope.patron.profile &&
+ $scope.patron.profile.usergroup() == 't'
+ );
+ }
+
$scope.new_address = function() {
var addr = egCore.idl.toHash(new egCore.idl.aua());
patronRegSvc.ingest_address($scope.patron, addr);
$scope.field_modified();
}
+ /* NOTE: this function is not necessary since angular applies
+ * the needed classes as each field becomes valid/invalid.
+ * Leaving it here for now for reference.
// Returns true if a required field has no value or a field's
// value does not match its configured regex pattern.
// Tests angular's form field validation toggles.
$scope.reg_form[field_name].$valid === false
);
}
+ */
+
+ // Returns true if any input elements are tagged as invalid
+ $scope.edit_passthru.has_invalid_fields = function() {
+ return $('#patron-reg-container.ng-invalid').length > 0;
+ }
$scope.edit_passthru.save = function(save_args) {
if (!save_args) save_args = {};