r31500@martha (orig r1229): purge | 2009-09-11 05:51:11 -0400
groditi [Fri, 25 Sep 2009 18:58:40 +0000 (18:58 +0000)]
 make_immutable for new moose
 r31688@martha (orig r1231):  mateu | 2009-09-13 18:18:07 -0400
 Bump version of SQL::Translator required for testing so t/im_dbic.t passes.
 r31689@martha (orig r1232):  wreis | 2009-09-14 13:35:30 -0400
 fixed child_event_sinks for SearchableListViewContainer vp
 r31690@martha (orig r1233):  wreis | 2009-09-14 13:35:58 -0400
 collection-grid already does Pager and Actions
 r31691@martha (orig r1234):  edenc | 2009-09-14 23:51:37 -0400
 added search spec sample to demo app
 r31692@martha (orig r1235):  wreis | 2009-09-15 11:36:30 -0400
 no divs in base skin
 r31693@martha (orig r1236):  purge | 2009-09-17 10:21:58 -0400
 pass through layout_args to actions
 r31694@martha (orig r1237):  edenc | 2009-09-17 14:14:04 -0400
 compatibility fixes for Class::MOP 0.93

23 files changed:
Makefile.PL
lib/ComponentUI/Controller/TestModel/Foo.pm
lib/ComponentUI/TestModel/Foo/Action/SearchSpec/Update.pm [new file with mode: 0644]
lib/ComponentUI/TestModel/Foo/SearchSpec.pm [new file with mode: 0644]
lib/Reaction/Class.pm
lib/Reaction/Object.pm
lib/Reaction/UI/Controller.pm
lib/Reaction/UI/Skin.pm
lib/Reaction/UI/ViewPort/ListViewWithSearch.pm
lib/Reaction/UI/ViewPort/Role/Actions.pm
lib/Reaction/UI/ViewPort/SearchableListViewContainer.pm
share/skin/base/layout/action.tt
share/skin/base/layout/collection.tt
share/skin/base/layout/field/array.tt
share/skin/base/layout/field/collection.tt
share/skin/base/layout/field/container.tt
share/skin/base/layout/field/mutable.tt
share/skin/base/layout/field/mutable/choose_many.tt
share/skin/default/layout/action.tt
share/skin/default/layout/field/array.tt
share/skin/default/layout/field/collection.tt
share/skin/default/layout/field/mutable.tt
share/skin/default/layout/field/mutable/choose_many.tt

index 549760e..b1c2ec6 100644 (file)
@@ -51,7 +51,7 @@ requires 'signatures' => '0.05';
 test_requires 'Test::Class' => '0.31';
 test_requires 'Test::WWW::Mechanize::Catalyst' => '0.51';
 test_requires 'Test::Memory::Cycle' => '1.04';
-test_requires 'SQL::Translator' => '0.09004';
+test_requires 'SQL::Translator' => '0.11002';
 
 install_share;
 
index 2fb994c..04a56e8 100644 (file)
@@ -3,6 +3,10 @@ package ComponentUI::Controller::TestModel::Foo;
 use base 'Reaction::UI::Controller::Collection::CRUD';
 use Reaction::Class;
 
+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',
@@ -49,11 +53,19 @@ for my $action (qw/view create update/){
   );
 }
 
-# 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;
-# }
+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;
+};
 
 1;
