[Jifty-commit] r880 - in jifty/trunk: lib/Jifty lib/Jifty/Web/Form share/web/static/js

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Apr 20 21:49:46 EDT 2006


Author: alexmv
Date: Thu Apr 20 21:49:44 2006
New Revision: 880

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Action.pm
   jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
   jifty/trunk/lib/Jifty/Web/Form/Element.pm
   jifty/trunk/share/web/static/js/jifty.js

Log:
 r12451 at zoq-fot-pik:  chmrr | 2006-04-20 21:48:05 -0400
  * Buttons should produce registrations
  * links and buttons should insert submit information into their onclicks
  * First pass at removing regions
  * If we can't know the path of the region (because we don't know
 about it), carry on anyways, but output a debug warning.


Modified: jifty/trunk/lib/Jifty/Action.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action.pm	(original)
+++ jifty/trunk/lib/Jifty/Action.pm	Thu Apr 20 21:49:44 2006
@@ -410,6 +410,7 @@
                  @_);
 
     Jifty->web->form->register_action( $self );
+    Jifty->web->form->print_action_registration($self->moniker);
     $args{parameters}{$self->form_field_name($_)} = $args{arguments}{$_}
       for keys %{$args{arguments}};
 

Modified: jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Clickable.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Clickable.pm	Thu Apr 20 21:49:44 2006
@@ -143,6 +143,11 @@
         $args{submit} = [ $args{submit} ] unless ref $args{submit} eq "ARRAY";
         $args{submit}
             = [ map { ref $_ ? $_->moniker : $_ } @{ $args{submit} } ];
+
+        # If they have an onclick, add any and all submit actions to the onclick's submit list
+        if ($args{onclick}) {
+            $args{onclick} = [ (ref $args{onclick} eq "ARRAY" ? @{ $args{onclick} } : $args{onclick}), map { submit => $_ }, @{$args{submit}} ];
+        }
     }
 
     for my $field ( $self->accessors() ) {

Modified: jifty/trunk/lib/Jifty/Web/Form/Element.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Element.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Element.pm	Thu Apr 20 21:49:44 2006
@@ -39,7 +39,7 @@
 
 Replaces the region specified by the C<region> parameter (which
 defaults to the current region) with the fragment located at the given
-C<PATH>.
+C<PATH>.  If C<undef> is passed as the C<PATH>, acts like a L</delete>.
 
 =item refresh => REGION
 
@@ -48,8 +48,12 @@
 
 =item refresh_self => 1
 
-Refreshes the current region; this is the default action, if C<args>
-are supplied, but no other mode is given.
+Refreshes the current region; this is the default action, if a
+non-empty C<args> is supplied, but no other mode is given.
+
+=item delete => REGION
+
+Removes the given C<REGION> from the page, permanently.
 
 =back
 
@@ -151,14 +155,24 @@
                 @args{qw/mode path/} = ('Top', $hook->{prepend});
                 $hook->{element} ||= "#region-".$hook->{region};
             } elsif (exists $hook->{replace_with}) {
-                @args{qw/mode path region/} = ('Replace', $hook->{replace_with}, $hook->{region});
+                if (defined $hook->{replace_with}) {
+                    @args{qw/mode path region/} = ('Replace', $hook->{replace_with}, $hook->{region});
+                } else {
+                    @args{qw/mode region/} = ('Delete', $hook->{region});
+                }
             } elsif (exists $hook->{refresh}) {
                 my $region = ref $hook->{refresh} ? $hook->{refresh} : Jifty->web->get_region($hook->{refresh});
-                warn "Can't find region ".$hook->{refresh} and next unless $region;
-                @args{qw/mode path region/} = ('Replace', $hook->{refresh}->path, $hook->{refresh});
-            } elsif ((exists $hook->{refresh_self} and Jifty->web->current_region) or $hook->{args}) {
+                if ($region) {
+                    @args{qw/mode path region/} = ('Replace', $region->path, $region->qualified_name);
+                } else {
+                    $self->log->debug("Can't find region ".$hook->{refresh});
+                    @args{qw/mode path region/} = ('Replace', undef, $hook->{refresh});
+                }
+            } elsif ((exists $hook->{refresh_self} and Jifty->web->current_region) or ($hook->{args} and %{$hook->{args}})) {
                 # If we just pass arguments, treat as a refresh_self
                 @args{qw/mode path region/} = ('Replace', Jifty->web->current_region->path, Jifty->web->current_region);
+            } elsif (exists $hook->{delete}) {
+                @args{qw/mode region/} = ('Delete', $hook->{delete});
             } else {
                 # If we're not doing any of the above, skip this one
                 next;

Modified: jifty/trunk/share/web/static/js/jifty.js
==============================================================================
--- jifty/trunk/share/web/static/js/jifty.js	(original)
+++ jifty/trunk/share/web/static/js/jifty.js	Thu Apr 20 21:49:44 2006
@@ -407,6 +407,14 @@
         if (element == null)
             continue;
 
+        // If we're removing the element, do it now
+        // XXX TODO: Effects on this?
+        if (f['mode'] == "Delete") {
+            fragments[name] = null;
+            Element.remove(element);
+            continue;
+        }
+
         f['is_new'] = (fragments[name] ? false : true);
         // If it's new, we need to create it so we can dump it
         if (f['is_new']) {
@@ -422,6 +430,9 @@
 
             // Make the region (for now)
             new Region(name, f['args'], f['path'], f['parent']);
+        } else if (f['path'] == null) {
+            // If they didn't know tha path, fill it in now
+            f['path'] == fragments[name].path;
         }
 
         // Update with all new values


More information about the Jifty-commit mailing list