LP1904036 Patron edit unsaved changes dialog fix
authorBill Erickson <berickxx@gmail.com>
Fri, 7 Jan 2022 22:46:10 +0000 (17:46 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:40 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>

Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts

index e78c110..6128c8c 100644 (file)
@@ -35,7 +35,7 @@
 <eg-hold-notify-update-dialog #holdNotifyUpdateDialog>
 </eg-hold-notify-update-dialog>
 
-<div class="row" *ngIf="loading">
+<div class="row" *ngIf="!showForm">
   <div class="col-lg-6 offset-lg-3">
     <eg-progress-inline></eg-progress-inline>
   </div>
 
 <!-- The List O' Fields -->
 
-<div class="mt-3 striped-rows-even patron-edit-container form-validated" *ngIf="patron && !loading">
+<div class="mt-3 striped-rows-even patron-edit-container form-validated" *ngIf="patron && showForm">
 
   <div class="row pt-1 pb-1 mt-1" *ngIf="showField('ac.barcode')">
     <ng-container *ngTemplateOutlet="fieldLabel; 
index 92b7763..9fa83b8 100644 (file)
@@ -156,7 +156,15 @@ export class EditComponent implements OnInit, AfterViewInit {
     modifiedPatron: IdlObject;
     changeHandlerNeeded = false;
     nameTab = 'primary';
+
+    // Are we still fetching data and applying values?
     loading = false;
+    // Should the user be able to see the form?
+    // On page load, we want to show the form just before we are
+    // done loading, so values can be applied to inputs after they
+    // are rendered but before those changes would result in setting
+    // changesPending = true
+    showForm = false;
 
     surveys: IdlObject[];
     smsCarriers: ComboboxEntry[];
@@ -238,6 +246,7 @@ export class EditComponent implements OnInit, AfterViewInit {
 
     load(): Promise<any> {
         this.loading = true;
+        this.showForm = false;
         return this.setStatCats()
         .then(_ => this.getFieldDocs())
         .then(_ => this.setSurveys())
@@ -252,7 +261,7 @@ export class EditComponent implements OnInit, AfterViewInit {
         .then(_ => this.setOptInSettings())
         .then(_ => this.setSmsCarriers())
         .then(_ => this.setFieldPatterns())
-        .then(_ => this.loading = false)
+        .then(_ => this.showForm = true)
         // Not my preferred way to handle this, but some values are
         // applied to widgets slightly after the load() is done and the
         // widgets are rendered.  If a widget is required and has no
@@ -261,7 +270,10 @@ export class EditComponent implements OnInit, AfterViewInit {
         // non-saveable state on page load without forcing the page into
         // an nonsaveable state on every page load, check the save state
         // after a 1 second delay.
-        .then(_ => setTimeout(() => this.emitSaveState(), 1000));
+        .then(_ => setTimeout(() => {
+            this.emitSaveState();
+            this.loading = false;
+        }, 1000));
     }
 
     setEditProfiles(): Promise<any> {
@@ -1363,7 +1375,6 @@ export class EditComponent implements OnInit, AfterViewInit {
     }
 
     nonDeletedAddresses(): IdlObject[] {
-        console.log('nonDeletedAddresses() are ', this.patron.addresses().filter(a => !a.isdeleted()).map(a => a.id()));
         return this.patron.addresses().filter(a => !a.isdeleted());
     }
 
@@ -1371,6 +1382,7 @@ export class EditComponent implements OnInit, AfterViewInit {
 
         this.changesPending = false;
         this.loading = true;
+        this.showForm = false;
 
         return this.saveUser()
         .then(_ => this.saveUserSettings())