Bugzilla – Attachment 37226 Details for
Bug 5002
No error message if category code already exists
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[Signed-off] Bug 5002: Display messages on adding/deleting patron category
Signed-off-Bug-5002-Display-messages-on-addingdele.patch (text/plain), 8.13 KB, created by
Marc Véron
on 2015-03-25 16:06:46 UTC
(
hide
)
Description:
[Signed-off] Bug 5002: Display messages on adding/deleting patron category
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2015-03-25 16:06:46 UTC
Size:
8.13 KB
patch
obsolete
>From ac50c5024f107cc7386bb691ba7f3466b462d1b9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 24 Mar 2015 12:35:56 +0100 >Subject: [PATCH] [Signed-off] Bug 5002: Display messages on adding/deleting > patron category >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >There are no messages on adding and deleting patron category. >If an error occurs and the data is not inserted, the interface does not >alert the user. > >This patch adds a message block to alert the user if something wrong >happened. > >Test plan: >1/ Create a patron category PATCAT. You should get a confirmation >message. >2/ Try to create another patron category with the same code. You should >get an error message >3/ Delete the patron category PATCAT. You should get a confirmation >message. > >Confirm there is no regression on this form (try update an existing >patron category too). > >Followed test plan, works as expected. >Signed-off-by: Marc Véron <veron@veron.ch> >--- > admin/categorie.pl | 46 ++++++++++++-------- > .../prog/en/modules/admin/categorie.tt | 40 ++++++++--------- > 2 files changed, 47 insertions(+), 39 deletions(-) > >diff --git a/admin/categorie.pl b/admin/categorie.pl >index 75cee49..60d2c84 100755 >--- a/admin/categorie.pl >+++ b/admin/categorie.pl >@@ -71,8 +71,9 @@ my $input = new CGI; > my $searchfield = $input->param('description'); > my $script_name = "/cgi-bin/koha/admin/categorie.pl"; > my $categorycode = $input->param('categorycode'); >-my $op = $input->param('op') // ''; >+my $op = $input->param('op') // 'list'; > my $block_expired = $input->param("block_expired"); >+my @messages; > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >@@ -85,12 +86,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-$template->param( >- script_name => $script_name, >- categorycode => $categorycode, >- searchfield => $searchfield >-); >- > ################## ADD_FORM ################################## > # called by default. Used to create form to add or modify a record > if ( $op eq 'add_form' ) { >@@ -171,7 +166,6 @@ if ( $op eq 'add_form' ) { > # called by add_form, used to insert/modify data in DB > } > elsif ( $op eq 'add_validate' ) { >- $template->param( add_validate => 1 ); > > my $is_a_modif = $input->param("is_a_modif"); > >@@ -249,7 +243,7 @@ elsif ( $op eq 'add_validate' ) { > default_privacy > ) > VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)" ); >- $sth->execute( >+ my $inserted = $sth->execute( > map { $input->param($_) } ( > 'categorycode', 'description', > 'enrolmentperiod', 'enrolmentperioddate', >@@ -260,15 +254,20 @@ elsif ( $op eq 'add_validate' ) { > 'default_privacy', > ) > ); >- $sth->finish; >+ if ( $inserted ) { >+ push @messages, { type => 'message', code => 'success_on_insert' }; >+ } else { >+ $searchfield = q||; >+ push @messages, { type => 'error', code => 'error_on_insert' }; >+ } > } > > if ( C4::Context->preference('EnhancedMessagingPreferences') ) { > C4::Form::MessagingPreferences::handle_form_action( $input, > { categorycode => $input->param('categorycode') }, $template ); > } >- print $input->redirect("/cgi-bin/koha/admin/categorie.pl"); >- exit; >+ >+ $op = 'list'; > > # END $OP eq ADD_VALIDATE > ################## DELETE_CONFIRM ################################## >@@ -301,15 +300,20 @@ elsif ( $op eq 'delete_confirmed' ) { > > my $sth = $dbh->prepare("delete from categories where categorycode=?"); > >- $sth->execute($categorycode); >- $sth->finish; >+ my $deleted = $sth->execute($categorycode); > >- print $input->redirect("/cgi-bin/koha/admin/categorie.pl"); >- exit; >+ if ( $deleted ) { >+ push @messages, { type => 'message', code => 'success_on_delete' }; >+ } else { >+ push @messages, { type => 'error', code => 'error_on_delete' }; >+ } >+ >+ $op = 'list'; > > # END $OP eq DELETE_CONFIRMED > } >-else { # DEFAULT >+ >+if ( $op eq 'list' ) { > $template->param( else => 1 ); > my @loop; > my ( $count, $results ) = StringSearch( $searchfield, 'web' ); >@@ -378,6 +382,14 @@ else { # DEFAULT > $sth->finish; > > } #---- END $OP eq DEFAULT >+ >+$template->param( >+ script_name => $script_name, >+ categorycode => $categorycode, >+ searchfield => $searchfield, >+ messages => \@messages, >+); >+ > output_html_with_http_headers $input, $cookie, $template->output; > > exit 0; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt >index a2ad329..281d24a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt >@@ -1,9 +1,8 @@ > [% USE KohaDates -%] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Patron categories › [% IF ( add_form ) %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %] >-[% IF ( add_validate ) %]Data recorded[% END %] > [% IF ( delete_confirm ) %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] >-[% IF ( delete_confirmed ) %]Category deleted[% END %]</title> >+</title> > [% INCLUDE 'doc-head-close.inc' %] > [% INCLUDE 'calendar.inc' %] > <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >@@ -98,7 +97,6 @@ > [% INCLUDE 'patrons-admin-search.inc' %] > > <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › [% IF ( add_form ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %] >-[% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › Data recorded[% END %] > [% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF ( patrons_in_category > 0 ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] > [% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › Category deleted[% END %] > [% IF ( else ) %]Patron categories[% END %]</div> >@@ -109,11 +107,24 @@ > <div id="yui-main"> > <div class="yui-b"> > >-[% IF ( add_form ) %] >- >- >+[% FOR m IN messages %] >+ <div class="dialog [% m.type %]"> >+ [% SWITCH m.code %] >+ [% CASE 'error_on_insert' %] >+ An error occurred when inserting this patron category. Perhaps the category code already exists. >+ [% CASE 'error_on_delete' %] >+ An error occurred when deleteing this patron category. Check the logs. >+ [% CASE 'success_on_insert' %] >+ Patron category inserted with success. >+ [% CASE 'success_on_delete' %] >+ Patron category deleted with success. >+ [% CASE %] >+ [% m.code %] >+ [% END %] >+ </div> >+[% END %] > >- >+[% IF ( add_form ) %] > <form name="Aform" action="[% script_name %]" method="post"> > <input type="hidden" name="op" value="add_validate" /> > <input type="hidden" name="checked" value="0" /> >@@ -258,13 +269,6 @@ > > [% END %] > >-[% IF ( add_validate ) %] >-<h3>Data recorded</h3> >- <form action="[% script_name %]" method="post"> >- <input type="submit" value="OK" /> >- </form> >-[% END %] >- > [% IF ( delete_confirm ) %] > <form action="[% script_name %]" method="post"> > <fieldset> >@@ -317,14 +321,6 @@ > [% END %]</fieldset></fieldset></form> > [% END %] > >-[% IF ( delete_confirmed ) %] >-<h3>Category deleted</h3> >- >- <form action="[% script_name %]" method="post"> >- <input type="submit" value="OK" /> >- </form> >-[% END %] >- > [% IF ( else ) %] > > <div id="toolbar" class="btn-toolbar"> >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5002
:
37174
|
37226
|
37256
|
37257
|
37260
|
37319
|
37320