aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/Widget/ListView.pm
blob: ab80d93c3971bf47644d18cccb4f155b66f13ccb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package Reaction::UI::Widget::ListView;

use Reaction::UI::WidgetClass;
use aliased 'Reaction::UI::ViewPort::ListView' => 'ListView_VP';

class ListView which {

  has 'viewport' => (isa => ListView_VP, is => 'ro', required => 1);

  widget renders [
    qw(header body) => { viewport => func(self => 'viewport') }
  ];
  
  header renders [ header_entry over func(viewport => 'field_names') ];
  
  header_entry renders [ string { $_{viewport}->field_label_map->{ $_ } } ];
  
  body renders [ row over func(viewport => 'current_page_collection') ];
  
  row renders [
    col_entry over func(viewport => 'field_names') => { row => $_ }
  ];
  
  col_entry renders [
    string {
      my $proto = $_{row}->$_;
      if (blessed($proto) && $proto->can('display_name')) {
        return $proto->display_name;
      }
      return "${proto}";
    }
  ];

};

1;

=head1 NAME

Reaction::UI::Widget::ListView

=head1 DESCRIPTION

=head2 viewport

=head1 AUTHORS

See L<Reaction::Class> for authors.

=head1 LICENSE

See L<Reaction::Class> for the license.

=cut