work in progress, listview still broken
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Role / Actions.pm
1 package Reaction::UI::ViewPort::Role::Actions;
2
3 use Reaction::Role;
4 use Reaction::UI::ViewPort::Action::Link;
5
6 role Actions, which {
7
8   has actions => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
9   has action_prototypes => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
10   implements _build_action_prototypes => as { [] };
11
12   implements _build_actions => as {
13     my ($self) = @_;
14     my (@act, $i);
15     my $ctx = $self->ctx;
16     my $loc = $self->location;
17     foreach my $proto (@{ $self->action_prototypes }) {
18       my $action = Reaction::UI::ViewPort::Action::Link->new
19         (
20          ctx      => $ctx,
21          target   => $self->model,
22          location => join ('-', $loc, 'action', $i++),
23          %$proto,
24         );
25       push(@act, $action);
26     }
27     return \@act;
28   };
29
30 };
31
32 1;