#warn "Loaded ${class}" unless $@;
$@ ? next : return $cache->{ $lset_name } = $class;
}
- confess "Couldn't load widget '$tail': tried: @haystack";
+ confess "Couldn't load widget '$tail' for layout '$lset_name': tried: " .
+ join(", ", @haystack);
};
implements 'layout_set_for' => as {
package Reaction::UI::ViewPort;
use Reaction::Class;
+use Scalar::Util qw/blessed/;
class ViewPort which {
isa => 'HashRef', is => 'ro', default => sub { {} }
);
has ctx => (isa => 'Catalyst', is => 'ro', required => 1);
- has column_order => (is => 'rw');
implements _build_layout => as {
'';
implements apply_child_events => as {
my ($self, $ctx, $events) = @_;
foreach my $child ($self->child_event_sinks) {
+ confess blessed($child) ."($child) is not a valid object"
+ unless blessed($child) && $child->can('apply_events');
$child->apply_events($ctx, $events);
}
};
};
implements _build_ok_label => as{ 'ok' };
- implements _build_apply_label_ => as{ 'apply' };
+ implements _build_apply_label => as{ 'apply' };
implements _build_close_label_close => as{ 'close' };
implements _build_close_label_cancel => as{ 'cancel' };
implements can_apply => as {
my ($self) = @_;
- foreach my $field ( @{ $self->ordered_fields } ) {
+ foreach my $field ( @{ $self->fields } ) {
return 0 if $field->needs_sync;
# if e.g. a datetime field has an invalid value that can't be re-assembled
# into a datetime object, the action may be in a consistent state but
implements sync_action_from_fields => as {
my ($self) = @_;
- foreach my $field ($self->fields) {
+ foreach my $field (@{$self->fields}) {
$field->sync_to_action; # get the field to populate the $action if possible
}
- $self->action->sync_all;
- foreach my $field ($self->fields) {
+ $self->model->sync_all;
+ foreach my $field (@{$self->fields}) {
$field->sync_from_action; # get errors from $action if applicable
}
};
does 'Reaction::UI::ViewPort::Field::Role::Mutable';
does 'Reaction::UI::ViewPort::Field::Role::Choices';
+
around value => sub {
my $orig = shift;
my $self = shift;
return $orig->($self) unless @_;
my $value = $listify->(shift);
$_ = $self->str_to_ident($_) for @$value;
- my $checked = $self->attribute->check_valid_value($self->action, $value);
+ my $checked = $self->attribute->check_valid_value($self->model, $value);
# i.e. fail if any of the values fail
confess "Not a valid set of values"
if (@$checked < @$value || grep { !defined($_) } @$checked);
return super() || [];
};
+ implements _build_value_string => as {
+ join ", ", @{ shift->current_value_choices }
+ };
+
implements is_current_value => as {
my ($self, $check_value) = @_;
my @our_values = @{$self->value||[]};
use Time::ParseDate;
use DateTime;
-class 'Reaction::UI::ViewPort::Field::Mutable::DateTime', is 'Reaction::UI::ViewPort::Field::DateTime', which {
+class 'Reaction::UI::ViewPort::Field::Mutable::DateTime',
+ is 'Reaction::UI::ViewPort::Field::DateTime', which {
does 'Reaction::UI::ViewPort::Field::Role::Mutable';
implements _build_valid_values => as {
my $self = shift;
- return [ $self->attribute->all_valid_values($self->action) ];
+ return [ $self->attribute->all_valid_values($self->model) ];
};
implements _build_value_choices => sub{
}
my $writer = $attr->get_write_method;
confess "No writer for attribute" unless defined($writer);
- $self->action->$writer($self->value); #should we be passing $value ?
+ $self->model->$writer($self->value); #should we be passing $value ?
$self->needs_sync(0);
};
implements sync_from_action => as {
my ($self) = @_;
return unless !$self->needs_sync; # && $self->has_attribute;
- $self->message($self->action->error_for($self->attribute) || '');
+ $self->message($self->model->error_for($self->attribute) || '');
};
around accept_events => sub { ('value', shift->(@_)) };
};
override child_event_sinks => sub {
- return ( shift->fields, super());
+ return ( @{shift->fields}, super());
};
#candidate for shared role!
}
};
- implements fragment label_fragment {
+ implements fragment label_layout {
if (my $label = $_{viewport}->label) {
arg label => $label;
render 'label';
--- /dev/null
+package Reaction::UI::Widget::Field::Integer;
+
+use Reaction::UI::WidgetClass;
+
+class Integer is 'Reaction::UI::Widget::Field', which {
+
+};
+
+1;
+
+__END__;
+
+=head1 NAME
+
+Reaction::UI::Widget::DisplayField::Integer
+
+=head1 DESCRIPTION
+
+See L<Reaction::UI::Widget::Field>
+
+=head1 AUTHORS
+
+See L<Reaction::Class> for authors.
+
+=head1 LICENSE
+
+See L<Reaction::Class> for the license.
+
+=cut
use Reaction::UI::WidgetClass;
-class Field is 'Reaction::UI::Widget::Field', which {
+class Mutable is 'Reaction::UI::Widget::Field', which {
before fragment widget {
arg 'field_id' => event_id 'value';
--- /dev/null
+package Reaction::UI::Widget::Field::Mutable::Integer;
+
+use Reaction::UI::WidgetClass;
+
+class Integer is 'Reaction::UI::Widget::Field::Mutable', which {
+
+};
+
+1;
+
+__END__;
+
+=head1 NAME
+
+Reaction::UI::Widget::Field::Integer
+
+=head1 DESCRIPTION
+
+See L<Reaction::UI::Widget::Field>
+See L<Reaction::UI::Widget::Field::Mutable>
+
+=head1 AUTHORS
+
+See L<Reaction::Class> for authors.
+
+=head1 LICENSE
+
+See L<Reaction::Class> for the license.
+
+=cut
=for layout available_values
<select size="10" multiple="multiple" name="[% event_id_add_values %]">
- [% call_next %]
+ [% call_next %]
</select>
=for layout selected_values
<select size="10" multiple="multiple" name="[% event_id_remove_values %]">
- [% call_next %]
+ [% call_next %]
</select>
=for layout hidden_value
--- /dev/null
+=extends field/mutable
+
+=cut