From 5c1655e6a1b523e564c8121e8df84ffcd6ddd901 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 6 Aug 2018 15:18:35 -0400 Subject: [PATCH] LP#1785681 Patron address copy to clipboard Support copying formatted addresses to the clipboard in the browser staff client, similar to the XUL client. Action is performed via a new link in the addresses section (next to "print") in the patron summary sidebar. Signed-off-by: Bill Erickson Signed-off-by: Garry Collum Signed-off-by: Galen Charlton --- .../templates/staff/circ/patron/t_summary.tt2 | 18 ++++++++++++++++-- .../web/js/ui/default/staff/circ/patron/app.js | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/t_summary.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_summary.tt2 index c89a0075b3..6b16b66b10 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_summary.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_summary.tt2 @@ -181,12 +181,26 @@
{{addr.address_type()}} - [% l('(print)') %] + ([%- l('copy') -%][%- l('/print') -%])
{{addr.street1()}} {{addr.street2()}}
{{addr.city()}}, {{addr.state()}} {{addr.post_code()}}
+ diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index d37ed644f0..d007257e4f 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -339,6 +339,24 @@ function($scope, $q , $location , $filter , egCore , egNet , egUser , egAlertDi }); } + $scope.copy_address = function(addr) { + // Alas, navigator.clipboard is not yet supported in FF and others. + var lNode = document.querySelector('#patron-address-copy-' + addr.id()); + + // Un-hide the textarea just long enough to copy its data. + // Using node.style instead of ng-show/ng-hide in hopes it + // will be quicker, so the user never sees the textarea. + lNode.style.visibility = 'visible'; + lNode.focus(); + lNode.select(); + + if (!document.execCommand('copy')) { + console.error('Copy command failed'); + } + + lNode.style.visibility = 'hidden'; + } + $scope.toggle_expand_summary = function() { if ($scope.collapsePatronSummary) { $scope.collapsePatronSummary = false; -- 2.43.2