1 package Reaction::UI::ViewPort::Action;
5 use MooseX::Types::Moose qw/Int/;
6 use Reaction::Types::Core qw/NonEmptySimpleStr/;
8 use namespace::clean -except => [ qw(meta) ];
10 extends 'Reaction::UI::ViewPort::Object::Mutable';
11 with 'Reaction::UI::ViewPort::Action::Role::OK';
13 #this has to fucking go. it BLOWS.
16 isa => NonEmptySimpleStr,
17 default => sub { 'post' }
23 reader => 'is_changed',
29 foreach my $field ( @{ $self->fields } ) {
30 return 0 if $field->needs_sync;
31 # if e.g. a datetime field has an invalid value that can't be re-assembled
32 # into a datetime object, the action may be in a consistent state but
33 # not synchronized from the fields; in this case, we must not apply
35 return $self->model->can_apply;
39 shift->model->do_apply;
42 after apply_child_events => sub {
43 # interrupt here because fields will have been updated
45 $self->sync_action_from_fields;
48 sub sync_action_from_fields {
50 foreach my $field (@{$self->fields}) {
51 $field->sync_to_action; # get the field to populate the $action if possible
53 $self->model->sync_all;
54 foreach my $field (@{$self->fields}) {
55 $field->sync_from_action; # get errors from $action if applicable
60 __PACKAGE__->meta->make_immutable;
68 Reaction::UI::ViewPort::Action
74 This subclass of L<Reaction::UI::ViewPort::Object::Mutable> is used for
75 rendering a complete form supporting Apply, Close and OK.
85 Returns true if a field has been edited.
93 =head2 sync_action_from_fields
97 L<Reaction::UI::ViewPort>
99 L<Reaction::UI::ViewPort::Object>
101 L<Reaction::UI::ViewPort::Object::Mutable>
103 L<Reaction::InterfaceModel::Action::Role::Apply>
105 L<Reaction::InterfaceModel::Action::Role::Close>
107 L<Reaction::InterfaceModel::Action::Role::OK>
111 See L<Reaction::Class> for authors.
115 See L<Reaction::Class> for the license.