From: Bill Erickson Date: Tue, 12 Jun 2018 21:54:27 +0000 (-0400) Subject: LP#1775466 Add grid print support; move dialogs to root module X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=cd199e6d9a9bacb7bd36a816fcd154f8a6e62c34;p=working%2FEvergreen.git LP#1775466 Add grid print support; move dialogs to root module Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/common.module.ts b/Open-ILS/src/eg2/src/app/common.module.ts index b728240aa6..e04e00309e 100644 --- a/Open-ILS/src/eg2/src/app/common.module.ts +++ b/Open-ILS/src/eg2/src/app/common.module.ts @@ -18,11 +18,21 @@ import {OrgService} from '@eg/core/org.service'; import {AudioService} from '@eg/share/util/audio.service'; import {FormatService} from '@eg/share/util/format.service'; import {PrintService} from '@eg/share/print/print.service'; + +// Globally available components import {PrintComponent} from '@eg/share/print/print.component'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; +import {PromptDialogComponent} from '@eg/share/dialog/prompt.component'; +import {ProgressDialogComponent} from '@eg/share/dialog/progress.component'; @NgModule({ declarations: [ - PrintComponent + PrintComponent, + DialogComponent, + ConfirmDialogComponent, + PromptDialogComponent, + ProgressDialogComponent ], imports: [ CommonModule, @@ -35,7 +45,11 @@ import {PrintComponent} from '@eg/share/print/print.component'; RouterModule, NgbModule, FormsModule, - PrintComponent + PrintComponent, + DialogComponent, + ConfirmDialogComponent, + PromptDialogComponent, + ProgressDialogComponent ] }) diff --git a/Open-ILS/src/eg2/src/app/share/dialog/progress.component.ts b/Open-ILS/src/eg2/src/app/share/dialog/progress.component.ts index 180ed500ae..9a32bf5644 100644 --- a/Open-ILS/src/eg2/src/app/share/dialog/progress.component.ts +++ b/Open-ILS/src/eg2/src/app/share/dialog/progress.component.ts @@ -82,7 +82,7 @@ export class ProgressDialogComponent extends DialogComponent { // Increment the current value. If no amount is specified, // it increments by 1. Calling increment() on an indetermite // progress bar will force it to be a (semi-)determinate bar. - increment(amt: number) { + increment(amt?: number) { if (!Number.isInteger(amt)) { amt = 1; } if (!this.hasValue()) { diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-print.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid-print.component.html new file mode 100644 index 0000000000..bcb29e70fa --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-print.component.html @@ -0,0 +1,30 @@ + + + + + +
+ + + + + + + + + + + +
{{col.label}}
{{row[col.name]}}
+
+
+
diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-print.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-print.component.ts new file mode 100644 index 0000000000..f73e26b460 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-print.component.ts @@ -0,0 +1,45 @@ +import {Component, Input, TemplateRef, ViewChild} from '@angular/core'; +import {ProgressDialogComponent} from '@eg/share/dialog/progress.component'; +import {PrintService} from '@eg/share/print/print.service'; +import {GridContext} from '@eg/share/grid/grid'; + +@Component({ + selector: 'eg-grid-print', + templateUrl: './grid-print.component.html' +}) + +/** + */ +export class GridPrintComponent { + + @Input() gridContext: GridContext; + @ViewChild('printTemplate') private printTemplate: TemplateRef; + @ViewChild('progressDialog') + private progressDialog: ProgressDialogComponent; + + constructor(private printer: PrintService) {} + + printGrid() { + this.progressDialog.open(); + const columns = this.gridContext.columnSet.displayColumns(); + const textItems = {columns: columns, rows: []}; + + this.gridContext.getAllRowsAsText().subscribe( + row => { + this.progressDialog.increment(); + textItems.rows.push(row); + }, + err => this.progressDialog.close(), + () => { + this.progressDialog.close(); + this.printer.print({ + template: this.printTemplate, + contextData: textItems, + printContext: 'default' + }); + } + ); + } +} + + diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html index fd301a45dc..5f9a34aa1d 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html @@ -101,7 +101,11 @@ [download]="csvExportFileName" [href]="csvExportUrl"> cloud_download - Download CSV + Download Full CSV + + + print + Print Full Grid diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts index 43d3aec9d8..9e3ceda7d3 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts @@ -4,6 +4,7 @@ import {Pager} from '@eg/share/util/pager'; import {GridColumn, GridColumnSet, GridToolbarButton, GridToolbarAction, GridContext, GridDataSource} from '@eg/share/grid/grid'; import {GridColumnWidthComponent} from './grid-column-width.component'; +import {GridPrintComponent} from './grid-print.component'; @Component({ selector: 'eg-grid-toolbar', @@ -14,6 +15,7 @@ export class GridToolbarComponent implements OnInit { @Input() gridContext: GridContext; @Input() colWidthConfig: GridColumnWidthComponent; + @Input() gridPrinter: GridPrintComponent; csvExportInProgress: boolean; csvExportUrl: SafeUrl; @@ -39,6 +41,10 @@ export class GridToolbarComponent implements OnInit { action.action(this.gridContext.getSelectedRows()); } + printHtml() { + this.gridPrinter.printGrid(); + } + generateCsvExportUrl($event) { if (this.csvExportInProgress) { @@ -64,7 +70,6 @@ export class GridToolbarComponent implements OnInit { ).replace(/\s+/g, '_') + '.csv'; this.gridContext.gridToCsv().then(csv => { - console.log(csv); const blob = new Blob([csv], {type : 'text/plain'}); const win: any = window; // avoid TS errors this.csvExportUrl = this.sanitizer.bypassSecurityTrustUrl( diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid.component.html index 84c8dee325..5a24fc32ac 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.component.html @@ -1,13 +1,19 @@
- + + + +
diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.module.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.module.ts index 07a7eede20..31a052cba4 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.module.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.module.ts @@ -8,6 +8,7 @@ import {GridToolbarButtonComponent} from './grid-toolbar-button.component'; import {GridToolbarActionComponent} from './grid-toolbar-action.component'; import {GridColumnConfigComponent} from './grid-column-config.component'; import {GridColumnWidthComponent} from './grid-column-width.component'; +import {GridPrintComponent} from './grid-print.component'; @NgModule({ @@ -20,7 +21,8 @@ import {GridColumnWidthComponent} from './grid-column-width.component'; GridToolbarButtonComponent, GridToolbarActionComponent, GridColumnConfigComponent, - GridColumnWidthComponent + GridColumnWidthComponent, + GridPrintComponent ], imports: [ EgCommonModule diff --git a/Open-ILS/src/eg2/src/app/share/print/print.component.ts b/Open-ILS/src/eg2/src/app/share/print/print.component.ts index b715bc6d32..0496f0c46c 100644 --- a/Open-ILS/src/eg2/src/app/share/print/print.component.ts +++ b/Open-ILS/src/eg2/src/app/share/print/print.component.ts @@ -23,7 +23,7 @@ export class PrintComponent implements OnInit { handlePrintRequest(printReq: PrintRequest) { this.template = printReq.template; - this.context = printReq.contextData; + this.context = {$implicit: printReq.contextData}; // Give the template a chance to render inline before printing setTimeout(() => this.dispatchPrint(printReq)); diff --git a/Open-ILS/src/eg2/src/app/staff/common.module.ts b/Open-ILS/src/eg2/src/app/staff/common.module.ts index 33af569c16..2dfbb3cd8f 100644 --- a/Open-ILS/src/eg2/src/app/staff/common.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/common.module.ts @@ -2,10 +2,6 @@ import {NgModule, ModuleWithProviders} from '@angular/core'; import {EgCommonModule} from '@eg/common.module'; import {StaffBannerComponent} from './share/staff-banner.component'; import {OrgSelectComponent} from '@eg/share/org-select/org-select.component'; -import {DialogComponent} from '@eg/share/dialog/dialog.component'; -import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; -import {PromptDialogComponent} from '@eg/share/dialog/prompt.component'; -import {ProgressDialogComponent} from '@eg/share/dialog/progress.component'; import {AccessKeyDirective} from '@eg/share/accesskey/accesskey.directive'; import {AccessKeyService} from '@eg/share/accesskey/accesskey.service'; import {AccessKeyInfoComponent} from '@eg/share/accesskey/accesskey-info.component'; @@ -25,10 +21,6 @@ import {DateSelectComponent} from '@eg/share/date-select/date-select.component'; declarations: [ StaffBannerComponent, OrgSelectComponent, - DialogComponent, - ConfirmDialogComponent, - PromptDialogComponent, - ProgressDialogComponent, AccessKeyDirective, AccessKeyInfoComponent, ToastComponent, @@ -44,10 +36,6 @@ import {DateSelectComponent} from '@eg/share/date-select/date-select.component'; EgCommonModule, StaffBannerComponent, OrgSelectComponent, - DialogComponent, - ConfirmDialogComponent, - PromptDialogComponent, - ProgressDialogComponent, AccessKeyDirective, AccessKeyInfoComponent, ToastComponent, diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html index 4430212db8..bc6a8d672f 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html @@ -70,7 +70,7 @@ -Hello, {{world}}! +Hello, {{context.world}}!