use Reaction::UI::WidgetClass;
-class Index which {
+use namespace::clean -except => [ qw(meta) ];
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use aliased 'Reaction::UI::View';
use aliased 'Reaction::UI::LayoutSet';
-class Widget which {
-
- sub DEBUG_FRAGMENTS () { $ENV{REACTION_UI_WIDGET_DEBUG_FRAGMENTS} }
- sub DEBUG_LAYOUTS () { $ENV{REACTION_UI_WIDGET_DEBUG_LAYOUTS} }
-
- has 'view' => (isa => View, is => 'ro', required => 1);
- has 'layout_set' => (isa => LayoutSet, is => 'ro', required => 1);
- has 'fragment_names' => (is => 'ro', lazy_build => 1);
- has 'basic_layout_args' => (is => 'ro', lazy_build => 1);
-
- implements '_build_fragment_names' => as {
- my ($self) = shift;
- return [
- map { /^_fragment_(.*)/; $1; }
- grep { /^_fragment_/ }
- map { $_->{name} }
- $self->meta->compute_all_applicable_methods
- ];
- };
-
- implements 'render' => as {
- my ($self, $fragment_name, $rctx, $passed_args) = @_;
- confess "\$passed_args not hashref" unless ref($passed_args) eq 'HASH';
- if (DEBUG_FRAGMENTS) {
- my $vp = $passed_args->{viewport};
- $self->view->app->log->debug(
- "Rendering fragment ${fragment_name} for ".ref($self)
- ." for VP ${vp} at ".$vp->location
- );
- }
- my $args = { self => $self, %$passed_args };
- my $new_args = { %$args };
- my $render_tree = $self->_render_dispatch_order(
- $fragment_name, $args, $new_args
- );
- $rctx->dispatch($render_tree, $new_args);
- };
-
- implements '_method_for_fragment_name' => as {
- my ($self, $fragment_name) = @_;
- return $self->can("_fragment_${fragment_name}");
- };
-
- implements '_render_dispatch_order' => as {
- my ($self, $fragment_name, $args, $new_args) = @_;
-
- my @render_stack = (my $render_deep = (my $render_curr = []));
- my @layout_order = $self->layout_set->widget_order_for($fragment_name);
-
- if (my $f_meth = $self->_method_for_fragment_name($fragment_name)) {
- my @wclass_stack;
- my $do_render = sub {
- my $package = shift;
- if (@layout_order) {
- while ($package eq $layout_order[0][0]
- || $layout_order[0][0]->isa($package)) {
- my $new_curr = [];
- my @l = @{shift(@layout_order)};
- if (DEBUG_LAYOUTS) {
- $self->view->app->log->debug(
- "Layout ${fragment_name} in ${\$l[1]->name} from ${\$l[1]->source_file}"
- );
- }
- push(@$render_curr, [ -layout, $l[1], $fragment_name, $new_curr ]);
- push(@render_stack, $new_curr);
- push(@wclass_stack, $l[0]);
- $render_deep = $render_curr = $new_curr;
- last unless @layout_order;
- }
- }
- if (@wclass_stack) {
- while ($package ne $wclass_stack[-1]
- && $package->isa($wclass_stack[-1])) {
- pop(@wclass_stack);
- $render_curr = pop(@render_stack);
+use namespace::clean -except => [ qw(meta) ];
+
+
+sub DEBUG_FRAGMENTS () { $ENV{REACTION_UI_WIDGET_DEBUG_FRAGMENTS} }
+sub DEBUG_LAYOUTS () { $ENV{REACTION_UI_WIDGET_DEBUG_LAYOUTS} }
+
+has 'view' => (isa => View, is => 'ro', required => 1);
+has 'layout_set' => (isa => LayoutSet, is => 'ro', required => 1);
+has 'fragment_names' => (is => 'ro', lazy_build => 1);
+has 'basic_layout_args' => (is => 'ro', lazy_build => 1);
+sub _build_fragment_names {
+ my ($self) = shift;
+ return [
+ map { /^_fragment_(.*)/; $1; }
+ grep { /^_fragment_/ }
+ map { $_->{name} }
+ $self->meta->compute_all_applicable_methods
+ ];
+};
+sub render {
+ my ($self, $fragment_name, $rctx, $passed_args) = @_;
+ confess "\$passed_args not hashref" unless ref($passed_args) eq 'HASH';
+ if (DEBUG_FRAGMENTS) {
+ my $vp = $passed_args->{viewport};
+ $self->view->app->log->debug(
+ "Rendering fragment ${fragment_name} for ".ref($self)
+ ." for VP ${vp} at ".$vp->location
+ );
+ }
+ my $args = { self => $self, %$passed_args };
+ my $new_args = { %$args };
+ my $render_tree = $self->_render_dispatch_order(
+ $fragment_name, $args, $new_args
+ );
+ $rctx->dispatch($render_tree, $new_args);
+};
+sub _method_for_fragment_name {
+ my ($self, $fragment_name) = @_;
+ return $self->can("_fragment_${fragment_name}");
+};
+sub _render_dispatch_order {
+ my ($self, $fragment_name, $args, $new_args) = @_;
+
+ my @render_stack = (my $render_deep = (my $render_curr = []));
+ my @layout_order = $self->layout_set->widget_order_for($fragment_name);
+
+ if (my $f_meth = $self->_method_for_fragment_name($fragment_name)) {
+ my @wclass_stack;
+ my $do_render = sub {
+ my $package = shift;
+ if (@layout_order) {
+ while ($package eq $layout_order[0][0]
+ || $layout_order[0][0]->isa($package)) {
+ my $new_curr = [];
+ my @l = @{shift(@layout_order)};
+ if (DEBUG_LAYOUTS) {
+ $self->view->app->log->debug(
+ "Layout ${fragment_name} in ${\$l[1]->name} from ${\$l[1]->source_file}"
+ );
}
+ push(@$render_curr, [ -layout, $l[1], $fragment_name, $new_curr ]);
+ push(@render_stack, $new_curr);
+ push(@wclass_stack, $l[0]);
+ $render_deep = $render_curr = $new_curr;
+ last unless @layout_order;
}
- push(@{$render_curr}, [ -render, @_ ]);
- };
- $self->$f_meth($do_render, $args, $new_args);
- }
- # if we had no fragment method or if we still have layouts left
- if (@layout_order) {
- while (my $l = shift(@layout_order)) {
- if (DEBUG_LAYOUTS) {
- $self->view->app->log->debug(
- "Layout ${fragment_name} in ${\$l->[1]->name} from ${\$l->[1]->source_file}"
- );
+ }
+ if (@wclass_stack) {
+ while ($package ne $wclass_stack[-1]
+ && $package->isa($wclass_stack[-1])) {
+ pop(@wclass_stack);
+ $render_curr = pop(@render_stack);
}
- push(@$render_deep, [
- -layout => $l->[1], $fragment_name, ($render_deep = [])
- ]);
}
+ push(@{$render_curr}, [ '-render', @_ ]);
+ };
+ $self->$f_meth($do_render, $args, $new_args);
+ }
+ # if we had no fragment method or if we still have layouts left
+ if (@layout_order) {
+ while (my $l = shift(@layout_order)) {
+ if (DEBUG_LAYOUTS) {
+ $self->view->app->log->debug(
+ "Layout ${fragment_name} in ${\$l->[1]->name} from ${\$l->[1]->source_file}"
+ );
+ }
+ push(@$render_deep, [
+ -layout => $l->[1], $fragment_name, ($render_deep = [])
+ ]);
}
+ }
- return $render_stack[0];
- };
-
- implements '_build_basic_layout_args' => as {
- my ($self) = @_;
- my $args;
- foreach my $name (@{$self->fragment_names},
- @{$self->layout_set->layout_names}) {
- $args->{$name} ||= sub { $self->render($name, @_); };
- }
- return $args;
- };
-
- implements '_fragment_viewport' => as {
- my ($self, $do_render, $args, $new_args) = @_;
- my $vp = $args->{'_'};
- my ($widget, $merge_args) = $self->view->render_viewport_args($vp);
- $merge_args->{outer} = { %$new_args };
- delete @{$new_args}{keys %$new_args}; # fresh start
- @{$new_args}{keys %$merge_args} = values %$merge_args;
- $do_render->(Widget, $widget, 'widget');
- };
-
- implements '_fragment_widget' => as {
- my ($self, $do_render, $args, $new_args) = @_;
- my $merge = $self->basic_layout_args;
+ return $render_stack[0];
+};
+sub _build_basic_layout_args {
+ my ($self) = @_;
+ my $args;
+ foreach my $name (@{$self->fragment_names},
+ @{$self->layout_set->layout_names}) {
+ $args->{$name} ||= sub { $self->render($name, @_); };
+ }
+ return $args;
+};
+sub _fragment_viewport {
+ my ($self, $do_render, $args, $new_args) = @_;
+ my $vp = $args->{'_'};
+ my ($widget, $merge_args) = $self->view->render_viewport_args($vp);
+ $merge_args->{outer} = { %$new_args };
+ delete @{$new_args}{keys %$new_args}; # fresh start
+ @{$new_args}{keys %$merge_args} = values %$merge_args;
+ $do_render->(Widget, $widget, 'widget');
+};
+sub _fragment_widget {
+ my ($self, $do_render, $args, $new_args) = @_;
+ my $merge = $self->basic_layout_args;
#warn "Merge: ".join(', ', keys %$merge)." into: ".join(', ', keys %$new_args);
- delete @{$merge}{keys %$new_args}; # nuke 'self' and 'viewport'
- @{$new_args}{keys %$merge} = values %$merge;
- };
-
+ delete @{$merge}{keys %$new_args}; # nuke 'self' and 'viewport'
+ @{$new_args}{keys %$merge} = values %$merge;
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
=head1 NAME
use Reaction::UI::WidgetClass;
-class Action is 'Reaction::UI::Widget::Object', which {
-
- after fragment widget {
- arg 'method' => $_{viewport}->method;
- };
-
- implements fragment ok_button_fragment {
- if (grep { $_ eq 'ok' } $_{viewport}->accept_events) {
- arg 'event_id' => event_id 'ok';
- arg 'label' => $_{viewport}->ok_label;
- render 'ok_button';
- }
- };
-
- implements fragment apply_button_fragment {
- if (grep { $_ eq 'apply' } $_{viewport}->accept_events) {
- arg 'event_id' => event_id 'apply';
- arg 'label' => $_{viewport}->apply_label;
- render 'apply_button';
- }
- };
-
- implements fragment cancel_button_fragment {
- if (grep { $_ eq 'close' } $_{viewport}->accept_events) {
- arg 'event_id' => event_id 'close';
- arg 'label' => $_{viewport}->close_label;
- render 'cancel_button';
- }
- };
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Object';
+
+
+after fragment widget {
+ arg 'method' => $_{viewport}->method;
+};
+
+implements fragment ok_button_fragment {
+ if (grep { $_ eq 'ok' } $_{viewport}->accept_events) {
+ arg 'event_id' => event_id 'ok';
+ arg 'label' => $_{viewport}->ok_label;
+ render 'ok_button';
+ }
+};
+
+implements fragment apply_button_fragment {
+ if (grep { $_ eq 'apply' } $_{viewport}->accept_events) {
+ arg 'event_id' => event_id 'apply';
+ arg 'label' => $_{viewport}->apply_label;
+ render 'apply_button';
+ }
+};
+
+implements fragment cancel_button_fragment {
+ if (grep { $_ eq 'close' } $_{viewport}->accept_events) {
+ arg 'event_id' => event_id 'close';
+ arg 'label' => $_{viewport}->close_label;
+ render 'cancel_button';
+ }
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
#I want to change this at some point.
-class Link, which {
+use namespace::clean -except => [ qw(meta) ];
- before fragment widget {
- arg uri => $_{viewport}->uri;
- arg label => $_{viewport}->label;
- };
+before fragment widget {
+ arg uri => $_{viewport}->uri;
+ arg label => $_{viewport}->label;
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class Collection, which {
+use namespace::clean -except => [ qw(meta) ];
- implements fragment members {
- render member => over $_{viewport}->members;
- };
- implements fragment member {
- render 'viewport';
- };
+implements fragment members {
+ render member => over $_{viewport}->members;
+};
+implements fragment member {
+ render 'viewport';
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class Grid is 'Reaction::UI::Widget::Collection', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Collection';
- implements fragment header_cells {
- arg 'labels' => $_{viewport}->field_labels;
- render header_cell => over $_{viewport}->computed_field_order;
- };
- implements fragment header_cell {
- arg label => $_{labels}->{$_};
- };
+implements fragment header_cells {
+ arg 'labels' => $_{viewport}->field_labels;
+ render header_cell => over $_{viewport}->computed_field_order;
};
+implements fragment header_cell {
+ arg label => $_{labels}->{$_};
+};
+
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class Member is 'Reaction::UI::Widget::Object', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Object';
-};
+
+
+__PACKAGE__->meta->make_immutable;
+
1;
use Reaction::UI::WidgetClass;
-class WithActions, is 'Reaction::UI::Widget::Collection::Grid::Member', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Collection::Grid::Member';
- implements fragment actions {
- render action => over $_{viewport}->actions;
- };
- implements fragment action {
- render 'viewport';
- };
+implements fragment actions {
+ render action => over $_{viewport}->actions;
};
+implements fragment action {
+ render 'viewport';
+};
+
+__PACKAGE__->meta->make_immutable;
+
+
1;
use aliased 'Reaction::UI::ViewPort';
-class Container which {
-
- our $child_name;
-
- # somewhat evil. fragment returns ($name, $code) to pass to implements
- # or a method modifier name, so [1] will get us just the code
-
- # This is convenient to do here but DO NOT duplicate this code outside of
- # the same dist as WidgetClass since it's internals-dependent.
-
- my $child_fragment_method
- = (fragment container_child {
- arg '_' => $_{viewport}->$child_name;
- render 'viewport';
- })[1];
-
- around _method_for_fragment_name => sub {
- my $orig = shift;
- my $self = shift;
- my ($fragment_name) = @_;
- if (defined($child_name)
- && $fragment_name eq $child_name) {
- return $self->$orig(@_) || $child_fragment_method;
- }
- return $self->$orig(@_);
- };
-
- before _fragment_widget => sub {
- my ($self, $do_render, $args, $new_args) = @_;
- my @contained_names = $self->_contained_names($args->{viewport});
- foreach my $name (@contained_names) {
- $new_args->{$name} ||= sub {
- local $child_name = $name;
- $self->render($name, @_);
- };
- }
- };
-
- implements _contained_names => sub {
- my ($self, $vp) = @_;
- my @names;
- foreach my $attr ($vp->meta->compute_all_applicable_attributes) {
- next unless eval { $attr->type_constraint->name->isa(ViewPort) };
- my $name = $attr->name;
- next if ($name eq 'outer');
- push(@names, $name);
- }
- return @names;
- };
+use namespace::clean -except => [ qw(meta) ];
+
+our $child_name;
+
+# somewhat evil. fragment returns ($name, $code) to pass to implements
+# or a method modifier name, so [1] will get us just the code
+
+# This is convenient to do here but DO NOT duplicate this code outside of
+# the same dist as WidgetClass since it's internals-dependent.
+
+my $child_fragment_method
+ = (fragment container_child {
+ arg '_' => $_{viewport}->$child_name;
+ render 'viewport';
+ })[1];
+
+around _method_for_fragment_name => sub {
+ my $orig = shift;
+ my $self = shift;
+ my ($fragment_name) = @_;
+ if (defined($child_name)
+ && $fragment_name eq $child_name) {
+ return $self->$orig(@_) || $child_fragment_method;
+ }
+ return $self->$orig(@_);
};
+
+before _fragment_widget => sub {
+ my ($self, $do_render, $args, $new_args) = @_;
+ my @contained_names = $self->_contained_names($args->{viewport});
+ foreach my $name (@contained_names) {
+ $new_args->{$name} ||= sub {
+ local $child_name = $name;
+ $self->render($name, @_);
+ };
+ }
+};
+
+implements _contained_names => sub {
+ my ($self, $vp) = @_;
+ my @names;
+ foreach my $attr ($vp->meta->compute_all_applicable_attributes) {
+ next unless eval { $attr->type_constraint->name->isa(ViewPort) };
+ my $name = $attr->name;
+ next if ($name eq 'outer');
+ push(@names, $name);
+ }
+ return @names;
+};
+
+__PACKAGE__->meta->make_immutable;
+
1;
use Reaction::UI::WidgetClass;
-class Field, which {
-
- before fragment widget {
- if ($_{viewport}->can('value_string')) {
- arg 'field_value' => $_{viewport}->value_string;
- } else {
- arg 'field_value' => ''; #$_{viewport}->value;
- }
- };
-
- implements fragment label_fragment {
- if (my $label = $_{viewport}->label) {
- arg label => $label;
- render 'label';
- }
- };
+use namespace::clean -except => [ qw(meta) ];
+
+before fragment widget {
+ if ($_{viewport}->can('value_string')) {
+ arg 'field_value' => $_{viewport}->value_string;
+ } else {
+ arg 'field_value' => ''; #$_{viewport}->value;
+ }
+};
+
+implements fragment label_fragment {
+ if (my $label = $_{viewport}->label) {
+ arg label => $label;
+ render 'label';
+ }
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class Array, which {
+use namespace::clean -except => [ qw(meta) ];
- before fragment widget {
- arg 'label' => $_{viewport}->label;
- };
- implements fragment list {
- render 'item' => over $_{viewport}->value_names;
- };
+before fragment widget {
+ arg 'label' => $_{viewport}->label;
+};
- implements fragment item {
- arg 'name' => $_;
- };
+implements fragment list {
+ render 'item' => over $_{viewport}->value_names;
+};
+implements fragment item {
+ arg 'name' => $_;
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class Boolean is 'Reaction::UI::Widget::Field', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class Collection, which {
+use namespace::clean -except => [ qw(meta) ];
- before fragment widget {
- arg 'label' => $_{viewport}->label;
- };
- implements fragment list {
- render 'item' => over $_{viewport}->value_names;
- };
+before fragment widget {
+ arg 'label' => $_{viewport}->label;
+};
- implements fragment item {
- arg 'name' => $_;
- };
+implements fragment list {
+ render 'item' => over $_{viewport}->value_names;
+};
+implements fragment item {
+ arg 'name' => $_;
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class DateTime is 'Reaction::UI::Widget::Field', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class Image is 'Reaction::UI::Widget::Field', which {
-
- implements fragment image {
- if($_{viewport}->value_string) {
- arg uri => $_{viewport}->uri;
- render 'has_image';
- } else {
- render 'no_image';
- }
- };
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field';
+
+
+implements fragment image {
+ if($_{viewport}->value_string) {
+ arg uri => $_{viewport}->uri;
+ render 'has_image';
+ } else {
+ render 'no_image';
+ }
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
use Reaction::UI::WidgetClass;
-class Integer is 'Reaction::UI::Widget::Field', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class Mutable is 'Reaction::UI::Widget::Field', which {
-
- before fragment widget {
- arg 'field_id' => event_id 'value_string';
- arg 'field_name' => event_id 'value_string' unless defined $_{field_name};
- arg 'field_type' => 'text';
- arg 'field_class' => "action-field " . $_{viewport}->name;
-
- # 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 {
- if (my $message = $_{viewport}->message) {
- arg message => $message;
- render 'message';
- }
- };
-
- implements fragment field_is_required {
- my $model = $_{viewport}->model;
- my $attr = $_{viewport}->attribute;
- if ( $model->attribute_is_required($attr) ) {
- render 'field_is_required_yes';
- } else {
- render 'field_is_required_no';
- }
- };
-
-};
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field';
+
+
+
+ before fragment widget {
+ arg 'field_id' => event_id 'value_string';
+ arg 'field_name' => event_id 'value_string' unless defined $_{field_name};
+ arg 'field_type' => 'text';
+ arg 'field_class' => "action-field " . $_{viewport}->name;
+
+ # 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 {
+ if (my $message = $_{viewport}->message) {
+ arg message => $message;
+ render 'message';
+ }
+ };
+
+ implements fragment field_is_required {
+ my $model = $_{viewport}->model;
+ my $attr = $_{viewport}->attribute;
+ if ( $model->attribute_is_required($attr) ) {
+ render 'field_is_required_yes';
+ } else {
+ render 'field_is_required_no';
+ }
+ };
+
+__PACKAGE__->meta->make_immutable;
+
1;
use Reaction::UI::WidgetClass;
-class Boolean is 'Reaction::UI::Widget::Field::Mutable', which {
-
- after fragment widget {
- arg 'field_type' => 'checkbox';
- };
-
- implements fragment is_checked {
- if ($_{viewport}->value_string) {
- render 'is_checked_yes';
- } else {
- render 'is_checked_no';
- }
- };
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
+
+
+after fragment widget {
+ arg 'field_type' => 'checkbox';
+};
+
+implements fragment is_checked {
+ if ($_{viewport}->value_string) {
+ render 'is_checked_yes';
+ } else {
+ render 'is_checked_no';
+ }
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class ChooseMany is 'Reaction::UI::Widget::Field::Mutable', which {
-
- implements fragment action_buttons {
- foreach my $event (
- qw(add_all_values do_add_values do_remove_values remove_all_values)
- ) {
- arg "event_id_${event}" => event_id $event;
- }
- };
-
- implements fragment current_values {
- my $current_choices = $_{viewport}->current_value_choices;
- if( @$current_choices ){
- arg field_name => event_id 'value';
- render hidden_value => over $current_choices;
- } else {
- arg field_name => event_id 'no_current_value';
- arg '_' => {value => 1};
- render 'hidden_value';
- }
- };
-
- implements fragment selected_values {
- arg event_id_remove_values => event_id 'remove_values';
- render value_option => over $_{viewport}->current_value_choices;
- };
-
- implements fragment available_values {
- arg event_id_add_values => event_id 'add_values';
- render value_option => over $_{viewport}->available_value_choices;
- };
-
- implements fragment value_option {
- arg option_name => $_->{name};
- arg option_value => $_->{value};
- };
-
- implements fragment hidden_value {
- arg hidden_value => $_->{value};
- };
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
+
+
+implements fragment action_buttons {
+ foreach my $event (
+ qw(add_all_values do_add_values do_remove_values remove_all_values)
+ ) {
+ arg "event_id_${event}" => event_id $event;
+ }
+};
+
+implements fragment current_values {
+ my $current_choices = $_{viewport}->current_value_choices;
+ if( @$current_choices ){
+ arg field_name => event_id 'value';
+ render hidden_value => over $current_choices;
+ } else {
+ arg field_name => event_id 'no_current_value';
+ arg '_' => {value => 1};
+ render 'hidden_value';
+ }
+};
+
+implements fragment selected_values {
+ arg event_id_remove_values => event_id 'remove_values';
+ render value_option => over $_{viewport}->current_value_choices;
+};
+
+implements fragment available_values {
+ arg event_id_add_values => event_id 'add_values';
+ render value_option => over $_{viewport}->available_value_choices;
+};
+
+implements fragment value_option {
+ arg option_name => $_->{name};
+ arg option_value => $_->{value};
};
+implements fragment hidden_value {
+ arg hidden_value => $_->{value};
+};
+
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class ChooseOne is 'Reaction::UI::Widget::Field::Mutable', which {
-
- implements fragment option_is_required {
- if ($_{viewport}->value_is_required) {
- render 'option_is_required_yes';
- } else {
- render 'option_is_required_no';
- }
- };
-
- implements fragment option_list {
- render option => over $_{viewport}->value_choices;
- };
-
- implements fragment option {
- arg option_name => $_->{name};
- arg option_value => $_->{value};
- };
-
- implements fragment option_is_selected {
- if ($_{viewport}->is_current_value($_->{value})) {
- render 'option_is_selected_yes';
- } else {
- render 'option_is_selected_no';
- }
- };
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
+
+
+implements fragment option_is_required {
+ if ($_{viewport}->value_is_required) {
+ render 'option_is_required_yes';
+ } else {
+ render 'option_is_required_no';
+ }
+};
+
+implements fragment option_list {
+ render option => over $_{viewport}->value_choices;
+};
+
+implements fragment option {
+ arg option_name => $_->{name};
+ arg option_value => $_->{value};
+};
+
+implements fragment option_is_selected {
+ if ($_{viewport}->is_current_value($_->{value})) {
+ render 'option_is_selected_yes';
+ } else {
+ render 'option_is_selected_no';
+ }
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class DateTime is 'Reaction::UI::Widget::Field::Mutable', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
- after fragment widget {
- arg 'field_name' => event_id 'value_string';
- };
-};
+
+after fragment widget {
+ arg 'field_name' => event_id 'value_string';
+ };
+
+__PACKAGE__->meta->make_immutable;
+
1;
use Reaction::UI::WidgetClass;
-class File is 'Reaction::UI::Widget::Field::Mutable', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
- after fragment widget {
- arg field_type => 'file';
- };
+
+after fragment widget {
+ arg field_type => 'file';
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
#move this to a normal list and let the hidden part be decided by the template..
-class HiddenArray is 'Reaction::UI::Widget::Field::Mutable', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
- implements fragment hidden_list {
- render hidden_field => over $_{viewport}->value;
- };
- implements fragment hidden_field {
- arg field_value => $_;
- };
+implements fragment hidden_list {
+ render hidden_field => over $_{viewport}->value;
};
+implements fragment hidden_field {
+ arg field_value => $_;
+};
+
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class Integer is 'Reaction::UI::Widget::Field::Mutable', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
use aliased 'Reaction::UI::Widget::Field::Mutable::Password';
-class MatchingPasswords is Password, which {
+use namespace::clean -except => [ qw(meta) ];
+extends Password;
- implements fragment check_field {
- arg 'field_id' => event_id 'check_value';
- arg 'field_name' => event_id 'check_value';
- arg 'label' => 'Confirm:';
- render 'field'; #piggyback!
- };
- implements fragment check_label {
- if (my $label = $_{viewport}->check_label) {
- arg label => $label;
- render 'label';
- }
- };
+implements fragment check_field {
+ arg 'field_id' => event_id 'check_value';
+ arg 'field_name' => event_id 'check_value';
+ arg 'label' => 'Confirm:';
+ render 'field'; #piggyback!
+};
+implements fragment check_label {
+ if (my $label = $_{viewport}->check_label) {
+ arg label => $label;
+ render 'label';
+ }
};
+
+__PACKAGE__->meta->make_immutable;
+
+
1;
use Reaction::UI::WidgetClass;
-class Number is 'Reaction::UI::Widget::Field::Mutable', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class Password is 'Reaction::UI::Widget::Field::Mutable', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
- around fragment widget {
- call_next;
- arg field_type => 'password';
- arg field_value => ''; # no sending password to user. really.
- };
+
+around fragment widget {
+ call_next;
+ arg field_type => 'password';
+ arg field_value => ''; # no sending password to user. really.
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class String is 'Reaction::UI::Widget::Field::Mutable', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class Text is 'Reaction::UI::Widget::Field::Mutable', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class TimeRange is 'Reaction::UI::Widget::Field::Mutable', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field::Mutable';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class Number is 'Reaction::UI::Widget::Field', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class RelatedObject is 'Reaction::UI::Widget::Field', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class String is 'Reaction::UI::Widget::Field', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class Text is 'Reaction::UI::Widget::Field', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Field';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class ListView is 'Reaction::UI::Widget::Collection::Grid', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Collection::Grid';
- after fragment widget {
- arg pager_obj => $_{viewport}->pager;
- };
- implements fragment pager_fragment {
- my $pager = $_{pager_obj};
- if( $pager->last_page > $pager->first_page ) {
- render 'pager';
- }
- };
- implements fragment actions {
- render action => over $_{viewport}->actions;
- };
+after fragment widget {
+ arg pager_obj => $_{viewport}->pager;
+};
- implements fragment action {
- render 'viewport';
- };
+implements fragment pager_fragment {
+ my $pager = $_{pager_obj};
+ if( $pager->last_page > $pager->first_page ) {
+ render 'pager';
+ }
+};
- after fragment header_cells {
- if ($_{viewport}->object_action_count) {
- render 'header_action_cell';
- }
- };
+implements fragment actions {
+ render action => over $_{viewport}->actions;
+};
- around fragment header_cell {
- arg order_uri => event_uri {
- order_by => $_,
- order_by_desc => ((($_{viewport}->order_by||'') ne $_
- || $_{viewport}->order_by_desc) ? 0 : 1)
- };
- call_next;
- };
+implements fragment action {
+ render 'viewport';
+};
- implements fragment header_action_cell {
- arg col_count => $_{viewport}->object_action_count;
- };
+after fragment header_cells {
+ if ($_{viewport}->object_action_count) {
+ render 'header_action_cell';
+ }
+};
- implements fragment page_list {
- render numbered_page_fragment
- => over [ $_{pager_obj}->first_page .. $_{pager_obj}->last_page ];
+around fragment header_cell {
+ arg order_uri => event_uri {
+ order_by => $_,
+ order_by_desc => ((($_{viewport}->order_by||'') ne $_
+ || $_{viewport}->order_by_desc) ? 0 : 1)
};
+ call_next;
+};
- implements fragment numbered_page_fragment {
- arg page_uri => event_uri { page => $_ };
- arg page_number => $_;
- if ($_{pager_obj}->current_page == $_) {
- render 'numbered_page_this_page';
- } else {
- render 'numbered_page';
- }
- };
+implements fragment header_action_cell {
+ arg col_count => $_{viewport}->object_action_count;
+};
- implements fragment first_page {
- arg page_uri => event_uri { page => $_{pager_obj}->first_page };
- arg page_name => 'First';
- render 'named_page';
- };
+implements fragment page_list {
+ render numbered_page_fragment
+ => over [ $_{pager_obj}->first_page .. $_{pager_obj}->last_page ];
+};
- implements fragment last_page {
- arg page_uri => event_uri { page => $_{pager_obj}->last_page };
- arg page_name => 'Last';
- render 'named_page';
- };
+implements fragment numbered_page_fragment {
+ arg page_uri => event_uri { page => $_ };
+ arg page_number => $_;
+ if ($_{pager_obj}->current_page == $_) {
+ render 'numbered_page_this_page';
+ } else {
+ render 'numbered_page';
+ }
+};
- implements fragment next_page {
- arg page_name => 'Next';
- if (my $page = $_{pager_obj}->next_page) {
- arg page_uri => event_uri { page => $page };
- render 'named_page';
- } else {
- render 'named_page_no_page';
- }
- };
+implements fragment first_page {
+ arg page_uri => event_uri { page => $_{pager_obj}->first_page };
+ arg page_name => 'First';
+ render 'named_page';
+};
- implements fragment previous_page {
- arg page_name => 'Previous';
- if (my $page = $_{pager_obj}->previous_page) {
- arg page_uri => event_uri { page => $page };
- render 'named_page';
- } else {
- render 'named_page_no_page';
- }
- };
+implements fragment last_page {
+ arg page_uri => event_uri { page => $_{pager_obj}->last_page };
+ arg page_name => 'Last';
+ render 'named_page';
+};
+implements fragment next_page {
+ arg page_name => 'Next';
+ if (my $page = $_{pager_obj}->next_page) {
+ arg page_uri => event_uri { page => $page };
+ render 'named_page';
+ } else {
+ render 'named_page_no_page';
+ }
};
+implements fragment previous_page {
+ arg page_name => 'Previous';
+ if (my $page = $_{pager_obj}->previous_page) {
+ arg page_uri => event_uri { page => $page };
+ render 'named_page';
+ } else {
+ render 'named_page_no_page';
+ }
+};
+
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class Object, which {
+use namespace::clean -except => [ qw(meta) ];
- implements fragment field_list {
- render field => over $_{viewport}->fields;
- };
- implements fragment field {
- render 'viewport';
- };
+implements fragment field_list {
+ render field => over $_{viewport}->fields;
+};
+implements fragment field {
+ render 'viewport';
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use aliased 'Reaction::UI::Widget::Container';
use MooseX::Types::Moose 'HashRef';
-class SiteLayout is Container, which {
-
- has 'http_header' => (
- isa => HashRef, is => 'rw',
- default => sub { {} }
- );
-
- after fragment widget {
- arg static_base => $_{viewport}->static_base_uri;
- arg title => $_{viewport}->title;
- };
-
- implements fragment meta_info {
- my $self = shift;
- if ( $_{viewport}->meta_info->{'http_header'} ) {
- $self->http_header( delete $_{viewport}->meta_info->{'http_header'} );
- render 'meta_http_header' => over [keys %{$self->http_header}];
- }
- render 'meta_member' => over [keys %{$_{viewport}->meta_info}];
- };
-
- implements fragment meta_http_header {
- arg 'meta_name' => $_;
- arg 'meta_value' => shift->http_header->{$_};
- };
-
- implements fragment meta_member {
- arg 'meta_name' => $_;
- arg 'meta_value' => $_{viewport}->meta_info->{$_};
- };
+use namespace::clean -except => [ qw(meta) ];
+extends Container;
+
+
+has 'http_header' => (
+ isa => HashRef, is => 'rw',
+ default => sub { {} }
+);
+
+after fragment widget {
+ arg static_base => $_{viewport}->static_base_uri;
+ arg title => $_{viewport}->title;
};
+implements fragment meta_info {
+ my $self = shift;
+ if ( $_{viewport}->meta_info->{'http_header'} ) {
+ $self->http_header( delete $_{viewport}->meta_info->{'http_header'} );
+ render 'meta_http_header' => over [keys %{$self->http_header}];
+ }
+ render 'meta_member' => over [keys %{$_{viewport}->meta_info}];
+};
+
+implements fragment meta_http_header {
+ arg 'meta_name' => $_;
+ arg 'meta_value' => shift->http_header->{$_};
+};
+
+implements fragment meta_member {
+ arg 'meta_name' => $_;
+ arg 'meta_value' => $_{viewport}->meta_info->{$_};
+};
+
+__PACKAGE__->meta->make_immutable;
+
+
1;
use Reaction::UI::WidgetClass;
-class Value, which {
+use namespace::clean -except => [ qw(meta) ];
- before fragment widget {
- if ($_{viewport}->can('value_string')) {
- arg value => $_{viewport}->value_string;
- } elsif($_{viewport}->can('value')) {
- arg value => $_{viewport}->value;
- }
- };
+before fragment widget {
+ if ($_{viewport}->can('value_string')) {
+ arg value => $_{viewport}->value_string;
+ } elsif($_{viewport}->can('value')) {
+ arg value => $_{viewport}->value;
+ }
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class Boolean is 'Reaction::UI::Widget::Value', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Value';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class Collection, which {
+use namespace::clean -except => [ qw(meta) ];
- before fragment widget {
- arg 'label' => $_{viewport}->label;
- };
- implements fragment list {
- render 'item' => over $_{viewport}->value_names;
- };
+before fragment widget {
+ arg 'label' => $_{viewport}->label;
+};
- implements fragment item {
- arg 'name' => $_;
- };
+implements fragment list {
+ render 'item' => over $_{viewport}->value_names;
+};
+implements fragment item {
+ arg 'name' => $_;
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
__END__;
use Reaction::UI::WidgetClass;
-class DateTime is 'Reaction::UI::Widget::Value', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Value';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class Image, which {
+use namespace::clean -except => [ qw(meta) ];
- implements fragment image {
- if($_{viewport}->value_string) {
- arg uri => $_{viewport}->uri;
- render 'has_image';
- } else {
- render 'no_image';
- }
- };
+implements fragment image {
+ if($_{viewport}->value_string) {
+ arg uri => $_{viewport}->uri;
+ render 'has_image';
+ } else {
+ render 'no_image';
+ }
};
+__PACKAGE__->meta->make_immutable;
+
+
1;
use Reaction::UI::WidgetClass;
-class Number is 'Reaction::UI::Widget::Value', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Value';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class RelatedObject is 'Reaction::UI::Widget::Value', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Value';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class String is 'Reaction::UI::Widget::Value', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Value';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;
use Reaction::UI::WidgetClass;
-class Text is 'Reaction::UI::Widget::Value', which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::Widget::Value';
+
+
+
+__PACKAGE__->meta->make_immutable;
-};
1;