From: Jason Etheridge Date: Wed, 20 Nov 2019 13:31:54 +0000 (-0500) Subject: Print Selected Invoices action for invoice grid X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bb8dd28929cd7fe7c4950ca413715f92e4aba99e;p=working%2FEvergreen.git Print Selected Invoices action for invoice grid Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html index 2f85b987f0..5991f55326 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.html @@ -22,6 +22,10 @@ [stickyHeader]="true" idlClass="acqinv" [dataSource]="gridSource"> + + + @@ -30,3 +34,7 @@ + + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.ts index 9dbb627cba..20a6011bb6 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/invoice-results.component.ts @@ -4,6 +4,9 @@ import {map} from 'rxjs/operators'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {Pager} from '@eg/share/util/pager'; import {IdlObject} from '@eg/core/idl.service'; +import {EventService} from '@eg/core/event.service'; +import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; +import {PrintService} from '@eg/share/print/print.service'; import {NetService} from '@eg/core/net.service'; import {AuthService} from '@eg/core/auth.service'; import {GridComponent} from '@eg/share/grid/grid.component'; @@ -19,10 +22,15 @@ export class InvoiceResultsComponent implements OnInit { gridSource: GridDataSource; @ViewChild('acqSearchInvoicesGrid', { static: true }) invoiceResultsGrid: GridComponent; + @ViewChild('printfail', { static: true }) private printfail: AlertDialogComponent; + + noSelectedRows: (rows: IdlObject[]) => boolean; constructor( private router: Router, private route: ActivatedRoute, + private printer: PrintService, + private evt: EventService, private net: NetService, private auth: AuthService, private acqSearch: AcqSearchService) { @@ -30,6 +38,35 @@ export class InvoiceResultsComponent implements OnInit { ngOnInit() { this.gridSource = this.acqSearch.getAcqSearchDataSource('invoice'); + this.noSelectedRows = (rows: IdlObject[]) => (rows.length === 0); } + printSelectedInvoices(rows: IdlObject[]) { + var that = this; + var html = "\n"; + this.net.request( + 'open-ils.acq', + 'open-ils.acq.invoice.print.html', + this.auth.token(), rows.map( invoice => invoice.id() ) + ).subscribe( + (res) => { + if (this.evt.parse(res)) { + console.error(res); + this.printfail.open(); + } else { + html += res.template_output().data(); + } + }, + (err) => { + console.error(err); + this.printfail.open(); + }, + () => this.printer.print({ + text: html, + printContext: 'default' + }) + ); + } }