From a830f17948159dce6cb5a8c0aedd5aa4989b43fc Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 16 Apr 2018 15:23:50 +0000 Subject: [PATCH] Bug 20568 (follow-up) Interface and markup changes This patch makes some interface changes to bring things better in line with existing interface patterns. This patch also re-indents the modified templates with 4 spaces instead of 2 and makes s self-closing. Also changed: Corrected system preference check in opac-apikeys.pl. To test, apply the patch and: In the staff client: - Open a patron record and choose More -> Manage API keys. - There should be a standard message dialog containing a link to "Generate a new key." - Clicking the link should show the form for adding a new key. - Test that clicking the "Cancel" link hides the form. - Test that creating the new key works correctly. - You should now see a table showing existing keys and a "Generate a new key" button above it. - Test that the "Delete" button asks for confirmation, and that confirming and denying both work correctly. - Test that "Revoke" and "Activate" actions still work correctly. In the OPAC: - Set the AllowPatronsManageAPIKeysInOPAC system preference to "Allow." - Log in to the OPAC and click the "your API keys" link in the sidebar. - Clicking the "Generate new key" button should display the form for adding a new key. - Clicking the "cancel" link should hide the form. - Submitting the form should add a new key. - You should now see a table showing existing keys. - Test that the "Delete" link asks for confirmation, and that confirming and denying both work correctly. - Test that "Revoke" and "Activate" actions still work correctly. - Set the AllowPatronsManageAPIKeysInOPAC system preference to "Don't allow." - Log in to the OPAC and confirm that the "your API keys" link in the sidebar is no longer visible. - Confirm that navigating directly to /cgi-bin/koha/opac-apikeys.pl results in a 404 error. Signed-off-by: Tomas Cohen Arazi --- .../prog/en/modules/members/apikeys.tt | 157 ++++++++++-------- .../bootstrap/en/modules/opac-apikeys.tt | 124 ++++++++------ opac/opac-apikeys.pl | 2 +- 3 files changed, 160 insertions(+), 123 deletions(-) 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 22a9b2cf91..e710efdd2c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt @@ -1,4 +1,5 @@ [% USE Koha %] +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Patrons › API Keys [% INCLUDE 'doc-head-close.inc' %] @@ -8,80 +9,98 @@ [% INCLUDE 'patron-search.inc' %]
-
-
-
- [% INCLUDE 'members-toolbar.inc' %] +
+
+
+ [% INCLUDE 'members-toolbar.inc' %] -

API keys for [% INCLUDE 'patron-title.inc' %]

-
-
- - - - - -
-
- -
+

API keys for [% INCLUDE 'patron-title.inc' %]

+ -
- [% IF api_keys && api_keys.size > 0 %] - - - - - - - - - - - [% FOREACH key IN api_keys %] - - - - - - - [% END %] - -
DescriptionKeyActiveActions
[% key.description %][% key.value %][% IF key.active %]Yes[% ELSE %]No[% END %] -
- - - - -
-
- - - [% IF key.active %] - - - [% ELSE %] - - - [% END %] -
-
- [% ELSE %] - No keys defined for the current patron. - [% END %] +
+ [% IF api_keys && api_keys.size > 0 %] +

+ +

+ + + + + + + + + + + [% FOREACH key IN api_keys %] + + + + + + + [% END %] + +
DescriptionKeyActiveActions
[% key.description %][% key.value %][% IF key.active %]Yes[% ELSE %]No[% END %] +
+ + + + +
+
+ + + [% IF key.active %] + + + [% ELSE %] + + + [% END %] +
+
+ [% ELSE %] +
No keys defined for the current patron. Generate a new key
+ [% END %] +
+
+
+
+ [% INCLUDE 'circ-menu.inc' %]
-
-
-
- [% INCLUDE 'circ-menu.inc' %]
-
+ +[% MACRO jsinclude BLOCK %] + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt index 13be49b58d..7feecdcda5 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt @@ -10,10 +10,10 @@ @@ -27,61 +27,79 @@
-

Your API keys

-
-
- - - - - +

Your API keys

+

+ +

+ +
+ Generate new key + + + + +
+
+ +
-
- [% IF api_keys && api_keys.size > 0 %] - - - - - - - - - - - [% FOREACH key IN api_keys %] - - - - - +
DescriptionKeyActiveActions
[% key.description %][% key.value %][% IF key.active %]Yes[% ELSE %]No[% END %] -
- - - -
-
- - [% IF key.active %] - - - [% ELSE %] - - + [% IF api_keys && api_keys.size > 0 %] + + + + + + + + + + + [% FOREACH key IN api_keys %] + + + + + + [% END %] - - - - [% END %] - -
DescriptionKeyActiveActions
[% key.description %][% key.value %][% IF key.active %]Yes[% ELSE %]No[% END %] + + + + + +
+ + [% IF key.active %] + + + [% ELSE %] + + + [% END %] +
+
- [% ELSE %] - No keys defined for the current patron. - [% END %] +
+ [% ELSE %] +

No keys defined for the current patron.

+ [% END %]
-[% BLOCK jsinclude %][% END %] +[% BLOCK jsinclude %] + +[% END %] [% INCLUDE 'opac-bottom.inc' %] diff --git a/opac/opac-apikeys.pl b/opac/opac-apikeys.pl index 5dbd18ccb4..7a776f3063 100755 --- a/opac/opac-apikeys.pl +++ b/opac/opac-apikeys.pl @@ -40,7 +40,7 @@ my $patron_id = $loggedinuser; my $patron = Koha::Patrons->find( $patron_id ); if ( not defined $patron - or C4::Context->preference('AllowPatronsManageAPIKeysInOPAC') ) + or !C4::Context->preference('AllowPatronsManageAPIKeysInOPAC') ) { # patron_id invalid -> exit print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early -- 2.17.0