56839a207efdacf06a31866afe12385f99341beb
[catagits/Reaction.git] / lib / ComponentUI / Controller / TestModel / Foo.pm
1 package ComponentUI::Controller::TestModel::Foo;
2
3 use base 'Reaction::UI::Controller::Collection::CRUD';
4 use Reaction::Class;
5
6 __PACKAGE__->config(
7   model_name => 'TestModel',
8   collection_name => 'Foo',
9   action => {
10     base => { Chained => '/base', PathPart => 'testmodel/foo' },
11     list => {
12       ViewPort => {
13         action_prototypes => { delete_all => 'Delete all records' },
14         excluded_fields => [qw/id/],
15         action_order => [qw/delete_all create/],
16         Member => {
17           action_order => [qw/view update delete/],
18         },
19       },
20     },
21     view => {
22       ViewPort => {
23         excluded_fields => [qw/id/],
24       },
25     },
26     delete => {
27       ViewPort => {message => 'Are you sure you want to delete this Foo?'}
28     },
29   },
30 );
31
32 for my $action (qw/view create update/){
33   __PACKAGE__->config(
34     action => {
35       $action => {
36         ViewPort => {
37           container_layouts => [
38             { name => 'primary', fields => [qw/first_name last_name/]},
39             {
40               name => 'secondary',
41               label => 'Optional Label',
42               fields => [qw/bars bazes/],
43             },
44           ],
45         },
46       },
47     }
48   );
49 }
50
51 sub _build_action_viewport_args {
52   my $self = shift;
53   my $args = $self->next::method(@_);
54   $args->{list}{action_prototypes}{delete_all}{label} = 'Delete All Records';
55   return $args;
56 }
57
58 1;