blob: 06fe0c7c7ddf59ffd62a1e09fd091182ffaa903c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
package Reaction::UI::ViewPort::Action::Role::OK;
use Reaction::Role;
use MooseX::Types::Moose qw/Str/;
with 'Reaction::UI::ViewPort::Action::Role::Close';
has ok_label => (is => 'rw', isa => 'Str', lazy_build => 1);
sub _build_ok_label { 'ok' }
sub ok {
my $self = shift;
$self->close(@_) if $self->apply(@_);
}
around accept_events => sub {
my $orig = shift;
my $self = shift;
( ($self->has_on_close_callback ? ('ok') : ()), $self->$orig(@_) );
};
1;
__END__
=head1 NAME
Reaction::UI::ViewPort::Action::Role::OK - Integrate OK, Apply and Close events
=head1 SYNOPSIS
package MyApp::UI::ViewPort::SomeAction;
use Reaction::Class;
use namespace::clean -except => 'meta';
extends 'Reaction::UI::ViewPort::Object::Mutable';
with 'Reaction::UI::ViewPort::Action::Role::OK';
...
1;
=head1 DESCRIPTION
This role integrates an C<ok> event and inherits a
L<close|Reaction::UI::ViewPort::Action::Role::Close/close>
and an L<apply|Reaction::UI::ViewPort::Action::Role::Apply/apply>
event into the consuming viewport.
=head1 ATTRIBUTES
=head2 ok_label
Defaults to C<ok>. String is built by L</_build_ok_label>.
=head1 METHODS
=head2 ok
Calls C<apply>, and then C<close> if successful.
=head2 accept_events
Extends L<Reaction::UI::ViewPort::Action::Role::Close/accept_events> with the
event C<ok> if an L<on_close_callback|Reaction::UI::ViewPort::Action::Role::Close/on_close_callback>
was provided.
=head1 INTERNAL METHODS
=head2 _build_ok_label
Returns the string representing the label for the OK action. Defaults to C<ok>.
=head1 SEE ALSO
L<Reaction::UI::ViewPort::Action::Role::Apply>
L<Reaction::UI::ViewPort::Action::Role::Close>
=head1 AUTHORS
See L<Reaction::Class> for authors.
=head1 LICENSE
See L<Reaction::Class> for the license.
=cut
|