[Jifty-commit] r3387 - in jifty/branches/fragcont: lib/Jifty
lib/Jifty/Plugin share/web/static/js
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Jun 7 16:06:36 EDT 2007
Author: clkao
Date: Thu Jun 7 16:06:34 2007
New Revision: 3387
Modified:
jifty/branches/fragcont/lib/Jifty/Continuation.pm
jifty/branches/fragcont/lib/Jifty/Plugin/SinglePage.pm
jifty/branches/fragcont/lib/Jifty/Web.pm
jifty/branches/fragcont/lib/Jifty/Web/Form/Clickable.pm
jifty/branches/fragcont/lib/Jifty/Web/Form/Element.pm
jifty/branches/fragcont/share/web/static/js/jifty.js
Log:
first cut of continuation serialization & calling with webservices.
Modified: jifty/branches/fragcont/lib/Jifty/Continuation.pm
==============================================================================
--- jifty/branches/fragcont/lib/Jifty/Continuation.pm (original)
+++ jifty/branches/fragcont/lib/Jifty/Continuation.pm Thu Jun 7 16:06:34 2007
@@ -156,6 +156,7 @@
sub call {
my $self = shift;
+ Jifty->log->debug("Redirect to @{[$self->request->path]} via continuation");
# If we needed to fix up the path (it contains invalid
# characters) then warn, because this may cause infinite
# redirects
Modified: jifty/branches/fragcont/lib/Jifty/Plugin/SinglePage.pm
==============================================================================
--- jifty/branches/fragcont/lib/Jifty/Plugin/SinglePage.pm (original)
+++ jifty/branches/fragcont/lib/Jifty/Plugin/SinglePage.pm Thu Jun 7 16:06:34 2007
@@ -19,14 +19,14 @@
my ( $clickable, $args ) = @_;
my $url = $args->{'url'};
if ( $url && $url !~ m/^#/ ) {
- delete $args->{'url'};
+ $args->{'_orig_url'} = delete $args->{'url'};
# XXX mind the existing onclick
warn 'ooops got original onclick' . Dumper( $args->{onclick} )
if $args->{onclick};
$args->{onclick} = {
region => $self->region_name,
replace_with => $url,
- args => delete $args->{parameters}
+ args => delete $args->{parameters},
};
}
elsif (exists $args->{submit}) {
Modified: jifty/branches/fragcont/lib/Jifty/Web.pm
==============================================================================
--- jifty/branches/fragcont/lib/Jifty/Web.pm (original)
+++ jifty/branches/fragcont/lib/Jifty/Web.pm Thu Jun 7 16:06:34 2007
@@ -329,6 +329,16 @@
push @valid_actions, $request_action;
}
+ if ($self->request->continuation_path && Jifty->web->request->argument('_webservice_redirect')) {
+ # for continuation - perform internal redirect under webservices
+ Jifty->web->request->add_fragment(
+ name => '__page',
+ path => $self->request->continuation_path,
+ arguments => {},
+ wrapper => 0
+ );
+ return;
+ }
$self->request->save_continuation;
unless ( $self->request->just_validating ) {
Modified: jifty/branches/fragcont/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/branches/fragcont/lib/Jifty/Web/Form/Clickable.pm (original)
+++ jifty/branches/fragcont/lib/Jifty/Web/Form/Clickable.pm Thu Jun 7 16:06:34 2007
@@ -26,10 +26,10 @@
sub accessors {
shift->SUPER::accessors,
- qw(url escape_label tooltip continuation call returns submit target preserve_state render_as_button render_as_link);
+ qw(url escape_label tooltip continuation call returns submit target preserve_state render_as_button render_as_link _orig_url);
}
__PACKAGE__->mk_accessors(
- qw(url escape_label tooltip continuation call returns submit target preserve_state render_as_button render_as_link)
+ qw(url escape_label tooltip continuation call returns submit target preserve_state render_as_button render_as_link _orig_url)
);
=head2 new PARAMHASH
@@ -455,11 +455,22 @@
escape_label => $self->escape_label,
url => $self->complete_url,
target => $self->target,
+ continuation => $self->_continuation,
@_ }
);
return $link;
}
+sub _continuation {
+ # continuation info used by the update() call on client side
+ my $self = shift;
+ if ($self->returns) {
+ return { 'create' => $self->_orig_url };
+ }
+
+ return {};
+}
+
=head2 as_button
Returns the clickable as a L<Jifty::Web::Form::Field::InlineButton>,
Modified: jifty/branches/fragcont/lib/Jifty/Web/Form/Element.pm
==============================================================================
--- jifty/branches/fragcont/lib/Jifty/Web/Form/Element.pm (original)
+++ jifty/branches/fragcont/lib/Jifty/Web/Form/Element.pm Thu Jun 7 16:06:34 2007
@@ -149,8 +149,8 @@
=cut
-sub accessors { shift->handlers, qw(class key_binding key_binding_label id label tooltip) }
-__PACKAGE__->mk_accessors(qw(_onclick class key_binding key_binding_label id label tooltip));
+sub accessors { shift->handlers, qw(class key_binding key_binding_label id label tooltip continuation) }
+__PACKAGE__->mk_accessors(qw(_onclick class key_binding key_binding_label id label tooltip continuation));
=head2 new PARAMHASH OVERRIDE
@@ -320,7 +320,7 @@
my $string = join ";", (grep {not ref $_} (ref $value eq "ARRAY" ? @{$value} : ($value)));
if (@fragments or (!$actions || %$actions)) {
- my $update = Jifty->web->escape("update( ". Jifty::JSON::objToJson( {actions => $actions, fragments => \@fragments }, {singlequote => 1}) .", this );");
+ my $update = Jifty->web->escape("update( ". Jifty::JSON::objToJson( {actions => $actions, fragments => \@fragments, continuation => $self->continuation }, {singlequote => 1}) .", this );");
$string .= $self->javascript_preempt ? "return $update" : "$update; return true;";
}
if ($confirm) {
Modified: jifty/branches/fragcont/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/fragcont/share/web/static/js/jifty.js (original)
+++ jifty/branches/fragcont/share/web/static/js/jifty.js Thu Jun 7 16:06:34 2007
@@ -719,7 +719,6 @@
// - 'mode' is one of 'Replace', or the name of a Prototype Insertion
// - 'effect' is the name of a Prototype Effect
function update() {
- // If we don't have XMLHttpRequest, bail and fallback on full-page
// loads
if(!Ajax.getTransport()) return true;
// XXX: prevent default behavior in IE
@@ -740,19 +739,21 @@
// Grab extra arguments (from a button)
var button_args = Form.Element.buttonFormElements(trigger);
+ var form = Form.Element.getForm(trigger);
// If the action is null, take all actions
if (named_args['actions'] == null) {
named_args['actions'] = {};
// default to disable fields
- var form = Form.Element.getForm(trigger);
if (form)
Form.getActions(form).map(function(x){
named_args['actions'][x.moniker] = 1;
});
}
+ var optional_fragments;
+ if (form && form['J:CALL'])
+ optional_fragments = [ prepare_element_for_update({'mode':'Replace','args':{},'region':'__page','path': null}) ];
// Build actions structure
request['actions'] = $H();
- var optional_fragments;
for (var moniker in named_args['actions']) {
var disable = named_args['actions'][moniker];
var a = new Action(moniker, button_args);
@@ -846,6 +847,9 @@
request['variables']['region-'+k] = current_args[k];
}
+ // Build continuation structure
+ request['continuation'] = named_args['continuation'];
+
// Push any state variables which we set into the forms
for (var i = 0; i < document.forms.length; i++) {
var form = document.forms[i];
More information about the Jifty-commit
mailing list