order_by fixes including enable_order_by and coerce_order_by
[catagits/Reaction.git] / lib / ComponentUI / Controller / TestModel / Foo.pm
index 846223e..917ea17 100644 (file)
@@ -1,12 +1,59 @@
 package ComponentUI::Controller::TestModel::Foo;
 
-use base 'Reaction::UI::CRUDController';
+use base 'Reaction::UI::Controller::Collection::CRUD';
 use Reaction::Class;
 
 __PACKAGE__->config(
-  model_base => 'TestModel',
-  model_name => 'Foo',
-  action => { base => { Chained => '/base', PathPart => 'testmodel/foo' } },
+  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/],
+            },
+          ],
+        },
+      },
+    }
+  );
+}
+
+sub _build_action_viewport_args {
+  my $self = shift;
+  my $args = $self->next::method(@_);
+  $args->{list}{action_prototypes}{delete_all}{label} = 'Delete All Records';
+  return $args;
+}
+
 1;