Bug 16092: Fix error dialog and introduce the Font Awesome icons when delete a branc...
authorHector Castro <hector.hecaxmmx@gmail.com>
Thu, 17 Mar 2016 16:42:10 +0000 (10:42 -0600)
committerBrendan A Gallagher <brendan@bywatersolutions.com>
Thu, 31 Mar 2016 19:36:13 +0000 (19:36 +0000)
Also change admin/branch.pl   type => 'error' to type => 'alert' to fit
with wiki <https://wiki.koha-community.org/wiki/Interface_patterns#Errors_and_messages>

To test:
1) Go to Admin -> Libraries and groups
2) Try to delete a library with patrons and bib items
3) See the error message in yellow
4) Try to delete a branch category/group without any library attached
   to it
5) Apply patch and repeat steps 1 to 4. Notice about the changes
6) Test buttons Yes, delete and No, do not delete and verify that they
   work as expected

Signed-off-by: Marc VĂ©ron <veron@veron.ch>
NOTE: Patch rebased and reword title according with QA comment 4

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
admin/branches.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt

index c2ec087..6031f2f 100755 (executable)
@@ -93,7 +93,7 @@ if ( $op eq 'add_form' ) {
 
         eval { $library->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' };
         }
@@ -107,7 +107,7 @@ if ( $op eq 'add_form' ) {
         eval { $library->store; };
         $library->add_to_categories( \@categories );
         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' };
         }
@@ -126,7 +126,7 @@ if ( $op eq 'add_form' ) {
 
     if ( $items_count or $patrons_count ) {
         push @messages,
-          { type => 'error',
+          { type => 'alert',
             code => 'cannot_delete_library',
             data => {
                 items_count   => $items_count,
@@ -147,7 +147,7 @@ if ( $op eq 'add_form' ) {
     my $deleted = eval { $library->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' };
     }
@@ -173,7 +173,7 @@ if ( $op eq 'add_form' ) {
         $category->show_in_pulldown( $input->param('show_in_pulldown') eq 'on' );
         eval { $category->store; };
         if ($@) {
-            push @messages, { type => 'error', code => 'error_on_update_category' };
+            push @messages, { type => 'alert', code => 'error_on_update_category' };
         } else {
             push @messages, { type => 'message', code => 'success_on_update_category' };
         }
@@ -186,7 +186,7 @@ if ( $op eq 'add_form' ) {
         $category->show_in_pulldown( $input->param('show_in_pulldown') eq 'on' );
         eval { $category->store; };
         if ($@) {
-            push @messages, { type => 'error', code => 'error_on_insert_category' };
+            push @messages, { type => 'alert', code => 'error_on_insert_category' };
         } else {
             push @messages, { type => 'message', code => 'success_on_insert_category' };
         }
@@ -196,7 +196,7 @@ if ( $op eq 'add_form' ) {
     my $category = Koha::LibraryCategories->find($categorycode);
     if ( my $libraries_count = $category->libraries->count ) {
         push @messages,
-          { type => 'error',
+          { type => 'alert',
             code => 'cannot_delete_category',
             data => { libraries_count => $libraries_count, },
           };
@@ -209,7 +209,7 @@ if ( $op eq 'add_form' ) {
     my $deleted = eval { $category->delete; };
 
     if ( $@ or not $deleted ) {
-        push @messages, { type => 'error', code => 'error_on_delete_category' };
+        push @messages, { type => 'alert', code => 'error_on_delete_category' };
     } else {
         push @messages, { type => 'message', code => 'success_on_delete_category' };
     }
index aceec04..47da934 100644 (file)
@@ -79,7 +79,7 @@ tinyMCE.init({
     <div id="yui-main">
     <div class="yui-b">
 
-[% FOR m IN messages %]
+[% FOREACH m IN messages %]
     <div class="dialog [% m.type %]">
         [% SWITCH m.code %]
         [% CASE 'error_on_update' %]
@@ -381,13 +381,15 @@ tinyMCE.init({
 [% END %]
 
 [% IF op == 'delete_confirm_category' %]
-    <div class="dialog message">
-    Are you sure you want to delete the group '[% category.codedescription %]' ([% category.categorycode %])?
+    <div class="dialog alert">
+    <h3>Are you sure you want to delete the group '[% category.codedescription %]' ([% category.categorycode %])?</h3>
     <form action="/cgi-bin/koha/admin/branches.pl" method="post">
         <input type="hidden" name="op" value="delete_confirmed_category" />
         <input type="hidden" name="categorycode" value="[% category.categorycode |html %]" />
-        <input type="submit" value="Delete" />
-        <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a>
+        <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
+    </form>
+    <form action="/cgi-bin/koha/admin/branches.pl" method="get">
+        <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
     </form>
     </div>
 [% END %]