aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ComponentUI/Controller/TestModel/Bar.pm
blob: c649d782f51921fc17e85871d8beffa577c157b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package ComponentUI::Controller::TestModel::Bar;

use base 'Reaction::UI::Controller::Collection::CRUD';
use Reaction::Class;

__PACKAGE__->config(
  model_name => 'TestModel',
  collection_name => 'Bar',
  action => {
    base => { Chained => '/base', PathPart => 'testmodel/bar' },
    list => {
      ViewPort => {
        enable_order_by => [qw/name foo published_at/],
        coerce_order_by => { foo => ['foo.last_name', 'foo.first_name'] },
        layout => 'bar/collection',
        member_class => 'Reaction::UI::ViewPort::Object',
        Member => { layout => 'bar/member' }
      }
    }
  },
);

sub get_collection {
  my ($self, $c) = @_;
  my $collection = $self->next::method($c);
  return $collection->where({}, { prefetch => 'foo' });
}

sub create :Chained('base') {
  my $self = shift;
  my ($c) = @_;
  my $action_vp = $self->next::method(@_);
  my $self_uri = $c->uri_for($self->action_for('create'));
  $action_vp->action($self_uri);
  return $action_vp;
}

1;