1 import {Component, OnInit, Input} from '@angular/core';
2 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
3 import {NgbNav, NgbNavChangeEvent} from '@ng-bootstrap/ng-bootstrap';
4 import {OrgService} from '@eg/core/org.service';
5 import {IdlObject} from '@eg/core/idl.service';
6 import {NetService} from '@eg/core/net.service';
7 import {PatronService} from '@eg/staff/share/patron/patron.service';
8 import {PatronContextService} from './patron.service';
9 import {PrintService} from '@eg/share/print/print.service';
12 templateUrl: 'summary.component.html',
13 styleUrls: ['summary.component.css'],
14 selector: 'eg-patron-summary'
16 export class SummaryComponent implements OnInit {
19 private org: OrgService,
20 private net: NetService,
21 private printer: PrintService,
22 public patronService: PatronService,
23 public context: PatronContextService
30 return this.context.patron;
33 printAddress(addr: IdlObject) {
35 templateName: 'patron_address',
37 patron: this.context.patron,
40 printContext: 'default'
44 copyAddress(addr: IdlObject) {
45 // Note navigator.clipboard requires special permissions.
46 // This is hinky, but gets the job done without the perms.
48 const node = document.getElementById(
49 `patron-address-copy-${addr.id()}`) as HTMLTextAreaElement;
51 // Un-hide the textarea just long enough to copy its data.
52 // Using node.style instead of *ngIf in hopes it
53 // will be quicker, so the user never sees the textarea.
54 node.style.visibility = 'visible';
58 if (!document.execCommand('copy')) {
59 console.error('Copy command failed');
62 node.style.visibility = 'hidden';