use Reaction::Class;
class Delete is 'Reaction::InterfaceModel::Action', which {
- has '+target_model' => (isa => 'Row');
+ has '+target_model' => (isa => Row);
sub can_apply { 1 }
does 'Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques';
- has '+target_model' => (isa => 'Row');
+ has '+target_model' => (isa => Row);
implements BUILD => as {
my ($self) = @_;
does 'Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques';
- has '+target_model' => (isa => 'ResultSet');
+ has '+target_model' => (isa => ResultSet);
implements do_apply => as {
my $self = shift;
class DeleteAll is 'Reaction::InterfaceModel::Action', which {
- has '+target_model' => (isa => 'ResultSet');
+ has '+target_model' => (isa => ResultSet);
sub can_apply { 1 }
use Reaction::Class;
+use Reaction::Types::Core qw(Password);
+
class ChangePassword is 'Reaction::InterfaceModel::Action::User::SetPassword', which {
- has old_password => (isa => 'Password', is => 'rw', lazy_fail => 1);
+ has old_password => (isa => Password, is => 'rw', lazy_fail => 1);
around error_for_attribute => sub {
my $super = shift;
use Reaction::Class;
use aliased 'Reaction::InterfaceModel::Action';
+use Reaction::Types::Core qw(SimpleStr Password);
class Login, is Action, which {
- has 'username' => (isa => 'SimpleStr', is => 'rw', lazy_fail => 1);
- has 'password' => (isa => 'Password', is => 'rw', lazy_fail => 1);
+ has 'username' => (isa => SimpleStr, is => 'rw', lazy_fail => 1);
+ has 'password' => (isa => Password, is => 'rw', lazy_fail => 1);
around error_for_attribute => sub {
my $super = shift;
'Reaction::InterfaceModel::Action::User::Role::ConfirmationCodeSupport';
use aliased 'Reaction::InterfaceModel::Action::User::SetPassword';
+use Reaction::Types::Core qw(NonEmptySimpleStr);
+
class ResetPassword is SetPassword, which {
does ConfirmationCodeSupport;
has confirmation_code =>
- (isa => 'NonEmptySimpleStr', is => 'rw', lazy_fail => 1);
+ (isa => NonEmptySimpleStr, is => 'rw', lazy_fail => 1);
around error_for_attribute => sub {
my $super = shift;
use Reaction::Class;
use Reaction::InterfaceModel::Action;
+use Reaction::Types::Core qw(Password);
class SetPassword is 'Reaction::InterfaceModel::Action', which {
- has new_password => (isa => 'Password', is => 'rw', lazy_fail => 1);
+ has new_password => (isa => Password, is => 'rw', lazy_fail => 1);
has confirm_new_password =>
- (isa => 'Password', is => 'rw', lazy_fail => 1);
+ (isa => Password, is => 'rw', lazy_fail => 1);
around error_for_attribute => sub {
my $super = shift;
use MooseX::Types::Moose qw/Str Num Int/;
-subtype SimpleStr
- => as Str
- => where { (length($_) <= 255) && ($_ !~ m/\n/) }
- => message { "Must be a single line of no more than 255 chars" };
+subtype SimpleStr,
+ as Str,
+ where { (length($_) <= 255) && ($_ !~ m/\n/) },
+ message { "Must be a single line of no more than 255 chars" };
-subtype NonEmptySimpleStr
- => as SimpleStr
- => where { length($_) > 0 }
- => message { "Must be a non-empty single line of no more than 255 chars" };
+subtype NonEmptySimpleStr,
+ as SimpleStr,
+ where { length($_) > 0 },
+ message { "Must be a non-empty single line of no more than 255 chars" };
# XXX duplicating constraint msges since moose only uses last message
-subtype Password
- => as NonEmptySimpleStr
- => where { length($_) > 3 }
- => message { "Must be between 4 and 255 chars" };
+subtype Password,
+ as NonEmptySimpleStr,
+ where { length($_) > 3 },
+ message { "Must be between 4 and 255 chars" };
-subtype StrongPassword
- => as Password
- => where { (length($_) > 7) && (m/[^a-zA-Z]/) }
- => message {
+subtype StrongPassword,
+ as Password,
+ where { (length($_) > 7) && (m/[^a-zA-Z]/) },
+ message {
"Must be between 8 and 255 chars, and contain a non-alpha char" };
-subtype NonEmptyStr
- => as Str
- => where { length($_) > 0 }
- => message { "Must not be empty" };
-
-subtype PositiveNum
- => as Num
- => where { $_ >= 0 }
- => message { "Must be a positive number" };
-
-subtype PositiveInt
- => as Int
- => where { $_ >= 0 }
- => message { "Must be a positive integer" };
-
-subtype SingleDigit
- => as PositiveInt
- => where { $_ <= 9 }
- => message { "Must be a single digit" };
+subtype NonEmptyStr,
+ as Str,
+ where { length($_) > 0 },
+ message { "Must not be empty" };
+
+subtype PositiveNum,
+ as Num,
+ where { $_ >= 0 },
+ message { "Must be a positive number" };
+
+subtype PositiveInt,
+ as Int,
+ where { $_ >= 0 },
+ message { "Must be a positive integer" };
+
+subtype SingleDigit,
+ as PositiveInt,
+ where { $_ <= 9 },
+ message { "Must be a single digit" };
1;
=> as 'Object'
=> where { $_->isa('DBIx::Class::ResultSet') };
-subtype ResultSet
- => as 'DBIx::Class::ResultSet';
+subtype ResultSet,
+ as 'DBIx::Class::ResultSet';
use DBIx::Class::Core;
use DBIx::Class::Row;
=> as 'Object'
=> where { $_->isa('DBIx::Class::Row') };
-subtype Row
- => as 'DBIx::Class::Row';
+subtype Row,
+ as 'DBIx::Class::Row';
1;
use MooseX::Types::Moose qw/Object ArrayRef/;
use DateTime;
-subtype DateTime
- => as Object
- => where { $_->isa('DateTime') }
- => message { "Must be of the form YYYY-MM-DD HH:MM:SS" };
+subtype DateTime,
+ as Object,
+ where { $_->isa('DateTime') },
+ message { "Must be of the form YYYY-MM-DD HH:MM:SS" };
use DateTime::SpanSet;
-subtype SpanSet
- => as Object
- => where { $_->isa('DateTime::SpanSet') };
+subtype SpanSet,
+ as Object,
+ where { $_->isa('DateTime::SpanSet') };
-subtype TimeRangeCollection
- => as ArrayRef;
+subtype TimeRangeCollection,
+ as ArrayRef;
1;
use Reaction::Types::Core 'NonEmptySimpleStr';
use Email::Valid;
-subtype EmailAddress
- => as NonEmptySimpleStr
- => where { Email::Valid->address($_) }
- => message { "Must be a valid e-mail address" };
+subtype EmailAddress,
+ as NonEmptySimpleStr,
+ where { Email::Valid->address($_) },
+ message { "Must be a valid e-mail address" };
1;
use MooseX::Types::Moose 'Object';
use Catalyst::Request::Upload;
-subtype File
- => as Object
- => where { $_->isa('Catalyst::Request::Upload') }
- => message { "Must be a file" };
+subtype File,
+ as Object,
+ where { $_->isa('Catalyst::Request::Upload') },
+ message { "Must be a file" };
1;
use Reaction::Class;
use Scalar::Util qw/blessed/;
+sub DEBUG_EVENTS () { $ENV{REACTION_UI_VIEWPORT_DEBUG_EVENTS} }
+
class ViewPort which {
has location => (isa => 'Str', is => 'rw', required => 1);
my ($self, $events) = @_;
foreach my $event ($self->accept_events) {
if (exists $events->{$event}) {
- #my $name = eval{$self->name};
- #$self->ctx->log->debug("Applying Event: $event on $name with value: ". $events->{$event});
+ if (DEBUG_EVENTS) {
+ my $name = join(' at ', ref($self), $self->location);
+ $self->ctx->log->debug(
+ "Applying Event: $event on $name with value: "
+ .$events->{$event}
+ );
+ }
$self->$event($events->{$event});
}
}
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::File';
#use aliased 'Reaction::UI::ViewPort::Field::Mutable::TimeRange';
-class Action is 'Reaction::UI::ViewPort::Object', which {
+class Action is Object, which {
has model => (is => 'ro', isa => 'Reaction::InterfaceModel::Action', required => 1);
#has '+model' => (isa => 'Reaction::InterfaceModel::Action');
implements can_apply => as {
my ($self) = @_;
foreach my $field ( @{ $self->fields } ) {
- return 0 if $field->needs_sync;
+ 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;
};
$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_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);
};
use aliased 'Reaction::UI::ViewPort::Field';
class DateTime is Field, which {
- has '+value' => (isa => 'DateTime');
+ has '+value' => (isa => DateTime);
has value_string_default_format => (
isa => 'Str', is => 'rw', required => 1, default => sub { "%F %H:%M:%S" }
class File is 'Reaction::UI::ViewPort::Field', which {
- has '+value' => (isa => 'File', required => 0);
+ has '+value' => (isa => File, required => 0);
#has '+layout' => (default => 'file');
use Reaction::Class;
+use Reaction::Types::Core qw(SimpleStr);
+
class Password is 'Reaction::UI::ViewPort::Field::String', which {
- has '+value' => (isa => 'SimpleStr');
+ has '+value' => (isa => SimpleStr);
#has '+layout' => (default => 'password');
};
package Reaction::UI::ViewPort::Field::TimeRange;
use Reaction::Class;
-use Reaction::Types::DateTime;
+use Reaction::Types::DateTime qw(SpanSet);
use DateTime;
use DateTime::SpanSet;
use Time::ParseDate ();
class TimeRange is 'Reaction::UI::ViewPort::Field', which {
- has '+value' => (isa => 'SpanSet');
+ has '+value' => (isa => SpanSet);
#has '+layout' => (default => 'timerange');
};
#XXX
- implements _build_fields_for_type_Password => as { return };
+ implements _build_fields_for_type_Reaction_Types_Core_Password => as { return };
implements _build_fields_for_type_Str => as {
my ($self, $attr, $args) = @_;
$self->_build_simple_field(attribute => $attr, class => String, %$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);
};