Commit | Line | Data |
b8faba69 |
1 | package Reaction::UI::ViewPort::GridView::Role::Actions; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Reaction::Role; |
7 | use Reaction::UI::ViewPort::GridView::Action; |
8 | |
9 | role Actions, which { |
10 | |
11 | has actions => (is => 'ro', isa => 'ArrayRef', lazy_build => 1); |
12 | has action_prototypes => (is => 'ro', isa => 'ArrayRef', lazy_build => 1); |
89939ff9 |
13 | implements _build_action_prototypes => as { [] }; |
b8faba69 |
14 | |
89939ff9 |
15 | implements _build_actions => as { |
b8faba69 |
16 | my ($self) = @_; |
17 | my (@act, $i); |
18 | my $ctx = $self->ctx; |
19 | #if i could abstract this vs ->object for row we could eliminate the entity |
20 | #version of this role and just use one for both things. that would be cool. |
21 | my $obj = $self->current_collection; |
22 | my $loc = $self->location; |
23 | foreach my $proto (@{ $self->action_prototypes }) { |
24 | my $action = Reaction::UI::ViewPort::GridView::Action->new |
25 | ( |
26 | ctx => $ctx, |
27 | target => $obj, |
28 | location => join ('-', $loc, 'action', $i++), |
29 | %$proto, |
30 | ); |
31 | push(@act, $action); |
32 | } |
33 | return \@act; |
34 | }; |
35 | |
36 | }; |
37 | |
38 | 1; |