c649d782f51921fc17e85871d8beffa577c157b8
[catagits/Reaction.git] / lib / ComponentUI / Controller / TestModel / Bar.pm
1 package ComponentUI::Controller::TestModel::Bar;
2
3 use base 'Reaction::UI::Controller::Collection::CRUD';
4 use Reaction::Class;
5
6 __PACKAGE__->config(
7   model_name => 'TestModel',
8   collection_name => 'Bar',
9   action => {
10     base => { Chained => '/base', PathPart => 'testmodel/bar' },
11     list => {
12       ViewPort => {
13         enable_order_by => [qw/name foo published_at/],
14         coerce_order_by => { foo => ['foo.last_name', 'foo.first_name'] },
15         layout => 'bar/collection',
16         member_class => 'Reaction::UI::ViewPort::Object',
17         Member => { layout => 'bar/member' }
18       }
19     }
20   },
21 );
22
23 sub get_collection {
24   my ($self, $c) = @_;
25   my $collection = $self->next::method($c);
26   return $collection->where({}, { prefetch => 'foo' });
27 }
28
29 sub create :Chained('base') {
30   my $self = shift;
31   my ($c) = @_;
32   my $action_vp = $self->next::method(@_);
33   my $self_uri = $c->uri_for($self->action_for('create'));
34   $action_vp->action($self_uri);
35   return $action_vp;
36 }
37
38 1;