This patch fixes a problem wherein the patron editor
form would think that it had been modified by the
user immediately after initialization.
To test
-------
[1] Load the patron editor, then refresh the page. Note that
you are warned that there is unsaved input.
[2] As above, but hit the save button. Note that after saving,
you still get a warning that there is unsaved input.
[3] Apply the page, then repeat tests 1 and 2. This time, you
shouldn't get inappropriate unsaved data warnings.
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
<div class="col-md-3 reg-field-input">
<eg-date-input
ng-model="patron.dob"
- ng-change="field_modified()"
ng-blur="handle_field_changed(patron, 'dob')">
</eg-date-input>
</div>
[% draw_field_label('au', 'expire_date') %]
<div class="col-md-3 reg-field-input">
<eg-date-input
- ng-change="field_modified()"
ng-blur="handle_field_changed(patron, 'expire_date')"
ng-model="patron.expire_date">
</eg-date-input>
egUnloadPrompt.attach($scope);
}
+ // also monitor when form is changed *by the user*, as using
+ // an ng-change handler doesn't work with eg-date-input
+ $scope.$watch('reg_form.$pristine', function(newVal, oldVal) {
+ if (!newVal) egUnloadPrompt.attach($scope);
+ });
+
// username regex (if present) must be removed any time
// the username matches the barcode to avoid firing the
// invalid field handlers.