| 1 | package Reaction::UI::Controller::Collection; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | BEGIN { extends 'Reaction::UI::Controller'; } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 4 | ▶ | use aliased 'Reaction::UI::ViewPort::Collection::Grid'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 4 | __PACKAGE__->config( | |||||||||
| 9 | action => { | ||||||||||
| 10 | list => { Chained => 'base', PathPart => '' }, | ||||||||||
| 11 | object => { Chained => 'base', PathPart => 'id' }, | ||||||||||
| 12 | view => { Chained => 'object', }, | ||||||||||
| 13 | }, | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | 4 | with( | |||||||||
| 17 | 'Reaction::UI::Controller::Role::GetCollection', | ||||||||||
| 18 | 'Reaction::UI::Controller::Role::Action::Simple', | ||||||||||
| 19 | 'Reaction::UI::Controller::Role::Action::Object', | ||||||||||
| 20 | 'Reaction::UI::Controller::Role::Action::View', | ||||||||||
| 21 | 'Reaction::UI::Controller::Role::Action::List' | ||||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | 4 | has default_member_actions => ( | |||||||||
| 25 | isa => 'ArrayRef', | ||||||||||
| 26 | is => 'rw', | ||||||||||
| 27 | lazy_build => 1 | ||||||||||
| 28 | ); | ||||||||||
| 29 | |||||||||||
| 30 | 4 | has default_collection_actions => ( | |||||||||
| 31 | isa => 'ArrayRef', | ||||||||||
| 32 | is => 'rw', | ||||||||||
| 33 | lazy_build => 1 | ||||||||||
| 34 | ); | ||||||||||
| 35 | |||||||||||
| 36 | 3 | ▶ | sub _build_default_member_actions { ['view'] } | ||||||||
|
Subroutine
_build_default_member_actions: called CC=1 SCAR=0.0
| |||||||||||
| 37 | |||||||||||
| 38 | 3 | ▶ | sub _build_default_collection_actions { [] } | ||||||||
|
Subroutine
_build_default_collection_actions: called CC=1 SCAR=0.0
| |||||||||||
| 39 | |||||||||||
| 40 | 3 | ▶ | around _build_action_viewport_map => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 41 | 3 | my $orig = shift; | |||||||||
| 42 | 3 | my $map = shift->$orig( @_ ); | |||||||||
| 43 | 3 | $map->{list} = Grid; | |||||||||
| 44 | 3 | return $map; | |||||||||
| 45 | 4 | }; | |||||||||
| 46 | |||||||||||
| 47 | 3 | ▶ | around _build_action_viewport_args => sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 48 | 3 | my $orig = shift; | |||||||||
| 49 | 3 | my $self = shift; | |||||||||
| 50 | 3 | my $args = { list => { Member => {} } }; | |||||||||
| 51 | |||||||||||
| 52 | 3 | my $m_protos = $args->{list}{Member}{action_prototypes} = {}; | |||||||||
| 53 | 3 | for my $action_name( @{ $self->default_member_actions }){ | |||||||||
| 54 | 9 | my $label = join(' ', map { ucfirst } split(/_/, $action_name)); | |||||||||
| 55 | 9 | my $proto = $self->_build_member_action_prototype($label, $action_name); | |||||||||
| 56 | 9 | $m_protos->{$action_name} = $proto; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 3 | my $c_protos = $args->{list}{action_prototypes} = {}; | |||||||||
| 60 | 3 | for my $action_name( @{ $self->default_collection_actions }){ | |||||||||
| 61 | 6 | my $label = join(' ', map { ucfirst } split(/_/, $action_name)); | |||||||||
| 62 | 6 | my $proto = $self->_build_collection_action_prototype($label, $action_name); | |||||||||
| 63 | 6 | $c_protos->{$action_name} = $proto; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 3 | return $args; | |||||||||
| 67 | 4 | }; | |||||||||
| 68 | |||||||||||
| 69 | 9 | ▶ | sub _build_member_action_prototype { | ||||||||
|
Subroutine
_build_member_action_prototype: called CC=1 SCAR=2.0
| |||||||||||
| 70 | 9 | my ($self, $label, $action_name) = @_; | |||||||||
| 71 | return { | ||||||||||
| 72 | label => $label, | ||||||||||
| 73 | 0 | ▶ | uri => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 74 | 0 | my $action = $self->action_for($action_name); | |||||||||
| 75 | 0 | $_[1]->uri_for($action, [ @{$_[1]->req->captures}, $_[0]->__id ]); | |||||||||
| 76 | }, | ||||||||||
| 77 | 9 | }; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 6 | ▶ | sub _build_collection_action_prototype { | ||||||||
|
Subroutine
_build_collection_action_prototype: called CC=1 SCAR=1.2
| |||||||||||
| 81 | 6 | my ($self, $label, $action_name) = @_; | |||||||||
| 82 | return { | ||||||||||
| 83 | label => $label, | ||||||||||
| 84 | 0 | ▶ | uri => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 85 | 0 | my $action = $self->action_for($action_name); | |||||||||
| 86 | 0 | $_[1]->uri_for($action, $_[1]->req->captures); | |||||||||
| 87 | }, | ||||||||||
| 88 | 6 | }; | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | |||||||||||
| 92 | 3 | ▶ | sub base :CaptureArgs(0) { | ||||||||
|
Subroutine
base: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 93 | 3 | my ($self, $c) = @_; | |||||||||
| 94 | 4 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 95 | |||||||||||
| 96 | ##DEPRECATED ACTION | ||||||||||
| 97 | |||||||||||
| 98 | 0 | ▶ | sub basic_page { | ||||||||
|
Subroutine
basic_page: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 99 | 0 | my( $self, $c, @args) = @_; | |||||||||
| 100 | 0 | ▶ | if( $c->debug ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 101 | 0 | my ($package,undef,$line,$sub_name,@rest) = caller(1); | |||||||||
| 102 | 0 | my $message = "The method 'basic_page', called from sub '${sub_name}' in package ${package} at line ${line} is deprecated. Please use 'setup_viewport' instead."; | |||||||||
| 103 | 0 | $c->log->debug( $message ); | |||||||||
| 104 | } | ||||||||||
| 105 | 0 | $self->setup_viewport( $c, @args ); | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 4 | 1; | |||||||||
| 109 | |||||||||||
| 110 | __END__; | ||||||||||