From 3ed284566d3daa31488387321433a49ad8f7dc54 Mon Sep 17 00:00:00 2001 From: groditi Date: Fri, 2 Oct 2009 21:02:01 +0000 Subject: whoops compile error --- lib/Reaction/UI/ViewPort/Role/Actions.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Reaction/UI/ViewPort/Role/Actions.pm b/lib/Reaction/UI/ViewPort/Role/Actions.pm index f2d40fb..b17a869 100644 --- a/lib/Reaction/UI/ViewPort/Role/Actions.pm +++ b/lib/Reaction/UI/ViewPort/Role/Actions.pm @@ -77,7 +77,7 @@ sub _build_actions { uri => ( ref($uri) eq 'CODE' ? $uri->($target, $ctx) : $uri ), display => ( ref($label) eq 'CODE' ? $label->($target, $ctx) : $label ), layout => $layout, - ( ref($layout_args) eq ' HASH' ? layout_args => $layout_args : () ), + ( ref($layout_args) eq ' HASH' ? (layout_args => $layout_args) : () ), ); push(@act, $action); } -- cgit v1.2.3-54-g00ecf From fce142bbcc216ecb8a9e906000be683e9b4ccff9 Mon Sep 17 00:00:00 2001 From: wreis Date: Wed, 4 Nov 2009 19:37:47 +0000 Subject: undo r1236 --- lib/Reaction/UI/ViewPort/Role/Actions.pm | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/Reaction/UI/ViewPort/Role/Actions.pm b/lib/Reaction/UI/ViewPort/Role/Actions.pm index b17a869..ceb9bfe 100644 --- a/lib/Reaction/UI/ViewPort/Role/Actions.pm +++ b/lib/Reaction/UI/ViewPort/Role/Actions.pm @@ -63,21 +63,11 @@ sub _build_actions { my $label = exists $proto->{label} ? $proto->{label} : $proto_name; my $layout = exists $proto->{layout} ? $proto->{layout} : 'uri'; - my $layout_args; - if( exists $proto->{layout_args} ){ - if( ref($proto->{layout_args}) eq 'CODE' ){ - $layout_args = $proto->{layout_args}->($target, $ctx); - } else { - $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 => $layout, - ( ref($layout_args) eq ' HASH' ? (layout_args => $layout_args) : () ), ); push(@act, $action); } -- cgit v1.2.3-54-g00ecf -- cgit v1.2.3-54-g00ecf From 22a2b24377352d8e5b1be2942d559cc3fef4df2e Mon Sep 17 00:00:00 2001 From: edenc Date: Wed, 11 Nov 2009 19:31:04 +0000 Subject: working around Moose glitch via parameterized roles --- Makefile.PL | 1 + lib/Reaction/InterfaceModel/Reflector/DBIC.pm | 2 +- .../UI/ViewPort/Field/Mutable/ChooseMany.pm | 4 +-- lib/Reaction/UI/ViewPort/Field/Mutable/File.pm | 5 ++-- lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm | 29 +++++++++++++++++++--- .../UI/ViewPort/Field/Role/Mutable/Simple.pm | 17 ++++++++++--- 6 files changed, 44 insertions(+), 14 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index f25c126..da2cb84 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -46,6 +46,7 @@ requires 'namespace::clean' => '0.11'; requires 'metaclass' => '0.81'; requires 'Method::Signatures::Simple' => '0.03'; requires 'signatures' => '0.05'; +requires 'MooseX::Role::Parameterized' => '0.13'; test_requires 'Test::Class' => '0.31'; test_requires 'Test::WWW::Mechanize::Catalyst' => '0.51'; diff --git a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm index 38d9025..96bc262 100644 --- a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm +++ b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm @@ -153,7 +153,7 @@ sub reflect_schema { superclasses => [$base], ( @$roles ? (roles => $roles) : ()), ); - + # sources => undef, #default to qr/./ # sources => [], #default to nothing # sources => qr//, #DWIM, treated as [qr//] diff --git a/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm b/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm index 1b7a411..227ad33 100644 --- a/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm +++ b/lib/Reaction/UI/ViewPort/Field/Mutable/ChooseMany.pm @@ -11,11 +11,11 @@ use namespace::clean -except => [ qw(meta) ]; use MooseX::Types::Moose qw/ArrayRef/; extends 'Reaction::UI::ViewPort::Field'; -with 'Reaction::UI::ViewPort::Field::Role::Mutable'; +with 'Reaction::UI::ViewPort::Field::Role::Mutable' => { value_type => 'ArrayRef' }; with 'Reaction::UI::ViewPort::Field::Role::Choices'; #MUST BE HERE, BELOW THE 'does', OR THE TRIGGER WILL NOT HAPPEN! -has '+value' => (isa => ArrayRef); +#has '+value' => (isa => ArrayRef); around value => sub { my $orig = shift; diff --git a/lib/Reaction/UI/ViewPort/Field/Mutable/File.pm b/lib/Reaction/UI/ViewPort/Field/Mutable/File.pm index 4318eee..5c1b35d 100644 --- a/lib/Reaction/UI/ViewPort/Field/Mutable/File.pm +++ b/lib/Reaction/UI/ViewPort/Field/Mutable/File.pm @@ -6,9 +6,8 @@ use Reaction::Class; use namespace::clean -except => [ qw(meta) ]; extends 'Reaction::UI::ViewPort::Field'; -with 'Reaction::UI::ViewPort::Field::Role::Mutable::Simple'; - -has '+value' => (isa => Upload); +with 'Reaction::UI::ViewPort::Field::Role::Mutable::Simple' + => { value_type => Upload }; override apply_our_events => sub { my ($self, $events) = @_; diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm index 94953f4..16ae93f 100644 --- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm +++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm @@ -1,26 +1,46 @@ package Reaction::UI::ViewPort::Field::Role::Mutable; -use Reaction::Role; +use MooseX::Role::Parameterized; use aliased 'Reaction::InterfaceModel::Action'; use aliased 'Reaction::Meta::InterfaceModel::Action::ParameterAttribute'; use MooseX::Types::Moose qw/Int Str/; - use namespace::clean -except => [ qw(meta) ]; +=pod + +15:24 mst:» I'm not sure I understand why the +foo is overwriting my after'ed clear_value +15:24 mst:» but I would argue it shouldn't do that +15:25 @doy:» because has '+foo' is creating an entirely new attribute +15:25 @doy:» and just copying the meta-attribute's attributes into it +15:25 @doy:» so it's creating a new clearer sub in the subclass +15:27 rafl:» mst: for that case, i tend to just parameterize the role on whatever i might want to override in its attribute definitions + +=cut + +parameter value_type => ( + predicate => 'has_value_type' +); + +role { + +my $p = shift; + has model => (is => 'ro', isa => Action, required => 1); has attribute => (is => 'ro', isa => ParameterAttribute, required => 1); has value => ( - is => 'rw', lazy_build => 1, trigger_adopt('value'), + is => 'rw', lazy_build => 1, trigger => sub { shift->adopt_value }, clearer => 'clear_value', + $p->has_value_type? (isa => $p->value_type) : () ); + has needs_sync => (is => 'rw', isa => Int, default => 0); #should be bool? has message => (is => 'rw', isa => Str, clearer => 'clear_message'); has is_modified => ( #sould be bool? - is => 'ro', writer => '_set_modified', + is => 'ro', writer => '_set_modified', required => 1, default => 1, init_arg => undef ); @@ -111,6 +131,7 @@ sub sync_from_action { around accept_events => sub { ('value', shift->(@_)) }; +}; 1; diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm index e19fa61..d8ca473 100644 --- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm +++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm @@ -1,14 +1,23 @@ package Reaction::UI::ViewPort::Field::Role::Mutable::Simple; -use Reaction::Role; +use MooseX::Role::Parameterized; use aliased 'Reaction::UI::ViewPort::Field::Role::Mutable'; use namespace::clean -except => [ qw(meta) ]; -with Mutable; + +parameter value_type => ( + predicate => 'has_value_type' +); + +role { + +my $p = shift; + +with Mutable, $p->has_value_type ? { value_type => $p->value_type } : (); has value_string => ( - is => 'rw', lazy_build => 1, trigger_adopt('value_string'), + is => 'rw', lazy_build => 1, trigger => sub { shift->adopt_value_string }, clearer => 'clear_value', ); @@ -44,6 +53,6 @@ around accept_events => sub { ('value_string', shift->(@_)) }; around force_events => sub { (value_string => '', shift->(@_)) }; - +}; 1; -- cgit v1.2.3-54-g00ecf From 1fb2fe93587857afb8b3e4923a4ab726831033d3 Mon Sep 17 00:00:00 2001 From: edenc Date: Mon, 16 Nov 2009 22:06:25 +0000 Subject: added clone and inherit fix to Field::Mutable::HiddenArray --- lib/Reaction/UI/ViewPort/Field/Mutable/HiddenArray.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Reaction/UI/ViewPort/Field/Mutable/HiddenArray.pm b/lib/Reaction/UI/ViewPort/Field/Mutable/HiddenArray.pm index 77df3de..a54dfc5 100644 --- a/lib/Reaction/UI/ViewPort/Field/Mutable/HiddenArray.pm +++ b/lib/Reaction/UI/ViewPort/Field/Mutable/HiddenArray.pm @@ -6,9 +6,9 @@ use MooseX::Types::Moose qw/ArrayRef/; extends 'Reaction::UI::ViewPort::Field'; -with 'Reaction::UI::ViewPort::Field::Role::Mutable'; +with 'Reaction::UI::ViewPort::Field::Role::Mutable' => { value_type => 'ArrayRef' }; -has '+value' => (isa => ArrayRef); +#has '+value' => (isa => ArrayRef); around value => sub { my $orig = shift; -- cgit v1.2.3-54-g00ecf From a722f3e3e226a7319f69722de01c06792b3cf2c3 Mon Sep 17 00:00:00 2001 From: edenc Date: Fri, 4 Dec 2009 21:35:06 +0000 Subject: fixed hash deref bug in the base controller --- lib/Reaction/UI/Controller.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Reaction/UI/Controller.pm b/lib/Reaction/UI/Controller.pm index 2d1b843..f428941 100644 --- a/lib/Reaction/UI/Controller.pm +++ b/lib/Reaction/UI/Controller.pm @@ -12,7 +12,7 @@ with 'Catalyst::Component::InstancePerContext'; sub build_per_context_instance { my ($self, $c, @args) = @_; my $class = ref($self) || $self; - my $newself = $class->new($self->_application, {%$self, context => $c, @args}); + my $newself = $class->new($self->_application, {%{$self || {}}, context => $c, @args}); return $newself; } @@ -136,7 +136,7 @@ controller configuration. For example to override the default number of items in a CRUD list action: __PACKAGE__->config( - action => { + action => { list => { ViewPort => { per_page => 50 } }, } ); @@ -160,7 +160,7 @@ TODO: explain how next_action as a scalar gets converted to the redirect arrayre =head2 pop_viewport_to $vp Call L or -L on +L on the C<< $c->stash->{focus_stack} >>. =head2 redirect_to $c, $to, $captures, $args, $attrs @@ -186,7 +186,7 @@ $args if not supplied. =head2 make_context_closure The purpose of this method is to prevent memory leaks. -It weakens the context object, often denoted $c, and passes it as the +It weakens the context object, often denoted $c, and passes it as the first argument to the sub{} that is passed to the make_context_closure method. In other words, @@ -199,7 +199,7 @@ make_context_closure returns sub { $sub_you_gave_it->($weak_c, @_) To further expound up this useful construct consider code written before make_context_closure was created: - on_apply_callback => + on_apply_callback => sub { $self->after_search( $c, @_ ); } -- cgit v1.2.3-54-g00ecf