aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/Controller/Collection.pm
diff options
context:
space:
mode:
authorgroditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-01-10 01:26:14 +0000
committergroditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-01-10 01:26:14 +0000
commitb3832dbc7ca7e87f5449e9bb857d7c67a91ffc0f (patch)
treefd536ffc3434db7d9c31981f9e26b78ddb1bacd8 /lib/Reaction/UI/Controller/Collection.pm
parentf2756356bd70930992bcd498accc29dcb01075e2 (diff)
downloadreaction-b3832dbc7ca7e87f5449e9bb857d7c67a91ffc0f.tar.gz
reaction-b3832dbc7ca7e87f5449e9bb857d7c67a91ffc0f.zip
more pod updates
Diffstat (limited to 'lib/Reaction/UI/Controller/Collection.pm')
-rw-r--r--lib/Reaction/UI/Controller/Collection.pm130
1 files changed, 124 insertions, 6 deletions
diff --git a/lib/Reaction/UI/Controller/Collection.pm b/lib/Reaction/UI/Controller/Collection.pm
index 2b35ac5..9606695 100644
--- a/lib/Reaction/UI/Controller/Collection.pm
+++ b/lib/Reaction/UI/Controller/Collection.pm
@@ -25,10 +25,6 @@ sub _build_action_viewport_args {
return { };
}
-sub base :Action :CaptureArgs(0) {
- my ($self, $c) = @_;
-}
-
#XXX candidate for futre optimization, should cache reader?
sub get_collection {
my ($self, $c) = @_;
@@ -38,9 +34,8 @@ sub get_collection {
return $model->$reader;
}
-sub list :Chained('base') :PathPart('') :Args(0) {
+sub base :Action :CaptureArgs(0) {
my ($self, $c) = @_;
- $c->forward(basic_page => [{ collection => $self->get_collection($c) }]);
}
sub object :Chained('base') :PathPart('id') :CaptureArgs(1) {
@@ -50,6 +45,11 @@ sub object :Chained('base') :PathPart('id') :CaptureArgs(1) {
$c->stash(object => $object);
}
+sub list :Chained('base') :PathPart('') :Args(0) {
+ my ($self, $c) = @_;
+ $c->forward(basic_page => [{ collection => $self->get_collection($c) }]);
+}
+
sub view :Chained('object') :Args(0) {
my ($self, $c) = @_;
$c->forward(basic_page => [{ model => $c->stash->{object} }]);
@@ -67,3 +67,121 @@ sub basic_page : Private {
}
1;
+
+
+__END__;
+
+=head1 NAME
+
+Reaction::UI::Widget::Controller
+
+=head1 DESCRIPTION
+
+Controller class used to make displaying collections easier.
+Inherits from L<Reaction::UI::Controller>.
+
+=head1 ATTRIBUTES
+
+=head2 model_name
+
+The name of the model this controller will use as it's data source. Should be a name
+that can be passed to C<$C-E<gt>model>
+
+=head2 collection_name
+
+The name of the collection whithin the model that this Controller will be utilizing.
+
+=head2 action_viewport_map
+
+=over 4
+
+=item B<_build_action_viewport_map> - Provided builder method, see METHODS
+
+=item B<has_action_viewport_map> - Auto generated predicate
+
+=item B<clear_action_viewport_map>- Auto generated clearer method
+
+=back
+
+Read-write lazy building hashref. The keys should match action names in the Controller
+and the value should be the ViewPort class that this action should use.
+ See method C<basic_page> for more info.
+
+=head action_viewport_args
+
+Read-write lazy building hashref. Additional ViewPort arguments for the action named
+as the key in the controller. See method C<basic_page> for more info.
+
+=over 4
+
+=item B<_build_action_viewport_args> - Provided builder method, see METHODS
+
+=item B<has_action_viewport_args> - Auto generated predicate
+
+=item B<clear_action_viewport_args>- Auto generated clearer method
+
+=back
+
+=head1 METHODS
+
+=head2 get_collection $c
+
+Returns an instance of the collection this controller uses.
+
+=head2 _build_action_viewport_map
+
+Provided builder for C<action_viewport_map>. Returns a hash with two items:
+
+ list => 'Reaction::UI::ViewPort::ListView',
+ view => 'Reaction::UI::ViewPort::Object',
+
+=head2 _build_action_viewport_args
+
+Returns an empty hashref.
+
+=head1 ACTIONS
+
+=head2 base
+
+Chain link, no-op.
+
+=head2 list
+
+Chain link, chained to C<base> forwards to basic page passing one custom argument,
+C<collection> which includes an instance of the current collection.
+
+The default ViewPort for this action is C<Reaction::UI::ViewPort::ListView> and can be
+changed by altering the C<action_viewport_map> attribute hash.
+
+=head2 object
+
+Chain link, chained to C<base>, captures one argument, 'id'. Attempts to find a single
+object by searching for a member of the current collection which has a Primary Key or
+Unique constraint matching that argument. If the object is found it is stored in the
+ stash under the C<object> key.
+
+=head2 view
+
+Chain link, chained to C<object>. Forwards to C<basic page> with one custom vp argument
+ of C<object>, which is the object located in the previous chain link of the same name.
+
+The default ViewPort for this action is C<Reaction::UI::ViewPort::Object> and can be
+changed by altering the C<action_viewport_map> attribute hash.
+
+=head2 basic_page
+
+Private action, accepts one argument, a hashref of viewport arguments (C<$vp_args>).
+ It will automatically determine the action name using the catalyst stack and call
+C<push_viewport> with the ViewPort class name contained in the C<action_viewport_map>
+and arguments of C<$vp_args> and the arguments contained in C<action_viewport_args>,
+if any.
+
+=head1 AUTHORS
+
+See L<Reaction::Class> for authors.
+
+=head1 LICENSE
+
+See L<Reaction::Class> for the license.
+
+=cut