From: Bill Erickson Date: Thu, 20 Jan 2022 21:16:10 +0000 (-0500) Subject: LP1958581 Angular Grid Copy To Clipboard X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=647f704c5501602f4ffd668944ecd79b4c26e438;p=Evergreen.git LP1958581 Angular Grid Copy To Clipboard To test, right click on a row in an Angular grid. A dialog should appear which allows the user to click on a value to select the value into the clipboard. Once selected, the dialog should close. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/eg2/src/app/share/clipboard/clipboard-dialog.component.html b/Open-ILS/src/eg2/src/app/share/clipboard/clipboard-dialog.component.html new file mode 100644 index 0000000000..1ff5fa23fb --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/clipboard/clipboard-dialog.component.html @@ -0,0 +1,25 @@ + + + + + diff --git a/Open-ILS/src/eg2/src/app/share/clipboard/clipboard-dialog.component.ts b/Open-ILS/src/eg2/src/app/share/clipboard/clipboard-dialog.component.ts new file mode 100644 index 0000000000..46e0141ebf --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/clipboard/clipboard-dialog.component.ts @@ -0,0 +1,43 @@ +import {Component, Input, ViewChild, TemplateRef} from '@angular/core'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; + +interface ClipboardValues { + label: string; + value: string; +} + +@Component({ + selector: 'eg-clipboard-dialog', + templateUrl: './clipboard-dialog.component.html' +}) + +/** + * Copy To Clipboard dialog + */ +export class ClipboardDialogComponent extends DialogComponent { + + @Input() values: ClipboardValues[]; + + copyValue(value: string) { + + const node = + document.getElementById('clipboard-textarea') as HTMLTextAreaElement; + + // Un-hide the textarea just long enough to copy its data. + // Using node.style instead of *ngIf for snappier show/hide. + node.style.visibility = 'visible'; + node.style.display = 'block'; + node.value = value; + node.focus(); + node.select(); + + document.execCommand('copy'); + + node.style.visibility = 'hidden'; + node.style.display = 'none'; + + this.close(); + } +} + + diff --git a/Open-ILS/src/eg2/src/app/share/common-widgets.module.ts b/Open-ILS/src/eg2/src/app/share/common-widgets.module.ts index fda671ec2c..49fdc7bce0 100644 --- a/Open-ILS/src/eg2/src/app/share/common-widgets.module.ts +++ b/Open-ILS/src/eg2/src/app/share/common-widgets.module.ts @@ -17,6 +17,7 @@ import {DateTimeSelectComponent} from '@eg/share/datetime-select/datetime-select import {ContextMenuModule} from '@eg/share/context-menu/context-menu.module'; import {FileReaderComponent} from '@eg/share/file-reader/file-reader.component'; import {IntervalInputComponent} from '@eg/share/interval-input/interval-input.component'; +import {ClipboardDialogComponent} from '@eg/share/clipboard/clipboard-dialog.component'; @NgModule({ @@ -28,6 +29,7 @@ import {IntervalInputComponent} from '@eg/share/interval-input/interval-input.co DateRangeSelectComponent, DateTimeSelectComponent, FileReaderComponent, + ClipboardDialogComponent, IdlClassTemplateDirective, IntervalInputComponent, ], @@ -50,6 +52,7 @@ import {IntervalInputComponent} from '@eg/share/interval-input/interval-input.co OrgSelectComponent, DateRangeSelectComponent, DateTimeSelectComponent, + ClipboardDialogComponent, ContextMenuModule, FileReaderComponent, IntervalInputComponent, diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.html index fed22766ba..8cf795fc68 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.html @@ -1,6 +1,6 @@ - + diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-actions-menu.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-actions-menu.component.html index 97db338210..8bc8e326c1 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-actions-menu.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-actions-menu.component.html @@ -1,3 +1,13 @@ + + + + +