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 event and inherits a L and an L event into the consuming viewport. =head1 ATTRIBUTES =head2 ok_label Defaults to C. String is built by L. =head1 METHODS =head2 ok Calls C, and then C if successful. =head2 accept_events Extends L with the event C if an L was provided. =head1 INTERNAL METHODS =head2 _build_ok_label Returns the string representing the label for the OK action. Defaults to C. =head1 SEE ALSO L L =head1 AUTHORS See L for authors. =head1 LICENSE See L for the license. =cut