From 8227cb0e63d312ea672b5181da01a99355b82ccd Mon Sep 17 00:00:00 2001
From: Chloe <chloealabaster@gmail.com>
Date: Thu, 21 Jan 2016 03:20:58 +0000
Subject: [PATCH] Bug 15584 - Staff client list errors are incorrectly styled

To Test-
1-In the Staff Client, go to Lists (/cgi-bin/koha/virtualshelves/shelves.pl) and create a new list with the same name as an existing one. --note that it has some red in it like an error
2- apply patch
3-In the Staff Client, go to Lists (/cgi-bin/koha/virtualshelves/shelves.pl) and create a new list with the same name as an existing one. --note that now it should be just yellow with black writing as an alert

Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>
---
 virtualshelves/shelves.pl | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl
index 3dfa211..70afe07 100755
--- a/virtualshelves/shelves.pl
+++ b/virtualshelves/shelves.pl
@@ -56,11 +56,11 @@ if ( $op eq 'add_form' ) {
         my $patron = GetMember( 'borrowernumber' => $shelf->owner );
         $template->param( owner => $patron, );
         unless ( $shelf->can_be_managed( $loggedinuser ) ) {
-            push @messages, { type => 'error', code => 'unauthorized_on_update' };
+            push @messages, { type => 'alert', code => 'unauthorized_on_update' };
             $op = 'list';
         }
     } else {
-        push @messages, { type => 'error', code => 'does_not_exist' };
+        push @messages, { type => 'alert', code => 'does_not_exist' };
     }
 } elsif ( $op eq 'add' ) {
     eval {
@@ -78,9 +78,10 @@ if ( $op eq 'add_form' ) {
         $shelfnumber = $shelf->shelfnumber;
     };
     if ($@) {
-        push @messages, { type => 'error', code => ref($@), msg => $@ };
+        push @messages, { type => 'alert', code => ref($@), msg => $@ };
     } elsif ( not $shelf ) {
-        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' };
         $op = 'view';
@@ -101,16 +102,16 @@ if ( $op eq 'add_form' ) {
             eval { $shelf->store };
 
             if ($@) {
-                push @messages, { type => 'error', code => 'error_on_update' };
+                push @messages, { type => 'alert', code => 'error_on_update' };
                 $op = 'edit_form';
             } else {
                 push @messages, { type => 'message', code => 'success_on_update' };
             }
         } else {
-            push @messages, { type => 'error', code => 'unauthorized_on_update' };
+            push @messages, { type => 'alert', code => 'unauthorized_on_update' };
         }
     } else {
-        push @messages, { type => 'error', code => 'does_not_exist' };
+        push @messages, { type => 'alert', code => 'does_not_exist' };
     }
 } elsif ( $op eq 'delete' ) {
     $shelfnumber = $query->param('shelfnumber');
@@ -119,15 +120,15 @@ if ( $op eq 'add_form' ) {
         if ( $shelf->can_be_deleted( $loggedinuser ) ) {
             eval { $shelf->delete; };
             if ($@) {
-                push @messages, { type => 'error', code => ref($@), msg => $@ };
+                push @messages, { type => 'alert', code => ref($@), msg => $@ };
             } else {
                 push @messages, { type => 'message', code => 'success_on_delete' };
             }
         } else {
-            push @messages, { type => 'error', code => 'unauthorized_on_delete' };
+            push @messages, { type => 'alert', code => 'unauthorized_on_delete' };
         }
     } else {
-        push @messages, { type => 'error', code => 'does_not_exist' };
+        push @messages, { type => 'alert', code => 'does_not_exist' };
     }
     $op = 'list';
 } elsif ( $op eq 'add_biblio' ) {
@@ -141,21 +142,21 @@ if ( $op eq 'add_form' ) {
                 if ( $shelf->can_biblios_be_added( $loggedinuser ) ) {
                     my $added = eval { $shelf->add_biblio( $biblio->{biblionumber}, $loggedinuser ); };
                     if ($@) {
-                        push @messages, { type => 'error', code => ref($@), msg => $@ };
+                        push @messages, { type => 'alert', code => ref($@), msg => $@ };
                     } elsif ( $added ) {
                         push @messages, { type => 'message', code => 'success_on_add_biblio' };
                     } else {
                         push @messages, { type => 'message', code => 'error_on_add_biblio' };
                     }
                 } else {
-                    push @messages, { type => 'error', code => 'unauthorized_on_add_biblio' };
+                    push @messages, { type => 'alert', code => 'unauthorized_on_add_biblio' };
                 }
             } else {
-                push @messages, { type => 'error', code => 'item_does_not_exist' };
+                push @messages, { type => 'alert', code => 'item_does_not_exist' };
             }
         }
     } else {
-        push @messages, { type => 'error', code => 'does_not_exist' };
+        push @messages, { type => 'alert', code => 'does_not_exist' };
     }
     $op = $referer;
 } elsif ( $op eq 'remove_biblios' ) {
@@ -173,17 +174,17 @@ if ( $op eq 'add_form' ) {
                 );
             };
             if ($@) {
-                push @messages, { type => 'error', code => ref($@), msg => $@ };
+                push @messages, { type => 'alert', code => ref($@), msg => $@ };
             } elsif ( $number_of_biblios_removed ) {
                 push @messages, { type => 'message', code => 'success_on_remove_biblios' };
             } else {
-                push @messages, { type => 'error', code => 'no_biblio_removed' };
+                push @messages, { type => 'alert', code => 'no_biblio_removed' };
             }
         } else {
-            push @messages, { type => 'error', code => 'unauthorized_on_remove_biblios' };
+            push @messages, { type => 'alert', code => 'unauthorized_on_remove_biblios' };
         }
     } else {
-        push @messages, { type => 'error', code => 'does_not_exist' };
+        push @messages, { type => 'alert', code => 'does_not_exist' };
     }
     $op = $referer;
 }
@@ -288,10 +289,10 @@ if ( $op eq 'view' ) {
                 );
             }
         } else {
-            push @messages, { type => 'error', code => 'unauthorized_on_view' };
+            push @messages, { type => 'alert', code => 'unauthorized_on_view' };
         }
     } else {
-        push @messages, { type => 'error', code => 'does_not_exist' };
+        push @messages, { type => 'alert', code => 'does_not_exist' };
     }
 }
 
-- 
2.1.4