<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>
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';
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]))
}
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);
+ }
+ });
}
}