Koha/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt
Owen Leonard 37efe6ff76 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 <input>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 <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2018-05-09 12:55:58 -03:00

105 lines
5.6 KiB
Text

[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your API keys</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %][% END %]
</head>
[% INCLUDE 'bodytag.inc' bodyid='opac-user' bodyclass='scrollto' %]
[% INCLUDE 'masthead.inc' %]
<div class="main">
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
<li>
<a href="/cgi-bin/koha/opac-user.pl">
[% INCLUDE 'patron-title.inc' category_type=patron.category.category_type firstname=patron.firstname surname=patron.surname othernames=patron.othernames %]
</a>
<span class="divider">&rsaquo;</span>
</li>
<li><a href="/cgi-bin/koha/opac-apikeys.pl">Your API keys</a></li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<div id="navigation">
[% INCLUDE 'navigation.inc' IsPatronPage = 1 %]
</div>
</div>
<div class="span10">
<div id="apikeys" class="maincontent">
<h1>Your API keys</h1>
<p>
<button id="show-api-form" style="display:none" class="btn btn-default btn-sm" type="button"><i class="fa fa-plus"></i> Generate new key</button>
</p>
<form id="add-api-key" action="/cgi-bin/koha/opac-apikeys.pl" method="post">
<fieldset>
<legend>Generate new key</legend>
<input type="hidden" name="patron_id" value="[% patron.id %]" />
<input type="hidden" name="op" value="generate" />
<label for="description">Description: </label>
<input type="text" name="description" />
</fieldset>
<fieldset class="action">
<button class="btn btn-default btn-sm" type="submit">Save</button> <a href="#" style="display:none" class="cancel cancel-api-key">Cancel</a>
</fieldset>
</form>
[% IF api_keys && api_keys.size > 0 %]
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Description</th>
<th>Key</th>
<th>Active</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
[% FOREACH key IN api_keys %]
<tr>
<td>[% key.description %]</td>
<td>[% key.value %]</td>
<td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
<td>
<form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline">
<input type="hidden" name="key" value="[% key.value %]" />
<input type="hidden" name="op" value="delete" />
<button class="btn btn-link btn-xs delete-key" type="submit"><i class="fa fa-trash"></i> Delete</button>
</form>
<form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline">
<input type="hidden" name="key" value="[% key.value %]" />
[% IF key.active %]
<input type="hidden" name="op" value="revoke" />
<button class="btn btn-link btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button>
[% ELSE %]
<input type="hidden" name="op" value="activate" />
<button class="btn btn-link btn-xs" type="submit"><i class="fa fa-play"></i> Activate</button>
[% END %]
</form>
</td>
</tr>
[% END %]
</tbody>
</table>
[% ELSE %]
<p>No keys defined for the current patron.</p>
[% END %]
</div> <!-- /#apikeys -->
</div> <!-- /.span10 -->
</div> <!-- /.row-fluid -->
</div> <!-- /.container-fluid -->
</div> <!-- /#main -->
[% BLOCK jsinclude %]
<script>
$(document).ready(function(){
$("#add-api-key, #show-api-form, .cancel-api-key").toggle();
$("#show-api-form, .cancel-api-key").on("click", function(){
$("#add-api-key, #show-api-form").toggle();
});
$(".delete-key").on("click", function(){
return confirm(_("Are you sure you want to delete this key?"));
});
});
</script>
[% END %]
[% INCLUDE 'opac-bottom.inc' %]