Bug 22575: Item type administration uses invalid error class for dialog
authorOwen Leonard <oleonard@myacpl.org>
Tue, 26 Mar 2019 14:11:28 +0000 (14:11 +0000)
committerLucas Gass <lucas@bywatersolutions.com>
Mon, 15 Apr 2019 16:49:24 +0000 (16:49 +0000)
This patch modifies the item types administration script so that it
passes a valid message type to the template, where the type is used as a
CSS class. "Error" is a nonexistent dialog class. It should be "alert."

To test, apply the patch and go to Administration -> Item types.

 - Try to delete an item type which is in use. The style of the error
   dialog should be correct.
 - Try to add an item type using a code which already exists. The error
   should look correct.

Signed-off-by: Pierre-Marc Thibault <pierre-marc.thibault@inLibro.com>
Signed-off-by: Bin Wen <bin.wen@inlibro.com>

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

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 40503c8fa86e6c4480ec8ca59e28f0c6f394502d)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 7f81521067d5fcca8ba399a280515ce8942c7284)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

admin/itemtypes.pl

index cc790df..994b846 100755 (executable)
@@ -106,7 +106,7 @@ if ( $op eq 'add_form' ) {
         eval { $itemtype->store; };
 
         if ($@) {
-            push @messages, { type => 'error', code => 'error_on_update' };
+            push @messages, { type => 'alert', code => 'error_on_update' };
         } else {
             push @messages, { type => 'message', code => 'success_on_update' };
         }
@@ -130,13 +130,13 @@ if ( $op eq 'add_form' ) {
         eval { $itemtype->store; };
 
         if ($@) {
-            push @messages, { type => 'error', code => 'error_on_insert' };
+            push @messages, { type => 'alert', code => 'error_on_insert' };
         } else {
             push @messages, { type => 'message', code => 'success_on_insert' };
         }
     } else {
         push @messages,
-          { type => 'error',
+          { type => 'alert',
             code => 'already_exists',
           };
     }
@@ -148,7 +148,7 @@ if ( $op eq 'add_form' ) {
     my $itemtype = Koha::ItemTypes->find($itemtype_code);
     my $can_be_deleted = $itemtype->can_be_deleted();
     if ($can_be_deleted == 0) {
-        push @messages, { type => 'error', code => 'cannot_be_deleted'};
+        push @messages, { type => 'alert', code => 'cannot_be_deleted'};
         $op = 'list';
     } else {
         $template->param( itemtype => $itemtype, );
@@ -159,7 +159,7 @@ if ( $op eq 'add_form' ) {
     my $itemtype = Koha::ItemTypes->find($itemtype_code);
     my $deleted = eval { $itemtype->delete };
     if ( $@ or not $deleted ) {
-        push @messages, { type => 'error', code => 'error_on_delete' };
+        push @messages, { type => 'alert', code => 'error_on_delete' };
     } else {
         push @messages, { type => 'message', code => 'success_on_delete' };
     }