Koha/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt
Owen Leonard 29292c9f8d Bug 16297 - Remove the use of "onclick" from OAI sets configuration template
In order to bring the OAI sets configuration template into compliance
with coding guideline JS9, this patch changes with way some JavaScript
events are handled by moving JS handling out of the HTML markup.

To test, apply the patch and go to Administration -> OAI sets
configuration.

- Create or edit a set.
- Test the "Add description" link. Clicking it should add a
  description textarea.
- Test the "Remove" link associated with multiple description lines.
  Click them should remove the corresponding textarea.
- Test that additions and removals are saved correctly.

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-04-29 15:30:34 +00:00

151 lines
6.6 KiB
Text

[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; [% IF ( op_new ) %]OAI sets configuration &rsaquo; Add a new OAI set[% ELSE %]OAI sets configuration[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript">
//<![CDATA[
function newDescField() {
$("#adddescription").before(
'<li><label>setDescription: </label>' +
'<textarea style="vertical-align:middle" rows="2" cols="30" name="description"></textarea>' +
'<a class="remove_description" href="#"><i class="fa fa-fw fa-trash"></i> Remove</a>' +
'</li>'
);
}
function delDescField(minusButton) {
var li = minusButton.parent('li');
$(li).remove();
}
function confirmDelete() {
return confirm(_("Are you sure you want to delete this OAI set?"));
}
$(document).ready(function() {
$(".delete_oai_set").on("click",function(){
return confirmDelete();
});
$("body").on("click", ".remove_description", function(e){
e.preventDefault();
delDescField($(this));
});
$(".add_description").on("click", function(e){
e.preventDefault();
newDescField();
});
});
//]]>
</script>
</head>
<body id="admin_oai_sets" class="admin">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( op_new ) %]<a href="/cgi-bin/koha/admin/oai_sets.pl">OAI sets configuration</a> &rsaquo; Add a new OAI set[% ELSIF ( op_mod ) %]<a href="/cgi-bin/koha/admin/oai_sets.pl">OAI sets configuration</a> &rsaquo; Edit OAI set '[% spec %]'[% ELSE %] OAI sets configuration[% END %]</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
[% IF ( op_new || op_mod ) %]
<form method="post" action="/cgi-bin/koha/admin/oai_sets.pl" class="validated">
[% IF ( op_new ) %]
<h2>Add a new OAI set</h2>
<input type="hidden" name="op" value="savenew" />
[% ELSIF ( op_mod ) %]
<h2>Edit OAI set '[% spec %]'</h2>
<input type="hidden" name="op" value="savemod" />
<input type="hidden" name="id" value="[% id %]" />
[% END %]
<fieldset id="oaidetails" class="rows">
<ol>
<li>
<label for="spec" class="required">setSpec: </label>
<input type="text" id="spec" name="spec" value="[% spec %]" required="required" class="required" />
<span class="required">Required</span>
</li>
<li>
<label for="name" class="required">setName: </label>
<input type="text" id="name" name="name" value="[% name %]" required="required" class="required" />
<span class="required">Required</span>
</li>
[% FOREACH desc IN descriptions %]
<li>
<label>setDescription: </label>
<textarea style="vertical-align:middle" rows="2" cols="30" name="description">[% desc.description %]</textarea>
<a class="remove_description" href="#"><i class="fa fa-fw fa-trash"></i> Remove</a>
</li>
[% END %]
<li id="adddescription"><span class="label">&nbsp;</span><a href="#" class="add_description"><i class="fa fa-fw fa-plus"></i> Add description</a></li>
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/oai_sets.pl">Cancel</a>
</fieldset>
</form>
[% ELSE %]
<div id="toolbar" class="btn-toolbar">
<a class="btn btn-small" id="newoaiset" href="/cgi-bin/koha/admin/oai_sets.pl?op=new"><i class="fa fa-plus"></i> New set</a>
</div>
<h2>OAI sets</h2>
[% IF sets_loop %]
<table>
<thead>
<tr>
<th>setSpec</th>
<th>setName</th>
<th>setDescriptions</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
[% FOREACH set IN sets_loop %]
<tr>
<td>[% set.spec %]</td>
<td>[% set.name %]</td>
<td>
[% IF set.descriptions %]
<ul>
[% FOREACH desc IN set.descriptions %]
<li>[% desc.description %]</li>
[% END %]
</ul>
[% ELSE %]
<em>No descriptions</em>
[% END %]
</td>
<td>
<div class="dropdown">
<a class="btn btn-mini dropdown-toggle" id="oaisetsactions[% set.id %]" role="button" data-toggle="dropdown" href="#">
Actions <b class="caret"></b></a>
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="oaisetsactions[% set.id %]">
<li><a href="/cgi-bin/koha/admin/oai_sets.pl?op=mod&amp;id=[% set.id %]"><i class="fa fa-fw fa-pencil"></i> Edit</a></li>
<li><a class="delete_oai_set" href="/cgi-bin/koha/admin/oai_sets.pl?op=del&amp;id=[% set.id %]"><i class="fa fa-fw fa-trash"></i> Delete</a></li>
<li><a href="/cgi-bin/koha/admin/oai_set_mappings.pl?id=[% set.id %]"><i class="fa fa-fw fa-info"></i> Define mappings</a></li>
</ul>
</div>
</td>
</tr>
[% END %]
</tbody>
</table>
[% ELSE %]
<div class="dialog message"><p>There are no sets defined.</p></div>
[% END %]
[% END %]
</div>
</div>
<div class="yui-b">
[% INCLUDE 'admin-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]