Koha/koha-tmpl/intranet-tmpl/prog/en/modules/admin/restrictions.tt
Emmi Takkinen 20349d8737
Bug 23681: Fix QA issues
This patch fixes following QA issues:
- convert intaller files as .yml
- change column name readonly as is_system
- change column name is_system as default_value
- add column can_be_added_manually (testplan for this below)
- move syspref "PatronRestrictionTypes" to "Accounting > Features" tab
- tweak page title
- tweak tests to apply these changes

Also atomicupdate files have been updated. Issues with delete and tests
is fixed with adding additional schema change file.

To test:
1) Add new restriction type and make it manual.
2) Navigate to patron details page.
3) Add new restriction to patron.
=> Only selectable restriction should be the one
you just created.

Also prove t/db_dependent/RestrictionTypes.t.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-08-25 08:41:05 -03:00

242 lines
9.5 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF op == 'add_form' %][% IF ( restriction ) %]Modify restriction '[% restriction.display_text | html %]'[% ELSE %]New restriction[% END %][% END %]
[% IF op == 'delete_confirm' %]Confirm deletion of restriction '[% restriction.display_text | html %]'[% END %] &rsaquo; Patron restrictions &rsaquo; Administration &rsaquo; Koha
</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="admin_restrictions" class="admin">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'patrons-admin-search.inc' %]
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
<ol>
<li>
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
</li>
<li>
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
</li>
[% IF op == 'list' %]
<li>
<a href="#" aria-current="page">
Patron restrictions
</a>
</li>
[% END %]
[% IF op == 'add_form' %]
<li>
<a href="/cgi-bin/koha/admin/restrictions.pl">Patron restrictions</a>
</li>
[% IF restriction %]
<li>
<a href="#" aria-current="page">
Modify restriction '[% restriction.display_text | html %]'
</a>
</li>
[% ELSE %]
<li>
<a href="#" aria-current="page">
New restriction
</a>
</li>
[% END %]
[% END %]
[% IF op == 'delete_confirm' %]
<li>
<a href="/cgi-bin/koha/admin/restrictions.pl">Patron restrictions</a>
</li>
<li>
<a href="#" aria-current="page">
Delete restriction?
</a>
</li>
[% END %]
</ol>
</nav>
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% FOR m IN messages %]
<div class="dialog [% m.type | html %]">
[% SWITCH m.code %]
[% CASE 'duplicate_display_text' %]
Another restriction already has this label
[% CASE 'duplicate_code' %]
Another restriction already has this code
[% CASE %]
[% m.code | html %]
[% END %]
</div>
[% END %]
[% IF op == 'add_form' %]
<form id="restriction_form" action="/cgi-bin/koha/admin/restrictions.pl" method="post">
<input type="hidden" name="op" value="add_validate" />
<input type="hidden" name="checked" value="0" />
[% IF restriction %]
<h1>Modify restriction [% restriction.display_text | html %]</h1>
<input type="hidden" name="is_a_modif" value="1" />
[% ELSE %]
<h1>New restriction</h1>
[% END %]
<fieldset class="rows">
<ol>
[% IF restriction %]
<li>
<span class="label">Code: </span>[% restriction.code | html %]
<input type="hidden" name="code" value="[% restriction.code | html %]" />
</li>
<li>
<label for="display_text" class="required">Label: </label>
<input type="text" value="[% restriction.display_text | html %]" name="display_text" id="display_text" size="50" maxlength="50" class="required" required="required" />
<span class="required">Required</span>
</li>
<li>
<label for="can_be_added_manually">Can be manually added?</label>
[% IF restriction && restriction.is_system %]
[% IF restriction.can_be_added_manually %]Yes[% ELSE %]No[% END %]
[% ELSIF restriction.can_be_added_manually %]
<input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" checked="checked" value="1" />
[% ELSE %]
<input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" value="1" />
[% END %]
</li>
[% ELSE %]
<li>
<label for="code" class="required">Code: </label>
<input type="text" name="code" id="code" size="50" maxlength="50" class="required type_input " required="required" />
<span class="required">Required</span>
</li>
<li>
<label for="display_text" class="required">Label: </label>
<input type="text" name="display_text" id="display_text" size="50" maxlength="50" class="required" required="required" />
<span class="required">Required</span>
</li>
<li>
<label for="can_be_added_manually">Can be manually added?</label>
[% IF restriction && restriction.is_system %]
[% IF restriction.can_be_added_manually %]Yes[% ELSE %]No[% END %]
[% ELSIF restriction.can_be_added_manually %]
<input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" checked="checked" value="1" />
[% ELSE %]
<input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" value="1" />
[% END %]
</li>
[% END %]
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" value="Save" />
<a href="/cgi-bin/koha/admin/restrictions.pl" class="cancel">Cancel</a>
</fieldset>
</form>
[% END %]
[% IF op == 'delete_confirm' %]
<form action="/cgi-bin/koha/admin/restrictions.pl" method="post">
<fieldset>
<legend>
Confirm restriction deletion
</legend>
<p>Are you sure you want to delete &quot;[% restriction.display_text | html %]&quot;</p>
<fieldset class="action">
<input type="hidden" name="op" value="delete_confirmed" />
<input type="hidden" name="code" value="[% restriction.code | html %]" />
<input type="submit" value="Delete this restriction" />
<a class="cancel" href="/cgi-bin/koha/admin/restrictions.pl">Cancel</a>
</fieldset>
</fieldset>
</form>
[% END %]
[% IF op == 'list' %]
<div id="toolbar" class="btn-toolbar">
<a class="btn btn-default" id="newrestriction" href="/cgi-bin/koha/admin/restrictions.pl?op=add_form"><i class="fa fa-plus"></i> New restriction</a>
</div>
<h2>Patron restrictions</h2>
[% IF searchfield %]
You Searched for [% searchfield | html %]</span>
[% END %]
[% IF restrictions %]
<table id="restriction_types">
<thead>
<tr>
<th scope="col">Code</th>
<th scope="col">Label</th>
<th scope="col">Manual</th>
<th scope="col">Default</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
[% FOREACH restriction IN restrictions %]
<tr>
<td>
[% restriction.code | html %]
</td>
<td>
[% restriction.display_text | html %]
</td>
<td>
[% IF restriction.can_be_added_manually %]Yes[% END %]
</td>
<td>
[% IF restriction.default_value %]Yes[% END %]
</td>
<td class="actions">
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/restrictions.pl?op=add_form&amp;code=[% restriction.code | uri %]"><i class="fa fa-pencil"></i> Edit</a>
[% IF !restriction.is_system %]
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/restrictions.pl?op=delete_confirm&amp;code=[% restriction.code | uri %]"><i class="fa fa-trash"></i> Delete</a>
[% END %]
</td>
</tr>
[% END %]
</tbody>
</table>
[% ELSE %]
<div class="dialog alert">No restrictions have been defined. <a href="/cgi-bin/koha/admin/restrictions.pl?op=add_form">Create a new restriction</a>.</div>
[% END %]
[% END %]
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
[% INCLUDE 'admin-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
<script>
var MSG_DUPLICATE_CODE = _("Restriction code is already in use");
var MSG_DUPLICATE_DISPLAY_TEXT = _("Label is already in use");
var existing = {
[% FOREACH ex IN existing %]
[% ex.code | $raw %]: '[% ex.display_text | $raw %]',
[% END %]
};
</script>
[% Asset.js("js/restrictiontypes.js") | $raw %]
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]