LP1904036 merging
authorBill Erickson <berickxx@gmail.com>
Mon, 5 Apr 2021 22:03:47 +0000 (18:03 -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/share/patron/merge-dialog.component.html
Open-ILS/src/eg2/src/app/staff/share/patron/merge-dialog.component.ts

index bc5551d..3400983 100644 (file)
@@ -42,7 +42,7 @@
   <div class="modal-footer">
     <ng-container>
       <button type="button" class="btn btn-success" 
-        [disabled]="leadAccount" (click)="merge()" i18n>Merge</button>
+        [disabled]="!leadAccount" (click)="merge()" i18n>Merge</button>
       <button type="button" class="btn btn-warning" 
         (click)="close()" i18n>Cancel</button>
     </ng-container>
index c3d9eb4..c818f37 100644 (file)
@@ -2,6 +2,9 @@ import {Component, OnInit, Input, Output, ViewChild} from '@angular/core';
 import {from} from 'rxjs';
 import {switchMap, concatMap} from 'rxjs/operators';
 import {IdlService, IdlObject} from '@eg/core/idl.service';
+import {AuthService} from '@eg/core/auth.service';
+import {NetService} from '@eg/core/net.service';
+import {EventService} from '@eg/core/event.service';
 import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
 import {DialogComponent} from '@eg/share/dialog/dialog.component';
 import {PatronService, PatronStats, PatronAlerts} from './patron.service';
@@ -51,12 +54,16 @@ export class PatronMergeDialogComponent
 
     constructor(
         private modal: NgbModal,
+        private auth: AuthService,
+        private net: NetService,
+        private evt: EventService,
         private patrons: PatronService
     ) { super(modal); }
 
     ngOnInit() {
         this.onOpen$.subscribe(_ => {
             this.loading = true;
+            this.leadAccount = null;
             this.loadPatron(this.patronIds[0])
             .then(ctx => this.context1 = ctx)
             .then(_ => this.loadPatron(this.patronIds[1]))
@@ -77,6 +84,24 @@ export class PatronMergeDialogComponent
     }
 
     merge() {
+
+        const subId = this.leadAccount === this.patronIds[0] ?
+            this.patronIds[1] : this.patronIds[0];
+
+        this.net.request(
+            'open-ils.actor',
+            'open-ils.actor.user.merge',
+            this.auth.token(), this.leadAccount, [subId]
+        ).subscribe(resp => {
+            const evt = this.evt.parse(resp);
+            if (evt) {
+                console.error(evt);
+                alert(evt);
+                this.close(false);
+            } else {
+                this.close(true);
+            }
+        });
     }
 }