use Reaction::Class;
+use aliased 'Reaction::UI::ViewPort::Object';
+
+BEGIN { *DEBUG_EVENTS = \&Reaction::UI::ViewPort::DEBUG_EVENTS; }
+
use aliased 'Reaction::UI::ViewPort::Field::Mutable::Text';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::Array';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::String';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::ChooseOne';
use aliased 'Reaction::UI::ViewPort::Field::Mutable::ChooseMany';
-#use aliased 'Reaction::UI::ViewPort::InterfaceModel::Field::Mutable::File';
-#use aliased 'Reaction::UI::ViewPort::InterfaceModel::Field::Mutable::TimeRange';
+use aliased 'Reaction::UI::ViewPort::Field::Mutable::File';
+#use aliased 'Reaction::UI::ViewPort::Field::Mutable::TimeRange';
-class Action is 'Reaction::UI::ViewPort::Object', which {
- has '+model' => (isa => 'Reaction::InterfaceModel::Action');
+class Action is Object, which {
+ has model => (is => 'ro', isa => 'Reaction::InterfaceModel::Action', required => 1);
+ #has '+model' => (isa => 'Reaction::InterfaceModel::Action');
has next_action => (is => 'rw', isa => 'ArrayRef');
has on_apply_callback => (is => 'rw', isa => 'CodeRef');
};
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 } ) {
- return 0 if $field->needs_sync;
+ foreach my $field ( @{ $self->fields } ) {
+ if ($field->needs_sync) {
+ if (DEBUG_EVENTS) {
+ $self->ctx->log->debug(
+ "Failing out of can_apply on ${\ref($self)} at ${\$self->location}"
+ ." because field for ${\$field->attribute->name} 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
# not synchronized from the fields; in this case, we must not apply
}
+ if (DEBUG_EVENTS) {
+ my $ret = $self->model->can_apply;
+ $self->ctx->log->debug(
+ "model can_apply returned ${ret}"
+ ." on ${\ref($self)} at ${\$self->location}"
+ );
+ return $ret;
+ }
return $self->model->can_apply;
};
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
}
};
$self->_build_simple_field(attribute => $attr, class => Boolean, %$args);
};
- implements _build_fields_for_type_SimpleStr => as {
+ implements _build_fields_for_type_Reaction_Types_Core_SimpleStr => as {
my ($self, $attr, $args) = @_;
$self->_build_simple_field(attribute => $attr, class => String, %$args);
};
- #implements _build_fields_for_type_File => as {
- # my ($self, $attr, $args) = @_;
- # $self->_build_simple_field(attribute => $attr, class => File, %$args);
- #};
+ implements _build_fields_for_type_File => as {
+ my ($self, $attr, $args) = @_;
+ $self->_build_simple_field(attribute => $attr, class => File, %$args);
+ };
implements _build_fields_for_type_Str => as {
my ($self, $attr, $args) = @_;
if ($attr->has_valid_values) { # There's probably a better way to do this
$self->_build_simple_field(attribute => $attr, class => ChooseOne, %$args);
+ } else {
+ $self->_build_simple_field(attribute => $attr, class => Text, %$args);
}
- $self->_build_simple_field(attribute => $attr, class => Text, %$args);
};
- implements _build_fields_for_type_Password => as {
+ implements _build_fields_for_type_Reaction_Types_Core_Password => as {
my ($self, $attr, $args) = @_;
$self->_build_simple_field(attribute => $attr, class => Password, %$args);
};
- implements _build_fields_for_type_DateTime => as {
+ implements _build_fields_for_type_Reaction_Types_DateTime_DateTime => as {
my ($self, $attr, $args) = @_;
$self->_build_simple_field(attribute => $attr, class => DateTime, %$args);
};
(
attribute => $attr,
class => Array,
- layout => 'interface_model/field/mutable/array/hidden',
+ layout => 'field/mutable/hidden_array',
%$args);
}
};
=head1 NAME
-Reaction::UI::ViewPort::InterfaceModel::Action
+Reaction::UI::ViewPort::Action
=head1 SYNOPSIS
=head1 DESCRIPTION
-This subclass of viewport is used for rendering a collection of
-L<Reaction::UI::ViewPort::Field> objects for user editing.
+This subclass of L<Reaction::UI::ViewPort::Object> is used for rendering a
+collection of C<Reaction::UI::ViewPort::Field::Mutable::*> objects for user editing.
=head1 ATTRIBUTES
=head1 SEE ALSO
+L<Reaction::UI::ViewPort::Object>
+
L<Reaction::UI::ViewPort>
L<Reaction::InterfaceModel::Action>