1 package Reaction::UI::ViewPort::Collection::Grid;
5 use aliased 'Reaction::InterfaceModel::Collection' => 'IM_Collection';
6 use aliased 'Reaction::UI::ViewPort::Collection::Grid::Member';
8 class Grid is 'Reaction::UI::ViewPort::Collection', which {
10 has field_order => ( is => 'ro', isa => 'ArrayRef', lazy_build => 1);
11 has excluded_fields => ( is => 'ro', isa => 'ArrayRef', lazy_build => 1);
12 has field_labels => ( is => 'ro', isa => 'HashRef', lazy_build => 1);
14 has computed_field_order => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
16 ####################################
17 implements _build_member_class => as { Member };
19 implements _build_field_labels => as {
22 for my $field ( @{$self->computed_field_order}){
23 $labels{$field} = join(' ', map{ ucfirst } split('_', $field));
28 implements _build_field_order => as { []; };
29 implements _build_excluded_fields => as { []; };
31 implements _build_computed_field_order => as {
33 confess("current_collection lacks a value for 'member_type' attribute")
34 unless $self->current_collection->has_member_type;
35 my %excluded = map { $_ => undef } @{ $self->excluded_fields };
36 #treat _$field_name as private and exclude fields with no reader
37 my @names = grep { $_ !~ /^_/ && !exists($excluded{$_})} map { $_->name }
39 !($_->has_type_constraint &&
40 ($_->type_constraint->is_a_type_of('ArrayRef') ||
41 eval {$_->type_constraint->name->isa('Reaction::InterfaceModel::Collection')} ||
42 eval { $_->_isa_metadata->isa('Reaction::InterfaceModel::Collection') }
45 grep { defined $_->get_read_method }
46 $self->current_collection->member_type->meta->parameter_attributes;
48 return $self->sort_by_spec($self->field_order, \@names);
51 before _build_members => sub {
53 $self->member_args->{computed_field_order} ||= $self->computed_field_order;
64 Reaction::UI::ViewPort::Collection
68 This subclass of L<Reaction::UI::ViewPort::Collection> allows you to display a
69 homogenous collection of Reaction::InterfaceModel::Objects as a grid.
75 =head2 excluded_fields
79 =head2 computed_field_order
83 =head1 INTERNAL METHODS
85 These methods, although stable, are subject to change without notice. These are meant
86 to be used only by developers. End users should refrain from using these methods to
87 avoid potential breakages.
91 L<Reaction::UI::ViewPort::Collection>
95 See L<Reaction::Class> for authors.
99 See L<Reaction::Class> for the license.