LP1904036 post code handling / addr populating
authorBill Erickson <berickxx@gmail.com>
Tue, 30 Mar 2021 16:55:03 +0000 (12:55 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:29 +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 73ffee8..bcd8ba5 100644 (file)
 </eg-patron-secondary-groups>
 <eg-patron-barcodes #barcodesDialog [patron]="patron"></eg-patron-barcodes>
 
+<eg-alert-dialog #addrAlert
+  i18n-dialogTitle dialogTitle="Address Alert">
+</eg-alert-dialog>
+
 <div class="row" *ngIf="loading">
   <div class="col-lg-6 offset-lg-3">
     <eg-progress-inline></eg-progress-inline>
index 55728cd..ab855bb 100644 (file)
@@ -20,6 +20,7 @@ import {SecondaryGroupsDialogComponent} from './secondary-groups.component';
 import {ServerStoreService} from '@eg/core/server-store.service';
 import {EditToolbarComponent, VisibilityLevel} from './edit-toolbar.component';
 import {PatronSearchFieldSet} from '@eg/staff/share/patron/search.component';
+import {AlertDialogComponent} from '@eg/share/dialog/alert.component';
 
 const COMMON_USER_SETTING_TYPES = [
   'circ.holds_behind_desk',
@@ -121,6 +122,8 @@ export class EditComponent implements OnInit, AfterViewInit {
         private profileSelect: ProfileSelectComponent;
     @ViewChild('secondaryGroupsDialog')
         private secondaryGroupsDialog: SecondaryGroupsDialogComponent;
+    @ViewChild('addrAlert') private addrAlert: AlertDialogComponent;
+
 
     autoId = -1;
     patron: IdlObject;
@@ -679,6 +682,10 @@ export class EditComponent implements OnInit, AfterViewInit {
                 // TODO address_alert(obj);
                 break;
 
+            case 'post_code':
+                this.handlePostCodeChange(obj, value);
+                break;
+
             case 'barcode':
                 this.handleBarcodeChange(value);
                 break;
@@ -691,6 +698,25 @@ export class EditComponent implements OnInit, AfterViewInit {
         this.adjustSaveSate();
     }
 
+    handlePostCodeChange(addr: IdlObject, postCode: any) {
+        this.net.request(
+            'open-ils.search', 'open-ils.search.zip', postCode
+        ).subscribe(resp => {
+            if (!resp) return;
+
+            ['city', 'state', 'county'].forEach(field => {
+                if (resp[field]) {
+                    addr[field](resp[field]);
+                }
+            });
+
+            if (resp.alert) {
+                this.addrAlert.dialogBody = resp.alert;
+                this.addrAlert.open();
+            }
+        });
+    }
+
     handleUsernameChange(value: any) {
         this.dupeUsername = false;