aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ComponentUI/Controller/TestModel/Bar.pm3
-rw-r--r--lib/ComponentUI/UI/ViewPort/Baz/ListView/Member.pm4
-rw-r--r--lib/Reaction/Manual/ActionPrototypes.pod2
-rw-r--r--lib/Reaction/UI/ViewPort/Collection.pm6
-rw-r--r--lib/Reaction/UI/ViewPort/Collection/Grid.pm80
-rw-r--r--lib/Reaction/UI/ViewPort/Collection/Grid/Member/WithActions.pm13
-rw-r--r--lib/Reaction/UI/ViewPort/ListView.pm3
-rw-r--r--lib/Reaction/UI/ViewPort/Object.pm2
-rw-r--r--lib/Reaction/UI/ViewPort/Role/FieldArgs.pm133
-rw-r--r--lib/Reaction/UI/Widget/Collection.pm9
-rw-r--r--lib/Reaction/UI/Widget/Collection/Grid/Member.pm2
-rw-r--r--lib/Reaction/UI/Widget/Collection/Grid/Member/WithActions.pm105
-rw-r--r--lib/Reaction/UI/Widget/ListView.pm8
-rw-r--r--lib/Reaction/UI/Widget/Object.pm18
14 files changed, 175 insertions, 213 deletions
diff --git a/lib/ComponentUI/Controller/TestModel/Bar.pm b/lib/ComponentUI/Controller/TestModel/Bar.pm
index 4859b7d..c649d78 100644
--- a/lib/ComponentUI/Controller/TestModel/Bar.pm
+++ b/lib/ComponentUI/Controller/TestModel/Bar.pm
@@ -12,6 +12,9 @@ __PACKAGE__->config(
ViewPort => {
enable_order_by => [qw/name foo published_at/],
coerce_order_by => { foo => ['foo.last_name', 'foo.first_name'] },
+ layout => 'bar/collection',
+ member_class => 'Reaction::UI::ViewPort::Object',
+ Member => { layout => 'bar/member' }
}
}
},
diff --git a/lib/ComponentUI/UI/ViewPort/Baz/ListView/Member.pm b/lib/ComponentUI/UI/ViewPort/Baz/ListView/Member.pm
index 26740ce..ca534aa 100644
--- a/lib/ComponentUI/UI/ViewPort/Baz/ListView/Member.pm
+++ b/lib/ComponentUI/UI/ViewPort/Baz/ListView/Member.pm
@@ -4,10 +4,10 @@ use Reaction::Class;
use namespace::clean -except => [ qw(meta) ];
use aliased 'Reaction::UI::ViewPort::Field::String::Fragment';
-extends 'Reaction::UI::ViewPort::Collection::Grid::Member::WithActions';
+extends 'Reaction::UI::ViewPort::Collection::Grid::Member';
sub _build_layout {
- 'collection/grid/member/with_actions';
+ 'collection/grid/member';
}
sub _build_fields_for_name_description {
diff --git a/lib/Reaction/Manual/ActionPrototypes.pod b/lib/Reaction/Manual/ActionPrototypes.pod
index abf3a2d..388dc4c 100644
--- a/lib/Reaction/Manual/ActionPrototypes.pod
+++ b/lib/Reaction/Manual/ActionPrototypes.pod
@@ -42,7 +42,7 @@ By default, enable C<create>, C<update>, C<delete>, C<delete_all>, actions.
know how many actions to expect to lay out the UI properly.
=item Default to member-class
-L<Grid::Member::WithActions|Reaction::UI::ViewPort::Collection::Grid::Member::WithActions>
+L<Grid::Member|Reaction::UI::ViewPort::Collection::Grid::Member>
=back
diff --git a/lib/Reaction/UI/ViewPort/Collection.pm b/lib/Reaction/UI/ViewPort/Collection.pm
index a3cb0af..d64ab42 100644
--- a/lib/Reaction/UI/ViewPort/Collection.pm
+++ b/lib/Reaction/UI/ViewPort/Collection.pm
@@ -10,6 +10,9 @@ use MooseX::Types::Moose qw/Str HashRef/;
use namespace::clean -except => [ qw(meta) ];
extends 'Reaction::UI::ViewPort';
+with 'Reaction::UI::ViewPort::Collection::Role::Pager';
+with 'Reaction::UI::ViewPort::Role::Actions';
+
has members => (is => 'rw', isa => 'ArrayRef', lazy_build => 1);
has collection => (is => 'ro', isa => IM_Collection, required => 1);
@@ -120,8 +123,7 @@ constructor as items are instantiated.
The class to use when instantiating items to represent the member items.
See: L<Object|Reaction::UI::ViewPort::Object>,
-L<Member|Reaction::UI::ViewPort::Grid::Member>,
-L<Member::WithActions|Reaction::UI::ViewPort::Grid::Member::WithActions>,
+L<Member|Reaction::UI::ViewPort::Collection::Grid::Member>.
=head1 INTERNAL METHODS
diff --git a/lib/Reaction/UI/ViewPort/Collection/Grid.pm b/lib/Reaction/UI/ViewPort/Collection/Grid.pm
index 1cf3fd9..d24b96e 100644
--- a/lib/Reaction/UI/ViewPort/Collection/Grid.pm
+++ b/lib/Reaction/UI/ViewPort/Collection/Grid.pm
@@ -3,30 +3,13 @@ package Reaction::UI::ViewPort::Collection::Grid;
use Reaction::Class;
use aliased 'Reaction::InterfaceModel::Collection' => 'IM_Collection';
-use aliased 'Reaction::UI::ViewPort::Collection::Grid::Member::WithActions';
+use aliased 'Reaction::UI::ViewPort::Collection::Grid::Member';
use namespace::clean -except => [ qw(meta) ];
use MooseX::Types::Moose qw/ArrayRef HashRef Int/;
extends 'Reaction::UI::ViewPort::Collection';
-has field_order => ( is => 'ro', isa => ArrayRef, lazy_build => 1);
-has excluded_fields => ( is => 'ro', isa => ArrayRef, lazy_build => 1);
-has included_fields => ( is => 'ro', isa => ArrayRef, lazy_build => 1);
-has computed_field_order => (is => 'ro', isa => ArrayRef, lazy_build => 1);
-
-has _raw_field_labels => (
- is => 'rw',
- isa => HashRef,
- init_arg => 'field_labels',
- default => sub { {} },
-);
-
-has field_labels => (
- is => 'ro',
- isa => HashRef,
- lazy_build => 1,
- init_arg => undef,
-);
+with 'Reaction::UI::ViewPort::Role::FieldArgs';
has member_action_count => (
is => 'rw',
@@ -43,64 +26,7 @@ has member_action_count => (
},
);
-####################################
-sub _build_member_class { WithActions };
-
-sub _build_field_labels {
- my $self = shift;
- my %labels = %{$self->_raw_field_labels};
- for my $field ( @{$self->computed_field_order}) {
- next if defined $labels{$field};
- $labels{$field} = join(' ', map{ ucfirst } split('_', $field));
- }
- return \%labels;
-}
-
-sub _build_field_order { []; }
-
-sub _build_excluded_fields { []; }
-
-sub _build_included_fields { [] }
-
-#this is a total clusterfuck and it sucks we should just eliminate it and have
-# the grid members not render ArrayRef or Collection fields
-sub _build_computed_field_order {
- my ($self) = @_;
- my %excluded = map { $_ => undef } @{ $self->excluded_fields };
- my %included = map { $_ => undef } @{ $self->included_fields };
- #treat _$field_name as private and exclude fields with no reader
- my @names = grep { $_ !~ /^_/ && (!%included || exists( $included{$_}) )
- && !exists($excluded{$_})} map { $_->name }
- grep {
- !($_->has_type_constraint &&
- ($_->type_constraint->is_a_type_of('ArrayRef') ||
- eval {$_->type_constraint->name->isa('Reaction::InterfaceModel::Collection')} ||
- eval { $_->_isa_metadata->isa('Reaction::InterfaceModel::Collection') }
- )
- ) }
- grep { defined $_->get_read_method }
- $self->current_collection->member_type->parameter_attributes;
-
- return $self->sort_by_spec($self->field_order, \@names);
-}
-
-around _build_members => sub {
- my $orig = shift;
- my $self = shift;
- $self->member_args->{computed_field_order} ||= $self->computed_field_order;
- $self->member_args->{computed_action_order} ||= [];
- my $members = $self->$orig(@_);
-
- # cache everything yo
- for my $member (@$members){
- $member->clear_computed_action_order;
- my $order = $member->computed_action_order;
- @{ $self->member_args->{computed_action_order} } = @$order;
- last;
- }
-
- return $members;
-};
+sub _build_member_class { Member };
__PACKAGE__->meta->make_immutable;
diff --git a/lib/Reaction/UI/ViewPort/Collection/Grid/Member/WithActions.pm b/lib/Reaction/UI/ViewPort/Collection/Grid/Member/WithActions.pm
deleted file mode 100644
index ea3d832..0000000
--- a/lib/Reaction/UI/ViewPort/Collection/Grid/Member/WithActions.pm
+++ /dev/null
@@ -1,13 +0,0 @@
-package Reaction::UI::ViewPort::Collection::Grid::Member::WithActions;
-
-use Reaction::Class;
-
-use namespace::clean -except => [ qw(meta) ];
-extends 'Reaction::UI::ViewPort::Collection::Grid::Member';
-
-with 'Reaction::UI::ViewPort::Role::Actions';
-
-__PACKAGE__->meta->make_immutable;
-
-
-1;
diff --git a/lib/Reaction/UI/ViewPort/ListView.pm b/lib/Reaction/UI/ViewPort/ListView.pm
index d1778bd..d2574bb 100644
--- a/lib/Reaction/UI/ViewPort/ListView.pm
+++ b/lib/Reaction/UI/ViewPort/ListView.pm
@@ -5,10 +5,7 @@ use namespace::clean -except => [ qw(meta) ];
extends 'Reaction::UI::ViewPort::Collection::Grid';
with 'Reaction::UI::ViewPort::Collection::Role::Order';
-with 'Reaction::UI::ViewPort::Collection::Role::Pager';
-with 'Reaction::UI::ViewPort::Role::Actions';
__PACKAGE__->meta->make_immutable;
-
1;
diff --git a/lib/Reaction/UI/ViewPort/Object.pm b/lib/Reaction/UI/ViewPort/Object.pm
index 9a8738e..37dfdc5 100644
--- a/lib/Reaction/UI/ViewPort/Object.pm
+++ b/lib/Reaction/UI/ViewPort/Object.pm
@@ -21,6 +21,8 @@ use MooseX::Types::Moose qw/ArrayRef HashRef/;
use namespace::clean -except => [ qw(meta) ];
extends 'Reaction::UI::ViewPort';
+with 'Reaction::UI::ViewPort::Role::Actions';
+
#everything is read only right now. Later I can make somethings read-write
#but first I need to figure out what depends on what so we can have decent triggers
has model => (is => 'ro', isa => IM_Object, required => 1);
diff --git a/lib/Reaction/UI/ViewPort/Role/FieldArgs.pm b/lib/Reaction/UI/ViewPort/Role/FieldArgs.pm
new file mode 100644
index 0000000..bff31c2
--- /dev/null
+++ b/lib/Reaction/UI/ViewPort/Role/FieldArgs.pm
@@ -0,0 +1,133 @@
+package Reaction::UI::ViewPort::Role::FieldArgs;
+
+use Reaction::Role;
+use namespace::clean -except => [ qw(meta) ];
+
+has field_order => ( is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+has excluded_fields => ( is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+has included_fields => ( is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+has computed_field_order => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
+
+has _raw_field_labels => (
+ is => 'rw',
+ isa => 'HashRef',
+ init_arg => 'field_labels',
+ default => sub { {} },
+);
+
+has field_labels => (
+ is => 'ro',
+ isa => 'HashRef',
+ lazy_build => 1,
+ init_arg => undef,
+);
+
+sub _build_field_labels {
+ my $self = shift;
+ my %labels = %{$self->_raw_field_labels};
+ for my $field ( @{$self->computed_field_order}) {
+ next if defined $labels{$field};
+ $labels{$field} = join(' ', map{ ucfirst } split('_', $field));
+ }
+ return \%labels;
+}
+
+sub _build_field_order { [] }
+
+sub _build_excluded_fields { [] }
+
+sub _build_included_fields { [] }
+
+#this is a total clusterfuck and it sucks we should just eliminate it and have
+# the grid members not render ArrayRef or Collection fields
+sub _build_computed_field_order {
+ my ($self) = @_;
+ my %excluded = map { $_ => undef } @{ $self->excluded_fields };
+ my %included = map { $_ => undef } @{ $self->included_fields };
+ #treat _$field_name as private and exclude fields with no reader
+ my @names = grep { $_ !~ /^_/ && (!%included || exists( $included{$_}) )
+ && !exists($excluded{$_})} map { $_->name }
+ grep {
+ !($_->has_type_constraint &&
+ ($_->type_constraint->is_a_type_of('ArrayRef') ||
+ eval {$_->type_constraint->name->isa('Reaction::InterfaceModel::Collection')} ||
+ eval { $_->_isa_metadata->isa('Reaction::InterfaceModel::Collection') }
+ )
+ ) }
+ grep { defined $_->get_read_method }
+ $self->current_collection->member_type->parameter_attributes;
+
+ return $self->sort_by_spec($self->field_order, \@names);
+}
+
+around _build_members => sub {
+ my $orig = shift;
+ my $self = shift;
+ $self->member_args->{computed_field_order} ||= $self->computed_field_order;
+ $self->member_args->{computed_action_order} ||= [];
+ my $members = $self->$orig(@_);
+
+ # cache everything yo
+ for my $member (@$members){
+ $member->clear_computed_action_order;
+ my $order = $member->computed_action_order;
+ @{ $self->member_args->{computed_action_order} } = @$order;
+ last;
+ }
+
+ return $members;
+};
+
+1;
+
+__END__;
+
+=head1 NAME
+
+Reaction::UI::ViewPort::Role::FieldOptions
+
+=head1 DESCRIPTION
+
+=head1 ATTRIBUTES
+
+=head2 field_order
+
+=head2 excluded_fields
+
+List of field names to exclude.
+
+=head2 included_fields
+
+List of field names to include. If both C<included_fields> and
+C<excluded_fields> are specified the result is those fields which
+are in C<included_fields> and not in C<excluded_fields>.
+
+=head2 included_fields
+
+List of field names to include. If both C<included_fields> and
+C<excluded_fields> are specified the result is those fields which
+are in C<included_fields> and not in C<excluded_fields>.
+
+=head2 field_labels
+
+=head2 computed_field_order
+
+=head1 INTERNAL METHODS
+
+These methods, although stable, are subject to change without notice. These are meant
+to be used only by developers. End users should refrain from using these methods to
+avoid potential breakages.
+
+=head1 SEE ALSO
+
+L<Reaction::UI::ViewPort::Collection>
+
+=head1 AUTHORS
+
+See L<Reaction::Class> for authors.
+
+=head1 LICENSE
+
+See L<Reaction::Class> for the license.
+
+=cut
diff --git a/lib/Reaction/UI/Widget/Collection.pm b/lib/Reaction/UI/Widget/Collection.pm
index e991c4c..b24ba45 100644
--- a/lib/Reaction/UI/Widget/Collection.pm
+++ b/lib/Reaction/UI/Widget/Collection.pm
@@ -4,7 +4,6 @@ use Reaction::UI::WidgetClass;
use namespace::clean -except => [ qw(meta) ];
-
implements fragment members {
render member => over $_{viewport}->members;
};
@@ -13,6 +12,14 @@ implements fragment member {
render 'viewport';
};
+implements fragment actions {
+ render action => over $_{viewport}->actions;
+};
+
+implements fragment action {
+ render 'viewport';
+};
+
__PACKAGE__->meta->make_immutable;
diff --git a/lib/Reaction/UI/Widget/Collection/Grid/Member.pm b/lib/Reaction/UI/Widget/Collection/Grid/Member.pm
index 24168a6..3a47aa0 100644
--- a/lib/Reaction/UI/Widget/Collection/Grid/Member.pm
+++ b/lib/Reaction/UI/Widget/Collection/Grid/Member.pm
@@ -73,7 +73,7 @@ Renders the next C<field> fragment surrounded by a C<td> element.
=item * L<Reaction::UI::Widget::Collection::Grid>
-=item * L<Reaction::UI::Widget::Collection::Grid::Member::WithActions>
+=item * L<Reaction::UI::Widget::Collection::Grid::Member>
=back
diff --git a/lib/Reaction/UI/Widget/Collection/Grid/Member/WithActions.pm b/lib/Reaction/UI/Widget/Collection/Grid/Member/WithActions.pm
deleted file mode 100644
index f9ed586..0000000
--- a/lib/Reaction/UI/Widget/Collection/Grid/Member/WithActions.pm
+++ /dev/null
@@ -1,105 +0,0 @@
-package Reaction::UI::Widget::Collection::Grid::Member::WithActions;
-
-use Reaction::UI::WidgetClass;
-
-use namespace::clean -except => [ qw(meta) ];
-extends 'Reaction::UI::Widget::Collection::Grid::Member';
-
-implements fragment actions {
- render action => over $_{viewport}->actions;
-};
-
-implements fragment action {
- render 'viewport';
-};
-
-__PACKAGE__->meta->make_immutable;
-
-1;
-
-__END__;
-
-=head1 NAME
-
-Reaction::UI::Widget::Collection::Grid::Member::WithActions - Grid members with actions
-
-=head1 DESCRIPTION
-
-This is a subclass of L<Reaction::UI::Widget::Grid::Member> additionally
-providing actions per member.
-
-=head1 FRAGMENTS
-
-=head2 actions
-
-Renders the C<action> fragment with every item in the viewports C<actions>.
-
-=head2 action
-
-Renders the C<viewport> fragment provided by L<Reaction::UI::Widget>, thus
-rendering the current viewport stored in the C<_> topic argument provided
-by the C<actions> fragment.
-
-=head1 LAYOUT SETS
-
-=head2 base
-
- share/skin/base/layout/collection/grid/member/with_actions.tt
-
-This layout set extends the C<collection/grid/member> layout set in the parent
-skin.
-
-The following layouts are provided:
-
-=over 4
-
-=item field_list
-
-First renders the original C<field_list> fragment, then the C<actions> fragment.
-
-=item action
-
-Simply renders the next C<action> fragment in line.
-
-=back
-
-=head2 default
-
- share/skin/default/layout/collection/grid/member/with_actions.tt
-
-This layout skin extends the C<collection/grid/member> layout set in the parent
-skin.
-
-The following layouts are provided:
-
-=over 4
-
-=item field_list
-
-The same as in the C<base> skin.
-
-=item action
-
-Renders the original C<action> fragment surrounded by a C<td> element.
-
-=back
-
-=head1 SEE ALSO
-
-=over 4
-
-=item * L<Reaction::UI::Widget::Grid::Member>
-
-=item * L<Reaction::UI::Widget::Grid>
-
-=back
-
-=head1 AUTHORS
-
-See L<Reaction::Class> for authors.
-
-=head1 LICENSE
-
-See L<Reaction::Class> for the license.
-
-=cut
diff --git a/lib/Reaction/UI/Widget/ListView.pm b/lib/Reaction/UI/Widget/ListView.pm
index 2fa13f8..300cd6e 100644
--- a/lib/Reaction/UI/Widget/ListView.pm
+++ b/lib/Reaction/UI/Widget/ListView.pm
@@ -16,14 +16,6 @@ implements fragment pager_fragment {
}
};
-implements fragment actions {
- render action => over $_{viewport}->actions;
-};
-
-implements fragment action {
- render 'viewport';
-};
-
implements fragment maybe_sortable_header_cell {
my $vp = $_{viewport};
if( $_{viewport}->can_order_by($_) ){
diff --git a/lib/Reaction/UI/Widget/Object.pm b/lib/Reaction/UI/Widget/Object.pm
index de83e25..8674e44 100644
--- a/lib/Reaction/UI/Widget/Object.pm
+++ b/lib/Reaction/UI/Widget/Object.pm
@@ -21,6 +21,14 @@ implements fragment field {
render 'viewport';
};
+implements fragment actions {
+ render action => over $_{viewport}->actions;
+};
+
+implements fragment action {
+ render 'viewport';
+};
+
__PACKAGE__->meta->make_immutable;
1;
@@ -44,6 +52,16 @@ method return values.
Renders the C<field> viewport passed by C<container_list>.
+=head2 actions
+
+Renders the C<action> fragment with every item in the viewports C<actions>.
+
+=head2 action
+
+Renders the C<viewport> fragment provided by L<Reaction::UI::Widget>, thus
+rendering the current viewport stored in the C<_> topic argument provided
+by the C<actions> fragment.
+
=head1 DEPRECATED FRAGMENTS
=head2 field_list