Bug 34401: Fix inconsistencies in Item search fields page titles, breadcrumbs, and headers

This patch fixes some inconsistencies in the item search fields
administration page, making sure the page title, breadcrumb navigation,
and page headers are consistent with each other.

The patch makes some changes to the way new item search fields are added
in order to keep the display consistent with other similar interfaces:
The "add" form is no longer shown dynamically from the page listing item
search fields. Clicking the "New search field" toolbar button will now
take you to the same template used for editing existing search fields.
This allows us to put the correct context into page title, breadcrumbs,
and headings.

To test, apply the patch and go to Administration -> Item search fields.
Test the process of adding a new search field and editing an existing
search field.

Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Owen Leonard 2023-10-04 10:51:14 +00:00 committed by Tomas Cohen Arazi
parent 40b8180ff9
commit d10ce467f5
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
5 changed files with 43 additions and 74 deletions

View file

@ -22,7 +22,7 @@ use CGI;
use C4::Auth qw( get_template_and_user );
use C4::Output qw( output_html_with_http_headers );
use Koha::Item::Search::Field qw(GetItemSearchField ModItemSearchField);
use Koha::Item::Search::Field qw(GetItemSearchField AddItemSearchField ModItemSearchField);
my $cgi = CGI->new;
@ -48,6 +48,18 @@ if ($op eq 'mod') {
my $updated = ($field) ? 1 : 0;
print $cgi->redirect('/cgi-bin/koha/admin/items_search_fields.pl?updated=' . $updated);
exit;
} elsif ( $op eq 'add' ) {
my %vars = $cgi->Vars;
my $field;
my @params = qw(name label tagfield tagsubfield authorised_values_category);
@$field{@params} = @vars{@params};
if ( $field->{authorised_values_category} eq '' ) {
$field->{authorised_values_category} = undef;
}
$field = AddItemSearchField($field);
my $added = ($field) ? 1 : 0;
print $cgi->redirect( '/cgi-bin/koha/admin/items_search_fields.pl?added=' . $added );
exit;
}
my $field = GetItemSearchField($name);

View file

