1 package Reaction::UI::Widget::ListView;
3 use Reaction::UI::WidgetClass;
5 class ListView is 'Reaction::UI::Widget::GridView', which {
6 fragment widget [ qw/pager header body footer actions/,
8 pager => sub{ $_{viewport}->pager },
9 object_action_count => sub{ $_{viewport}->object_action_count },
10 #^^ it's ugly, i know, but i gotsto
15 [ qw/first_page previous_page current_page next_page last_page page_list/,
17 first_page => sub{ $_{pager}->first_page },
18 previous_page => sub{ $_{pager}->previous_page || $_{pager}->last_page },
19 current_page => sub{ $_{pager}->current_page },
20 next_page => sub{ $_{pager}->next_page || $_{pager}->first_page },
21 last_page => sub{ $_{pager}->last_page },
22 page_list => sub{ [$_{pager}->first_page .. $_{pager}->last_page] },
26 fragment first_page [ string{ "First" } ],
27 { uri => sub{ $_{self}->connect_uri( {page => $_{first_page} } ) } };
29 fragment previous_page [ string{ "Previous" } ],
30 { uri => sub{ $_{self}->connect_uri( {page => $_{previous_page} } ) } };
32 fragment current_page [ string{ "Current" } ],
33 { uri => sub{ $_{self}->connect_uri( {page => $_{current_page} } ) } };
35 fragment next_page [ string{ "Next" } ],
36 { uri => sub{ $_{self}->connect_uri( {page => $_{next_page} } ) } };
38 fragment last_page [ string{ "Last" } ],
39 { uri => sub{ $_{self}->connect_uri( {page => $_{last_page} } ) } };
41 fragment page_list [ page over $_{page_list} ];
42 fragment page [ string{ $_ } ],
43 { uri => sub{ $_{self}->connect_uri( {page => $_ } ) } };
45 fragment actions [ action over func(viewport => 'actions') ];
46 fragment action [ 'viewport' ];
48 fragment header_cell [ string { $_{labels}->{$_} } ],
50 my $ev = {order_by => $_, order_by_desc => $_{viewport}->order_by_desc ? 0 : 1 };
51 return $_{self}->connect_uri($ev);
55 fragment footer_cell [ string { $_{labels}->{$_} } ],
57 my $ev = {order_by => $_, order_by_desc => $_{viewport}->order_by_desc ? 0 : 1 };
58 return $_{self}->connect_uri($ev);
62 #this needs to be cleaned up and moved out
63 implements connect_uri => as{
64 my ($self, $events) = @_;
65 my $vp = $self->viewport;
66 my $ctx = $self->viewport->ctx;
67 my %args = map{ $vp->event_id_for($_) => $events->{$_} } keys %$events;
68 return $ctx->req->uri_with(\%args);