+
+__END__;
diff --git a/lib/ComponentUI/TestModel/Foo/Action/SearchSpec/Update.pm b/lib/ComponentUI/TestModel/Foo/Action/SearchSpec/Update.pm
new file mode 100644 (file)
index 0000000..97d2feb
--- /dev/null
@@ -0,0 +1,15 @@
+package ComponentUI::TestModel::Foo::Action::SearchSpec::Update;
+use Reaction::Class;
+use namespace::autoclean;
+
+use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
+
+extends 'Reaction::InterfaceModel::Action';
+with 'Reaction::InterfaceModel::Search::UpdateSpec';
+
+has 'first_name' => (isa => NonEmptySimpleStr, is => 'rw', required => 0);
+has 'last_name' => (isa => NonEmptySimpleStr, is => 'rw', required => 0);
+
+sub _reflection_info {{ normal => [qw/first_name last_name/] }}
+
+1;
diff --git a/lib/ComponentUI/TestModel/Foo/SearchSpec.pm b/lib/ComponentUI/TestModel/Foo/SearchSpec.pm
new file mode 100644 (file)
index 0000000..4664ec6
--- /dev/null
@@ -0,0 +1,24 @@
+package ComponentUI::TestModel::Foo::SearchSpec;
+use Reaction::Class;
+use namespace::autoclean;
+
+use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
+
+with 'Reaction::InterfaceModel::Search::Spec';
+
+has 'first_name' => (isa => NonEmptySimpleStr, is => 'rw', required => 0);
+has 'last_name' => (isa => NonEmptySimpleStr, is => 'rw', required => 0);
+
+sub _build__search_spec {
+  my($self) = @_;
+  my %search;
+  $search{first_name} = $self->first_name if $self->has_first_name;
+  $search{last_name} = $self->last_name if $self->has_last_name;
+  return [\%search];
+}
+
+# no special packing/unpacking required for Foo
+sub _to_string_pack_value { $_[1] }
+sub _from_string_unpack_value { $_[1] }
+
+1;
index a57dcdf..9f61bbf 100644 (file)
@@ -233,6 +233,8 @@ sub next_import {
 
 sub next_import_package { 'Moose' }
 
+__PACKAGE__->meta->make_immutable;
+
 1;
 
 #---------#---------#---------#---------#---------#---------#---------#--------#
index 7440bd3..de4c740 100644 (file)
@@ -7,6 +7,8 @@ use Moose qw(extends);
 
 extends 'Moose::Object';
 
+__PACKAGE__->meta->make_immutable;
+
 no Moose;
 
 1;
index 8ed781f..2d1b843 100644 (file)
@@ -11,7 +11,8 @@ with 'Catalyst::Component::InstancePerContext';
 
 sub build_per_context_instance {
   my ($self, $c, @args) = @_;
-  my $newself =  $self->new($self->_application, {%$self, context => $c, @args});
+  my $class = ref($self) || $self;
+  my $newself =  $class->new($self->_application, {%$self, context => $c, @args});
   return $newself;
 }
 
index 237279d..0683258 100644 (file)
@@ -71,6 +71,7 @@ sub _find_skin_dir {
 };
 sub _load_skin_config {
   my ($self, $args) = @_;
+  my $class = ref($self) || $self;
   my $base = $self->skin_dir;
   my $lst = sub { (ref $_[0] eq 'ARRAY') ? $_[0] : [$_[0]] };
   my @files = (
@@ -84,7 +85,7 @@ sub _load_skin_config {
               })}
             );
   if (my $super_name = $cfg{extends}) {
-    my $super = $self->new(
+    my $super = $class->new(
       name => $super_name,
       view => $self->view,
       skin_base_dir => $args->{skin_base_dir},
index ee5f738..c199f7d 100644 (file)
@@ -6,8 +6,6 @@ extends 'Reaction::UI::ViewPort::Collection::Grid';
 
 with 'Reaction::UI::ViewPort::Collection::Role::UseSearchSpec';
 with 'Reaction::UI::ViewPort::Collection::Role::Order';
-with 'Reaction::UI::ViewPort::Collection::Role::Pager';
-with 'Reaction::UI::ViewPort::Role::Actions';
 
 __PACKAGE__->meta->make_immutable;
 
index 32c7bbb..89b5ae3 100644 (file)
@@ -62,12 +62,14 @@ sub _build_actions {
     my $uri = $proto->{uri} or confess('uri is required in prototype action');
     my $label = exists $proto->{label} ? $proto->{label} : $proto_name;
     my $layout = exists $proto->{layout} ? $proto->{layout} : 'uri';
+    my $layout_args = exists $proto->{layout_args} ? $proto->{layout_args} : {};
 
     my $action = Reaction::UI::ViewPort::URI->new(
       location => join ('-', $loc, 'action', $i++),
       uri => ( ref($uri) eq 'CODE' ? $uri->($target, $ctx) : $uri ),
       display => ( ref($label) eq 'CODE' ? $label->($target, $ctx) : $label ),
       layout => ( ref($layout) eq 'CODE' ? $layout->($target, $ctx) : $layout ),
+      layout_args => ( ref($layout_args) eq 'CODE' ? $layout_args->($target, $ctx) : $layout_args ),
     );
     push(@act, $action);
   }
index d83941b..4468275 100644 (file)
@@ -74,7 +74,7 @@ override BUILDARGS => sub {
 };
 
 override child_event_sinks => method () {
-  ((map $self->$_, 'listview', 'search_form'), super);
+  ((map $self->$_, 'search_form', 'listview'), super);
 };
 
 1;
index b5cb708..dba41d0 100644 (file)
@@ -1,13 +1,11 @@
 =for layout widget
 
-<div class="action_form">
-  <form action="[% action %]" id="[% form_id %]" method="[% method %]" enctype="multipart/form-data">
-    [% header  %]
-    [% container_list %]
-    [% buttons %]
-    [% footer  %]
-  </form>
-</div>
+<form action="[% action %]" id="[% form_id %]" method="[% method %]" enctype="multipart/form-data">
+  [% header  %]
+  [% container_list %]
+  [% buttons %]
+  [% footer  %]
+</form>
 
 =for layout header
 
index 6becfb1..da0cd2f 100644 (file)
@@ -6,9 +6,7 @@
 
 =for layout body
 
-<div class="collection_members">
-  [% members %]
-</div>
+[% members %]
 
 =for layout footer
 
index cd9c0c2..ac62db7 100644 (file)
@@ -9,11 +9,9 @@
 
 =for layout list
 
-<div class="array_list">
 <ul>
-[% content %]
+  [% content %]
 </ul>
-</div>
 
 =for layout item
 
index 2203344..1f6ae9e 100644 (file)
@@ -9,11 +9,9 @@
 
 =for layout list
 
-<div class="collection_list">
 <ul>
-[% call_next %]
+  [% call_next %]
 </ul>
-</div>
 
 =for layout item
 
index c504e55..d9e0ced 100644 (file)
@@ -11,8 +11,6 @@
 
 =for layout field
 
-<div class="field_container_field">
-  [% call_next %]
-</div>
+[% call_next %]
 
 =cut
index d21e979..333a27a 100644 (file)
@@ -1,6 +1,6 @@
 =for layout widget
 
-<div class="[% field_class %]">[% label_fragment %] [% field %] [% message_fragment %]</div>
+[% label_fragment %] [% field %] [% message_fragment %]
 
 =for layout label
 
index 51f315e..9d19fff 100644 (file)
@@ -8,7 +8,6 @@
 
 =for layout field
 
-<div class="choose_many_field">
 <table>
   <tr>
     <td> [% available_values %] </td>
@@ -19,7 +18,6 @@
     </td>
   </tr>
 </table>
-</div>
 
 =for layout available_values
 
 
 =for layout action_buttons
 
-<div class="choose_many_buttons">
-  <input type="submit" value="&gt;&gt;" name="[% event_id_add_all_values %]" />
-  <input type="submit" value="&gt;" name="[% event_id_do_add_values %]" />
-  <input type="submit" value="&lt;" name="[% event_id_do_remove_values %]" />
-  <input type="submit" value="&lt;&lt;" name="[% event_id_remove_all_values %]" />
-</div>
+<input type="submit" value="&gt;&gt;" name="[% event_id_add_all_values %]" />
+<input type="submit" value="&gt;" name="[% event_id_do_add_values %]" />
+<input type="submit" value="&lt;" name="[% event_id_do_remove_values %]" />
+<input type="submit" value="&lt;&lt;" name="[% event_id_remove_all_values %]" />
 
 =for layout message
 
index a18e51d..e1b003f 100644 (file)
@@ -1,5 +1,11 @@
 =extends NEXT
 
+=for layout widget
+
+<div class="action_form">
+  [% call_next %]
+</div>
+
 =for layout container
 
 [% call_next %] <br />
index acb2cce..60c86b1 100644 (file)
@@ -4,4 +4,10 @@
 
 <span class="field_array_label"><strong > [% content | html %]: </strong></span>
 
+=for layout list
+
+<div class="array_list">
+  [% call_next %]
+</div>
+
 =cut
index f513e94..16789bf 100644 (file)
@@ -4,4 +4,10 @@
 
 <span class="field_collection_label_box"><strong> [% label %]: </strong></span>
 
+=for layout list
+
+<div class="collection_list">
+  [% call_next %]
+</div>
+
 =cut
index 615e14e..ec10a4c 100644 (file)
@@ -1,5 +1,9 @@
 =extends NEXT
 
+=for layout widget
+
+<div class="[% field_class %]">[% call_next %]</div>
+
 =for layout message
 
 [% call_next %]<br />
index e01a1ba..117f39e 100644 (file)
@@ -6,13 +6,16 @@
 [% message_fragment %]
 [% field %]
 
+=for layout field
+
+<div class="choose_many_field">
+  [% call_next %]
+</div>
+
 =for layout action_buttons
 
 <div class="choose_many_buttons">
-<input type="submit" value="&gt;&gt;" name="[% event_id_add_all_values %]" /> <br />
-<input type="submit" value="&gt;" name="[% event_id_do_add_values %]" /> <br />
-<input type="submit" value="&lt;" name="[% event_id_do_remove_values %]" /> <br />
-<input type="submit" value="&lt;&lt;" name="[% event_id_remove_all_values %]" /> <br />
+  [% call_next %]
 </div>
 
 =cut