LP1904036 address alerts; misc
authorBill Erickson <berickxx@gmail.com>
Tue, 6 Apr 2021 16:04:09 +0000 (12:04 -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-toolbar.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html
Open-ILS/src/eg2/src/app/staff/share/patron/penalty-dialog.component.ts

index 580a745..3afbada 100644 (file)
   </div>
 </div>
 
+<div class="row pb-1 pt-1" *ngIf="addressAlerts.length > 0">
+  <div class="col-lg-12 d-flex">
+    <div class="ml-auto mr-2">
+      <div *ngFor="let alert of addressAlerts"
+        class="alert alert-danger ml-auto p-2 mt-2" i18n>
+          Address Alert: {{alert.alert_message()}}
+      </div>
+    </div>
+  </div>
+</div>
+
 <div class="row pb-1 pt-1" *ngIf="dupesFound().length > 0">
   <div class="col-lg-12 d-flex">
     <div class="ml-auto mr-2">
index d715cbc..fc1093b 100644 (file)
@@ -2,6 +2,7 @@ import {Component, OnInit, Input, Output, EventEmitter} from '@angular/core';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
 import {NgbNav, NgbNavChangeEvent} from '@ng-bootstrap/ng-bootstrap';
 import {OrgService} from '@eg/core/org.service';
+import {IdlService, IdlObject} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
 import {AuthService} from '@eg/core/auth.service';
 import {PatronService} from '@eg/staff/share/patron/patron.service';
@@ -41,9 +42,11 @@ export class EditToolbarComponent implements OnInit {
     printClicked: EventEmitter<void> = new EventEmitter<void>();
 
     searches: {[category: string]: DupeSearch} = {};
+    addressAlerts: IdlObject[] = [];
 
     constructor(
         private org: OrgService,
+        private idl: IdlService,
         private net: NetService,
         private auth: AuthService,
         private patronService: PatronService,
@@ -63,8 +66,6 @@ export class EditToolbarComponent implements OnInit {
         return Object.values(this.searches).filter(dupe => dupe.count > 0);
     }
 
-
-
     checkDupes(category: string, search: PatronSearchFieldSet) {
 
         this.net.request(
@@ -85,5 +86,17 @@ export class EditToolbarComponent implements OnInit {
             };
         });
     }
+
+    checkAddressAlerts(addr: IdlObject) {
+        const addrHash = this.idl.toHash(addr);
+        const patron = this.context.summary.patron;
+        addrHash.mailing_address = addr.id() === patron.mailing_address().id();
+        addrHash.billing_address = addr.id() === patron.billing_address().id();
+        this.net.request(
+            'open-ils.actor',
+            'open-ils.actor.address_alert.test',
+            this.auth.token(), this.auth.user().ws_ou(), addrHash
+        ).subscribe(alerts => this.addressAlerts = alerts);
+    }
 }
 
index b37b546..a6d45bb 100644 (file)
   i18n-dialogBody dialogBody="An address is required during registration">
 </eg-alert-dialog>
 
+<eg-alert-dialog #xactCollisionAlert
+  i18n-dialogTitle dialogTitle="Save Collision"
+  i18n-dialogBody dialogBody="Patron record was modified by another user while you were 
+  editing it. Your changes were not saved; please reapply them.">
+</eg-alert-dialog>
+
 <eg-hold-notify-update-dialog #holdNotifyUpdateDialog>
 </eg-hold-notify-update-dialog>
 
index 887efa4..5df2571 100644 (file)
@@ -145,6 +145,8 @@ export class EditComponent implements OnInit, AfterViewInit {
     @ViewChild('addrAlert') private addrAlert: AlertDialogComponent;
     @ViewChild('addrRequiredAlert')
         private addrRequiredAlert: AlertDialogComponent;
+    @ViewChild('xactCollisionAlert')
+        private xactCollisionAlert: AlertDialogComponent;
 
 
     autoId = -1;
@@ -900,7 +902,7 @@ export class EditComponent implements OnInit, AfterViewInit {
             case 'city':
                 // dupe search on address wants the address object as the value.
                 this.dupeValueChange('address', obj);
-                // TODO address_alert(obj);
+                this.toolbar.checkAddressAlerts(obj);
                 break;
 
             case 'post_code':
@@ -1379,11 +1381,14 @@ export class EditComponent implements OnInit, AfterViewInit {
             if (evt) {
                 console.error('Patron update failed with', evt);
                 if (evt.textcode === 'XACT_COLLISION') {
-                    // TODO alert
+                    this.xactCollisionAlert.open().toPromise().then(_ =>
+                        window.location.href = window.location.href
+                    );
                 }
-            }
+            } else {
 
-            alert('Patron update failed:' + result);
+                alert('Patron update failed:' + result);
+            }
 
             return Promise.reject('Save Failed');
         });
index 71a2e78..510fb3f 100644 (file)
             <a href class="nav-link" (click)="toggleSummaryPane(); false"
               title="Toggle Summary Pane" i18n-title>
               <ng-container *ngIf="showSummaryPane()">
-                <span class="material-icons">navigate_before</span>
+                <span class="material-icons">fullscreen</span>
               </ng-container>
               <ng-container *ngIf="!showSummaryPane()">
-                <span class="material-icons">navigate_next</span>
+                <span class="material-icons">fullscreen_exit</span>
               </ng-container>
             </a>
           </li>
index 7a2435c..8380a0e 100644 (file)
@@ -3,6 +3,7 @@ import {merge, from, Observable} from 'rxjs';
 import {tap, take, switchMap} from 'rxjs/operators';
 import {IdlService, IdlObject} from '@eg/core/idl.service';
 import {OrgService} from '@eg/core/org.service';
+import {ServerStoreService} from '@eg/core/server-store.service';
 import {AuthService} from '@eg/core/auth.service';
 import {NetService} from '@eg/core/net.service';
 import {EventService} from '@eg/core/event.service';
@@ -54,6 +55,7 @@ export class PatronPenaltyDialogComponent
         private idl: IdlService,
         private org: OrgService,
         private net: NetService,
+        private store: ServerStoreService,
         private evt: EventService,
         private toast: ToastService,
         private auth: AuthService,
@@ -85,9 +87,8 @@ export class PatronPenaltyDialogComponent
             this.penaltyTypeFromButton = this.SILENT_NOTE;
         }
 
-        this.org.settings(['ui.staff.require_initials.patron_standing_penalty'])
-        .then(sets => this.requireInitials =
-            sets['ui.staff.require_initials.patron_standing_penalty']);
+        this.store.getItem('ui.staff.require_initials.patron_standing_penalty')
+        .then(require => this.requireInitials = require);
 
         const obs1 = this.pcrud.retrieve('au', this.patronId)
             .pipe(tap(usr => this.patron = usr));