aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-03-11 02:17:31 +0000
committermatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-03-11 02:17:31 +0000
commit881dd5577887267d76437631ccd0f456d56f9d99 (patch)
treebbf9ddb4847b96cc22ce21b991e19875f379cb0d
parent6447c1ddad112023156da4243e9123b9877c839f (diff)
downloadreaction-881dd5577887267d76437631ccd0f456d56f9d99.tar.gz
reaction-881dd5577887267d76437631ccd0f456d56f9d99.zip
special exists event, force_events
-rw-r--r--lib/Reaction/UI/ViewPort.pm12
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm2
-rw-r--r--lib/Reaction/UI/Widget/Field/Mutable.pm7
-rw-r--r--share/skin/default/layout/field/mutable/boolean.tt5
4 files changed, 24 insertions, 2 deletions
diff --git a/lib/Reaction/UI/ViewPort.pm b/lib/Reaction/UI/ViewPort.pm
index 0e9cbb2..1c2b755 100644
--- a/lib/Reaction/UI/ViewPort.pm
+++ b/lib/Reaction/UI/ViewPort.pm
@@ -18,7 +18,7 @@ class ViewPort which {
has _tangent_stacks => (
isa => 'HashRef', is => 'ro', default => sub { {} }
);
- has ctx => (isa => 'Catalyst', is => 'ro', required => 1);
+ has ctx => (isa => 'Catalyst', is => 'ro'); #, required => 1);
implements _build_layout => as {
'';
@@ -90,13 +90,19 @@ class ViewPort which {
implements handle_events => as {
my ($self, $events) = @_;
+ my $exists = exists $events->{exists};
+ if ($exists) {
+ my %force = $self->force_events;
+ my @need = grep { !exists $events->{$_} } keys %force;
+ @{$events}{@need} = @force{@need};
+ }
foreach my $event ($self->accept_events) {
if (exists $events->{$event}) {
if (DEBUG_EVENTS) {
my $name = join(' at ', $self, $self->location);
$self->ctx->log->debug(
"Applying Event: $event on $name with value: "
- .$events->{$event}
+ .(defined $events->{$event} ? $events->{$event} : '<undef>')
);
}
$self->$event($events->{$event});
@@ -106,6 +112,8 @@ class ViewPort which {
implements accept_events => as { () };
+ implements force_events => as { () };
+
implements event_id_for => as {
my ($self, $name) = @_;
return join(':', $self->location, $name);
diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
index 66fa464..4244b31 100644
--- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
@@ -31,6 +31,8 @@ role Simple which {
around accept_events => sub { ('value_string', shift->(@_)) };
+ around force_events => sub { (value_string => '', shift->(@_)) };
+
};
1;
diff --git a/lib/Reaction/UI/Widget/Field/Mutable.pm b/lib/Reaction/UI/Widget/Field/Mutable.pm
index 98d7e9b..c4d2e44 100644
--- a/lib/Reaction/UI/Widget/Field/Mutable.pm
+++ b/lib/Reaction/UI/Widget/Field/Mutable.pm
@@ -8,6 +8,13 @@ class Mutable is 'Reaction::UI::Widget::Field', which {
arg 'field_id' => event_id 'value_string';
arg 'field_name' => event_id 'value_string' unless defined $_{field_name};
arg 'field_type' => 'text';
+
+ # these two are to fire force_events in viewports
+ # where you can end up without an event for e.g.
+ # HTML checkbox fields
+
+ arg 'exists_event' => event_id 'exists';
+ arg 'exists_value' => 1;
};
implements fragment message_fragment {
diff --git a/share/skin/default/layout/field/mutable/boolean.tt b/share/skin/default/layout/field/mutable/boolean.tt
index f50b377..6d70f36 100644
--- a/share/skin/default/layout/field/mutable/boolean.tt
+++ b/share/skin/default/layout/field/mutable/boolean.tt
@@ -1,5 +1,10 @@
=extends field/mutable
+=for layout widget
+
+<input name="[% exists_event %]" type="hidden" value="[% exists_value %]" />
+[% call_next %]
+
=for layout field_body
value="1" [% is_checked %]