Commit | Line | Data |
931cbc8d |
1 | package Reaction::UI::Controller::Role::Action::View; |
2 | |
3 | use Moose::Role -traits => 'MethodAttributes'; |
4 | use Reaction::UI::ViewPort::Object; |
5 | |
6 | requires 'setup_viewport'; |
7 | |
8 | sub view :Action :Args(0) { |
9 | my ($self, $c) = @_; |
10 | $self->setup_viewport($c, { model => $c->stash->{object} }); |
11 | } |
12 | |
13 | around _build_action_viewport_map => sub { |
14 | my $orig = shift; |
15 | my $map = shift->$orig( @_ ); |
16 | $map->{view} = 'Reaction::UI::ViewPort::Object'; |
17 | return $map; |
18 | }; |
19 | |
20 | 1; |
21 | |
22 | __END__; |
23 | |
24 | =head1 NAME |
25 | |
26 | Reaction::UI::Controller::Role::Action::View - View action |
27 | |
28 | =head1 DESCRIPTION |
29 | |
30 | Provides a C<view> action, which sets up an L<Object Viewport|Reaction::UI::Viewport::Object> |
31 | using the object located in the C<object> slot of the C<stash>. |
32 | |
33 | =head1 SYNOPSYS |
34 | |
35 | package MyApp::Controller::Foo; |
36 | |
37 | use base 'Reaction::Controller'; |
38 | use Reaction::Class; |
39 | |
40 | with( |
41 | 'Reaction::UI::Controller::Role::GetCollection', |
42 | 'Reaction::UI::Controller::Role::Action::Simple', |
43 | 'Reaction::UI::Controller::Role::Action::Object', |
44 | 'Reaction::UI::Controller::Role::Action::View' |
45 | ); |
46 | |
47 | __PACKAGE__->config( action => { |
48 | object => { Chained => 'base' }, |
49 | view => { Chained => 'object' }, |
50 | } ); |
51 | |
52 | sub base :Chained('/base') :CaptureArgs(0) { |
53 | ... |
54 | } |
55 | |
56 | |
57 | =head1 ROLES CONSUMED |
58 | |
59 | This role also consumes the following roles: |
60 | |
61 | =over4 |
62 | |
63 | =item L<Reaction::UI::Controller::Role::Action::Simple> |
64 | |
65 | =back |
66 | |
67 | =head1 ACTIONS |
68 | |
69 | =head2 view |
70 | |
71 | Chain endpoint with no args, sets up the viewport with the appropriate viewport. |
72 | |
73 | =head1 METHODS |
74 | |
75 | =head2 _build_action_viewport_map |
76 | |
77 | Extends to set the C<view> key in the map to L<Reaction::UI::ViewPort::Object> |
78 | |
79 | =head1 SEE ALSO |
80 | |
81 | =over4 |
82 | |
83 | =item L<Reaction::UI::Controller> |
84 | |
85 | =item L<Reaction::UI::Controller::Role::GetCollection> |
86 | |
87 | =item L<Reaction::UI::Controller::Role::Action::Simple> |
88 | |
89 | =item L<Reaction::UI::Controller::Role::Action::List> |
90 | |
91 | =item L<Reaction::UI::Controller::Role::Action::Object> |
92 | |
93 | =item L<Reaction::UI::Controller::Role::Action::Create> |
94 | |
95 | =item L<Reaction::UI::Controller::Role::Action::Update> |
96 | |
97 | =item L<Reaction::UI::Controller::Role::Action::Delete> |
98 | |
99 | =item L<Reaction::UI::Controller::Role::Action::DeleteAll> |
100 | |
101 | =back |
102 | |
103 | =head1 AUTHORS |
104 | |
105 | See L<Reaction::Class> for authors. |
106 | |
107 | =head1 LICENSE |
108 | |
109 | See L<Reaction::Class> for the license. |
110 | |
111 | =cut |