my ($self, $events) = @_;
foreach my $event ($self->accept_events) {
if (exists $events->{$event}) {
- # $self->ctx->log->debug("Applying Event: $event with value: ". $events->{$event});
+ #my $name = eval{$self->name};
+ #$self->ctx->log->debug("Applying Event: $event on $name with value: ". $events->{$event});
$self->$event($events->{$event});
}
}
class Grid is 'Reaction::UI::ViewPort::Collection', which {
- has field_order => ( isa => 'ArrayRef', is => 'ro', lazy_build => 1);
- has field_labels => ( isa => 'HashRef', is => 'ro', lazy_build => 1);
+ has field_order => ( is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+ has excluded_fields => ( is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+ has field_labels => ( is => 'ro', isa => 'HashRef', lazy_build => 1);
- has ordered_fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
- has excluded_fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+ has computed_field_order => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
####################################
implements _build_member_class => as { };
implements _build_field_order => as { []; };
implements _build_excluded_fields => as { []; };
- implements _build_ordered_fields => as {
+ implements _build_computed_field_order => as {
my ($self) = @_;
confess("current_collection lacks a value for 'member_type' attribute")
unless $self->current_collection->has_member_type;
before _build_members => sub {
my ($self) = @_;
- $self->member_args->{ordered_fields} ||= $self->ordered_fields;
+ $self->member_args->{computed_field_order} ||= $self->computed_field_order;
};
};
class ChooseMany is 'Reaction::UI::ViewPort::Field', which {
- has '+value' => (isa => 'ArrayRef');
-
does 'Reaction::UI::ViewPort::Field::Role::Mutable';
does 'Reaction::UI::ViewPort::Field::Role::Choices';
+ #MUST BE HERE, BELOW THE 'does', OR THE TRIGGER WILL NOT HAPPEN!
+ has '+value' => (isa => 'ArrayRef');
around value => sub {
my $orig = shift;
};
implements _build_value_string => as {
- join ", ", @{ shift->current_value_choices }
+ my $self = shift;
+ join ", ", (map {$self->obj_to_name($_->{value}) } @{ $self->current_value_choices })
};
implements is_current_value => as {
my ($self, $check_value) = @_;
- my @our_values = @{$self->value||[]};
+ my @our_values = @{$self->value || []};
$check_value = $self->obj_to_str($check_value) if ref($check_value);
return grep { $self->obj_to_str($_) eq $check_value } @our_values;
};
my $value = shift;
if (defined $value) {
$value = $self->str_to_ident($value) if (!ref $value);
- my $checked = $self->attribute->check_valid_value($self->action, $value);
+ my $checked = $self->attribute->check_valid_value($self->model, $value);
confess "${value} is not a valid value" unless defined($checked);
$value = $checked;
}
$orig->($self, $value);
};
+ implements _build_value_string => as {
+ my $self = shift;
+ $self->obj_to_name($self->value->{value});
+ };
+
implements is_current_value => as {
my ($self, $check_value) = @_;
my $our_value = $self->value;
}
my $writer = $attr->get_write_method;
confess "No writer for attribute" unless defined($writer);
+ my $value = $self->value;
$self->model->$writer($self->value); #should we be passing $value ?
$self->needs_sync(0);
};
has field_order => (is => 'ro', isa => 'ArrayRef');
has builder_cache => (is => 'ro', isa => 'HashRef', lazy_build => 1);
- has ordered_fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
has excluded_fields => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+ has computed_field_order => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
implements BUILD => as {
my ($self, $args) = @_;
my $obj = $self->model;
my $args = $self->has_field_args ? $self->field_args : {};
my @fields;
- for my $field_name (@{ $self->ordered_fields }) {
+ for my $field_name (@{ $self->computed_field_order }) {
my $attr = $obj->meta->find_attribute_by_name($field_name);
my $meth = $self->builder_cache->{$field_name} ||= $self->get_builder_for($attr);
my $field = $self->$meth($attr, ($args->{$field_name} || {}));
return \@fields;
};
- implements _build_ordered_fields => as {
+ implements _build_computed_field_order => as {
my ($self) = @_;
my %excluded = map { $_ => undef } @{ $self->excluded_fields };
#treat _$field_name as private and exclude fields with no reader
# arg form_id => $_{viewport}->location;
#};
- #implements fragment field_list {
- # render field => over $_{viewport}->ordered_fields;
- #};
-
- #implements fragment field {
- # render 'viewport';
- #};
-
implements fragment ok_button_fragment {
if (grep { $_ eq 'ok' } $_{viewport}->accept_events) {
arg 'event_id' => event_id 'ok';
=head1 FRAGMENTS
-=head2 widget
-
-Renders "header", "field_list", "buttons" and "footer"
-
-=head2 field_list
-
-Sequentially renders the C<ordered_fields> of the viewport
-
-=head2 buttons
-
-Additional variables available in topic hash: "message"
-
-=head2 header
-
-Content is a dummy value
+=head2 ok_button_fragment
-=head2 footer
+=head2 apply_button_fragment
-Content is a dummy value
+=head2 cancel_button_fragment
=head1 AUTHORS
implements fragment header_cells {
arg 'labels' => $_{viewport}->field_labels;
- render header_cell => over $_{viewport}->field_order;
+ render header_cell => over $_{viewport}->computed_field_order;
};
implements fragment header_cell {
}
};
- implements fragment label_layout {
+ implements fragment label_fragment {
if (my $label = $_{viewport}->label) {
arg label => $label;
render 'label';
before fragment widget {
arg 'field_id' => event_id 'value';
- arg 'field_name' => event_id 'value';
+ arg 'field_name' => event_id 'value' unless defined $_{field_name};
arg 'field_type' => 'text';
};
class DateTime is 'Reaction::UI::Widget::Field::Mutable', which {
+ after fragment widget {
+ arg 'field_name' => event_id 'value_string';
+ };
+
};
1;
__END__;
-
=head1 NAME
Reaction::UI::Widget::Object
=head1 FRAGMENTS
-=head2 widget
-
-Renders C<field_list>
-
=head2 field_list
-Sequentially renders the C<ordered_fields> of the viewport.
+Sequentially renders the C<fields> of the viewport in the C<computed_field_order>
=head1 AUTHORS
=for layout widget
-[% label_layout %]
+[% label_fragment %]
[% value_layout %]
-=for layout label_layout
+=for layout label
<strong > [% label %]: </strong>