From 5371e48a35d765f74a99a91cc4c7be3352325c19 Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Wed, 2 Apr 2025 10:44:52 +0200 Subject: [PATCH] Bug 36275: The displayed values for Client ID and Secret need copy to clipboard buttons in apikeys.tt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds: - A new include with a prepared button that sets the passed copy_to_clipboard_value as the data-value attribute. - A script, which is an IIFE that can also be used elsewhere that then adds event listeners for clicks on the above buttons (or other buttons with data-copy-to-clipboard) - The included buttons and the associated js to apikeys.tt. To test: 1) Activate the RESTOAuth2ClientCredentials syspref. 2) Search for a patron, e.g. 42 3) Go to more -> Manage API keys 4) Generate a new client id/key pair 5) Notice that there are copy to clipboard buttons next to the client id and secret 6) Click one of them 7) Paste your clipboard into the top search input for example 8) Verify it works and the value is identical to the value you copied 9) Sign off https://bugs.koha-community.org/show_bug.cgi?id=36275 Signed-off-by: Emmanuel Bétemps Signed-off-by: Nick Clemens Signed-off-by: Emmanuel Bétemps --- .../en/includes/copy-to-clipboard-button.inc | 1 + .../prog/en/modules/members/apikeys.tt | 3 +++ .../intranet-tmpl/prog/js/copyToClipboard.js | 23 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/copy-to-clipboard-button.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/js/copyToClipboard.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/copy-to-clipboard-button.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/copy-to-clipboard-button.inc new file mode 100644 index 00000000000..2c5f5746d91 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/copy-to-clipboard-button.inc @@ -0,0 +1 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt index 2763aa1ee08..c0ee02bd221 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt @@ -48,10 +48,12 @@
  • Client ID: [% fresh_api_key.client_id | html %] + [% INCLUDE 'copy-to-clipboard-button.inc' copy_to_clipboard_value = fresh_api_key.client_id %]
  • Secret: [% fresh_api_key.plain_text_secret | html %] + [% INCLUDE 'copy-to-clipboard-button.inc' copy_to_clipboard_value = fresh_api_key.plain_text_secret %]
  • @@ -137,6 +139,7 @@ [% MACRO jsinclude BLOCK %] [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") | $raw %] + [% Asset.js("js/copyToClipboard.js") | $raw %]