[Jifty-commit] r3673 - in jifty/trunk: lib/Jifty/View/Declare

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed Jul 11 20:04:14 EDT 2007


Author: trs
Date: Wed Jul 11 20:04:13 2007
New Revision: 3673

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/View/Declare/CRUD.pm

Log:
 r25176 at zot:  tom | 2007-07-11 20:03:57 -0400
 - Minor refactoring for easy wording change
 - Provide the D in CRUD


Modified: jifty/trunk/lib/Jifty/View/Declare/CRUD.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/CRUD.pm	(original)
+++ jifty/trunk/lib/Jifty/View/Declare/CRUD.pm	Wed Jul 11 20:04:13 2007
@@ -194,8 +194,8 @@
     my $self = shift;
     my $record = shift;
 
-    if ($record->current_user_can('update')) {
-	hyperlink(
+    if ( $record->current_user_can('update') ) {
+        hyperlink(
             label   => _("Edit"),
             class   => "editlink",
             onclick => {
@@ -252,6 +252,13 @@
 
     my $object_type = $self->object_type;
     my $id = $record->id;
+
+    my $delete = Jifty->web->form->add_action(
+        class   => 'Delete' . $object_type,
+        moniker => 'delete-' . Jifty->web->serial,
+        record  => $record
+    );
+
         div {
             { class is 'crud editlink' };
             hyperlink(
@@ -271,6 +278,16 @@
                 },
                 as_button => 1
             );
+            if ( $record->current_user_can('delete') ) {
+                $delete->button(
+                    label   => 'Delete',
+                    onclick => {
+                        submit => $delete,
+                        confirm => 'Really delete?',
+                        refresh => Jifty->web->current_region->parent,
+                    }
+                );
+            }
         };
 
 };
@@ -376,13 +393,15 @@
 
 =cut
 
+private template 'no_items_found' => sub { outs(_("No items found.")) };
+
 private template 'list_items' => sub {
     my $self        = shift;
     my $collection  = shift;
     my $item_path   = shift;
     my $object_type = $self->object_type;
     if ( $collection->pager->total_entries == 0 ) {
-        outs( _("No items found") );
+        show('no_items_found');
     }
 
     div {


More information about the Jifty-commit mailing list