Koha/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt
Owen Leonard d3dde3c9cd
Bug 34411: Inconsistencies in Additional fields page titles, breadcrumbs, and header
This patch makes changes to the additional fields administration
template in order to make it more consistent with other pages in Koha.

To test, apply the patch and go to Administration -> Additional fields.
View each variation of the page to confirm that breadcrumb navigation,
page title, and page headings are consistent with each other.

- Main list
  - Table view (e.g. aqbasket, aqorders, etc)
    - New field
    - Edit field

Signed-off-by: Salah Ghedda <salah.ghedda@inLibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-09-18 12:06:14 -03:00

307 lines
14 KiB
Text
Executable file

[% USE AuthorisedValues %]
[% USE raw %]
[% PROCESS 'i18n.inc' %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% FILTER collapse %]
[% SWITCH op %]
[% CASE 'add_form' %]
[% IF field %]
[% tx("Modify field '{field_name}'", { field_name = field.name }) | html %] &rsaquo;
[% ELSE %]
[% t("New field") | html %] &rsaquo;
[% END %]
[% tx("Table '{table_name}'", { table_name = tablename } ) | html %]
[% CASE 'list' %]
[% tx("Table '{table_name}'", { table_name = tablename } ) | html %]
[% END %] &rsaquo;
[% t("Additional fields") | html %] &rsaquo;
[% t("Administration") | html %] &rsaquo;
[% t("Koha") | html %]
[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
[% marcfield_tables = ['subscription', 'aqorders'] %]
[% searchable_tables = ['subscription', 'aqbasket', 'aqinvoices'] %]
[% show_marcfield = marcfield_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %]
[% show_searchable = searchable_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %]
<body id="ser_add_fields" class="ser">
[% WRAPPER 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
[% END %]
[% WRAPPER 'sub-header.inc' %]
[% WRAPPER breadcrumbs %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
[% END %]
[% SWITCH op %]
[% CASE 'add_form' %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a>
[% END %]
[% IF field %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/admin/additional-fields.pl?tablename=[% tablename | uri %]">[% tx("Table '{table_name}'", { table_name = tablename } ) | html %]</a>
[% END %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
[% tx("Modify field '{field_name}'", { field_name = field.name }) | html %]
[% END %]
[% ELSE %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/admin/additional-fields.pl?tablename=[% tablename | uri %]">[% tx("Table '{table_name}'", { table_name = tablename } ) | html %]</a>
[% END %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
[% t("New field" ) | html %]
[% END %]
[% END %]
[% CASE 'list' %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a>
[% END %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
[% tx("Table '{table_name}'", { table_name = tablename } ) | html %]
[% END %]
[% CASE %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Additional fields</span>
[% END %]
[% END %]
[% END #/ WRAPPER breadcrumbs %]
[% END #/ WRAPPER sub-header.inc %]
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% IF op == 'list' %]
<div id="toolbar" class="btn-toolbar">
<a class="btn btn-default" id="newfields" href="?op=add_form&amp;tablename=[% tablename | uri %]"><i class="fa fa-plus"></i> New field</a>
</div>
[% END %]
[% IF messages %]
[% FOR message IN messages %]
[% IF message.code == 'insert' %]
[% IF message.number > 0 %]
<div class="dialog message">The field has been added</div>
[% ELSE %]
<div class="dialog alert">The field could not be added. Perhaps the name already exists?</div>
[% END %]
[% ELSIF message.code == 'update' %]
[% IF message.number > 0 %]
<div class="dialog message">The field has been updated</div>
[% ELSE %]
<div class="dialog alert">The field could not be updated. Perhaps the name already exists?</div>
[% END %]
[% ELSIF message.code == 'delete' %]
[% IF message.number > 0 %]
<div class="dialog message">The field has been deleted</div>
[% ELSE %]
<div class="dialog alert">The field could not be deleted. Check the log for errors.</div>
[% END %]
[% END %]
[% END %]
[% END %]
[% IF op == 'list_tables' %]
[% IF CAN_user_acquisitions_order_manage || CAN_user_serials_edit_subscription || CAN_user_updatecharges_remaining_permissions %]
<h1>Additional fields</h1>
<div class="page-section">
<h2>Select a table:</h2>
[% BLOCK table_option %]
<li><a href="?tablename=[% value | uri %]">[% content | $raw %] (<span class="ex">[% value | html %]</span>)</a></li>
[% END %]
<ul>
[% IF CAN_user_acquisition_order_manage %]
[% WRAPPER table_option value="aqbasket" %]<span>Order baskets</span>[% END %]
[% WRAPPER table_option value="aqorders" %]<span>Order lines</span>[% END %]
[% END %]
[% IF CAN_user_acquisition_edit_invoices %]
[% WRAPPER table_option value="aqinvoices" %]<span>Invoices</span>[% END %]
[% END %]
[% IF CAN_user_serials_edit_subscription %]
[% WRAPPER table_option value="subscription" %]<span>Subscriptions</span>[% END %]
[% END %]
[% IF CAN_user_updatecharges_remaining_permissions %]
[% WRAPPER table_option value="accountlines:credit" %]Account lines (credit)[% END %]
[% WRAPPER table_option value="accountlines:debit" %]Account lines (debit)[% END %]
[% END %]
</ul>
[% ELSE %]
Additional permissions are required for editing additional fields
[% END %]
</div><!-- /.page-section -->
[% ELSIF op == 'list' %]
<h1>Additional fields for '[% tablename | html %]'</h1>
[% IF fields %]
<div class="page-section">
<table id="fieldst">
<thead>
<tr>
<th>Name</th>
<th>Authorized value category</th>
[% IF show_marcfield %]
<th>MARC field</th>
<th>MARC field mode</th>
[% END %]
[% IF show_searchable %]
<th>Searchable</th>
[% END %]
<th class="noExport">Actions</th>
</tr>
</thead>
<tbody>
[% FOR field IN fields %]
<tr>
<td>[% field.name | html %]</td>
<td>[% field.authorised_value_category | html %]</td>
[% IF show_marcfield %]
<td>[% field.marcfield | html %]</td>
<td>
[% SWITCH field.marcfield_mode %]
[% CASE 'get' %]Get value from MARC record
[% CASE 'set' %]Save value to MARC record
[% END %]
</td>
[% END %]
[% IF show_searchable %]
<td>
[% IF field.searchable %]Yes[% ELSE %]No[% END %]
</td>
[% END %]
<td class="actions">
<a class="btn btn-default btn-xs" href="?op=add_form&amp;field_id=[% field.id | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<a class="confirmdelete btn btn-default btn-xs" href="?op=delete&amp;field_id=[% field.id | uri %]&amp;tablename=[% tablename | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
</td>
</tr>
[% END %]
</tbody>
</table>
</div><!-- /.page-section -->
[% ELSE %]
[% IF tablename %]There are no additional fields defined for this table.[% END %]
[% END %]
[% ELSIF op == 'add_form' %]
[% IF field %]
<h1>[% tx("Modify field '{field_name}' for table '{table_name}'", { field_name = field.name, table_name = tablename }) | html %]</h1>
[% ELSE %]
<h1>[% tx("New field for table '{table_name}'", { table_name = tablename } ) | html %]</h1>
[% END %]
<form action="" name="add_form" id="add_field" method="post">
<fieldset class="rows">
<ol>
<li>
<label for="name" class="required">Name: </label>
<input type="text" name="name" id="name" value="[% field.name | html %]" class="required focus" required="required" />
<span class="required">Required</span>
</li>
<li>
<label for="av">Authorized value category: </label>
<select id="av" name="authorised_value_category">
<option value="">None</option>
[% PROCESS options_for_authorised_value_categories authorised_value_categories = AuthorisedValues.GetCategories({selected => field.authorised_value_category}) %]
</select>
</li>
[% IF show_marcfield %]
<li>
<label for="marcfield">MARC field: </label>
<input type="text" name="marcfield" id="marcfield" value="[% field.marcfield | html %]" />
<div class="hint">Example: 942$c</div>
</li>
<li>
<label for="marcfield_mode">MARC field mode: </label>
<select id="marcfield_mode" name="marcfield_mode">
[% IF field.marcfield_mode == 'get' %]
<option value="get" selected>Get value from MARC record (not modifiable)</option>
[% ELSE %]
<option value="get">Get value from MARC record (not modifiable)</option>
[% END %]
[% IF field.marcfield_mode == 'set' %]
<option value="set" selected>Save value to MARC record</option>
[% ELSE %]
<option value="set">Save value to MARC record</option>
[% END %]
</select>
</li>
[% END %]
[% IF show_searchable %]
<li>
<label for="searchable">Searchable: </label>
[% IF field.searchable %]
<input type="checkbox" name="searchable" id="searchable" checked="checked" />
[% ELSE %]
<input type="checkbox" name="searchable" id="searchable" />
[% END %]
</li>
[% END %]
</ol>
</fieldset>
<fieldset class="action">
[% IF field %]
<input type="hidden" name="field_id" value="[% field.id | html %]" />
[% END %]
<input type="hidden" name="tablename" value="[% tablename | html %]" />
<input type="hidden" name="op" value="add" />
<input type="submit" class="btn btn-primary" value="Save" />
<a href="?tablename=[% tablename | uri %]" class="cancel">Cancel</a>
</fieldset>
</form>
[% 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 %]
[% INCLUDE "datatables.inc" %]
<script>
$(document).ready(function(){
$('#selecttable').find(":submit").hide();
$('#selecttable select').change(function() {
$('#selecttable').submit();
});
$("#fieldst").dataTable($.extend(true, {}, dataTablesDefaults, {
'bAutoWidth': false,
'sDom': 't<"bottom pager"ilpf>',
'sPaginationType': 'full',
'aLengthMenu': [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
'iDisplayLength': 20,
'aaSorting': [[ 0, "asc" ]],
}));
$(".confirmdelete").click(function(){
return confirm(_("Are you sure you want to delete this field?"));
});
$("#add_field").on('submit', function() {
if ( $("#marcfield").length && $("select[name='authorised_value_category']").length ) {
if ( $("#marcfield").val().length > 0
&& $("select[name='authorised_value_category']" ).val().length > 0 ) {
alert(_("You cannot select an authorised value category and a MARC field") );
return false;
}
}
return true;
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]