aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ComponentUI/Controller/TestModel/Foo.pm
blob: d9f3659f74cb1a5ac61d3ccc7a936b39ca462780 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package ComponentUI::Controller::TestModel::Foo;

use Reaction::Class;
BEGIN { extends 'Reaction::UI::Controller::Collection::CRUD'; }

use aliased 'Reaction::UI::ViewPort::SearchableListViewContainer';
use aliased 'ComponentUI::TestModel::Foo::SearchSpec';
use aliased 'ComponentUI::TestModel::Foo::Action::SearchSpec::Update';

__PACKAGE__->config(
  model_name => 'TestModel',
  collection_name => 'Foo',
  action => {
    base => { Chained => '/base', PathPart => 'testmodel/foo' },
    list => {
      ViewPort => {
        action_prototypes => { delete_all => 'Delete all records' },
        excluded_fields => [qw/id/],
        action_order => [qw/delete_all create/],
        enable_order_by => [qw/last_name/],
        Member => {
          action_order => [qw/view update delete/],
        },
      },
    },
    view => {
      ViewPort => {
        excluded_fields => [qw/id/],
      },
    },
    delete => {
      ViewPort => {message => 'Are you sure you want to delete this Foo?'}
    },
  },
);

for my $action (qw/view create update/){
  __PACKAGE__->config(
    action => {
      $action => {
        ViewPort => {
          container_layouts => [
            { name => 'primary', fields => [qw/first_name last_name/]},
            {
              name => 'secondary',
              label => 'Optional Label',
              fields => [qw/bars bazes/],
            },
          ],
        },
      },
    }
  );
}

override _build_action_viewport_map => sub {
  my $map = super();
  $map->{list} = SearchableListViewContainer;
  return $map;
};

override _build_action_viewport_args => sub {
  my $args = super();
  $args->{list}{spec_class} = SearchSpec;
  $args->{list}{action_class} = Update;
  return $args;
};

sub object : Chained('base') PathPart('id') CaptureArgs(1) {
  my ($self, $c, $object) = @_;
  $self->next::method($c, $object);
  # just as failing use case
}

1;

__END__;