@ -22,7 +22,7 @@ use CGI;
use C4::Auth qw( get_template_and_user );
use C4::Output qw( output_html_with_http_headers );
use Koha::Item::Search::Field qw(AddItemSearchField GetItemSearchFields DelItemSearchField);
use Koha::Item::Search::Field qw(GetItemSearchFields DelItemSearchField);
my $cgi = CGI->new;
@ -35,21 +35,7 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({
my $op = $cgi->param('op') || '';
if ($op eq 'add') {
my %vars = $cgi->Vars;
my $field;
my @params = qw(name label tagfield tagsubfield authorised_values_category);
@$field{@params} = @vars{@params};
if ( $field->{authorised_values_category} eq '' ) {
$field->{authorised_values_category} = undef;
}
$field = AddItemSearchField($field);
if ($field) {
$template->param(field_added => $field);
} else {
$template->param(field_not_added => 1);
}
} elsif ($op eq 'del') {
if ($op eq 'del') {
my $name = $cgi->param('name');
my $rv = DelItemSearchField($name);
if ($rv) {

View file

@ -5,6 +5,11 @@
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% FILTER collapse %]
[% IF (field) %]
[% tx("Modify search field '{field}'", { field = field.name }) | html %]
[% ELSE %]
[% t("New search field") | html %]
[% END %] &rsaquo;
[% t("Item search fields") | html %] &rsaquo;
[% t("Administration") | html %] &rsaquo;
[% t("Koha") | html %]
@ -23,17 +28,17 @@
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
[% END %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/admin/items_search_fields.pl">Item search fields</a>
[% END %]
[% IF (field) %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/admin/items_search_fields.pl">Item search fields</a>
[% END %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Modify search field [% field.name | html %]</span>
[% tx("Modify search field '{field}'", { field = field.name }) | html %]
[% END %]
[% ELSE %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Item search fields</span>
<span>New search field</span>
[% END %]
[% END %]
[% END #/ WRAPPER breadcrumbs %]
@ -44,15 +49,22 @@
<div class="col-sm-10 col-sm-push-2">
<main>
<h1>Item search field: [% field.label | html %]</h1>
<h1>
[% IF (field) %]
[% tx("Modify search field '{field}'", { field = field.name }) | html %]
[% ELSE %]
[% t("New search field") | html %]
[% END %]
</h1>
<form action="/cgi-bin/koha/admin/items_search_field.pl" method="POST" id="edit_search_fields">
<form action="/cgi-bin/koha/admin/items_search_field.pl" method="POST" id="search_fields">
<fieldset class="rows">
<legend>Edit field</legend>
[% INCLUDE 'admin-items-search-field-form.inc' field=field %]
<div>
<input type="hidden" name="op" value="mod" />
</div>
[% INCLUDE 'admin-items-search-field-form.inc' field=field %]
[% IF (field) %]
<input type="hidden" name="op" value="mod" />
[% ELSE %]
<input type="hidden" name="op" value="add" />
[% END %]
</fieldset>
<fieldset class="action">
<input type="submit" class="btn btn-primary" value="Submit" />

View file

@ -19,9 +19,6 @@
[% WRAPPER 'sub-header.inc' %]
[% WRAPPER breadcrumbs %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
[% END %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
[% END %]
@ -37,12 +34,12 @@
<main>
<div id="toolbar" class="btn-toolbar">
<a class="btn btn-default" id="new_search_field" href="/cgi-bin/koha/admin/items_search_fields.pl"><i class="fa fa-plus"></i> New search field</a>
<a class="btn btn-default" href="/cgi-bin/koha/admin/items_search_field.pl"><i class="fa fa-plus"></i> New search field</a>
</div>
[% IF field_added %]
<div class="dialog message">
Field successfully added: [% field_added.label | html %]
Field successfully added
</div>
[% ELSIF field_not_added %]
<div class="dialog alert">
@ -60,7 +57,7 @@
</div>
[% ELSIF field_updated %]
<div class="dialog message">
Field successfully updated: [% field_updated.label | html %]
Field successfully updated
</div>
[% ELSIF field_not_updated %]
<div class="dialog alert">
@ -108,18 +105,6 @@
</div>
[% END %]
<form id="add_field_form" action="/cgi-bin/koha/admin/items_search_fields.pl" method="POST">
<fieldset class="rows">
<legend><h1>Add a new field</h1></legend>
[% INCLUDE 'admin-items-search-field-form.inc' field=undef %]
<input type="hidden" name="op" value="add" />
</fieldset>
<fieldset class="action">
<input type="submit" class="btn btn-primary" value="Submit" />
<a href="#" class="cancel hide_form">Cancel</a>
</fieldset>
</form>
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->

View file

@ -5,19 +5,6 @@ jQuery.validator.addMethod("marcfield", function(value, element) {
}, __("Please enter letters or numbers") );
$(document).ready(function(){
$("#add_field_form").hide();
$("#new_search_field").on("click",function(e){
e.preventDefault();
$("#add_field_form").show();
$(".dialog").hide();
$("#search_fields_list,#toolbar").hide();
});
$(".hide_form").on("click",function(e){
e.preventDefault();
$("#add_field_form").hide();
$(".dialog").show();
$("#search_fields_list,#toolbar").show();
});
$(".field-delete").on("click",function(){
$(this).parent().parent().addClass("highlighted-row");
if (confirm( __("Are you sure you want to delete this field?") )) {
@ -28,20 +15,7 @@ $(document).ready(function(){
}
});
$("#add_field_form").validate({
rules: {
label: "required",
tagfield: {
required: true,
marcfield: true
},
tagsubfield: {
marcfield: true
}
}
});
$("#edit_search_fields").validate({
$("#search_fields").validate({
rules: {
label: "required",
tagfield: {