/[transports]/trunk/web/templates/transports/table
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/web/templates/transports/table

Parent Directory Parent Directory | Revision Log Revision Log


Revision 74 - (hide annotations)
Mon Jun 12 10:14:50 2006 UTC (18 years ago) by dpavlin
File size: 3695 byte(s)
added table sorting
1 dpavlin 37 <%args>
2     $page => 1
3 dpavlin 69 $show_description => 0
4     $show_comment => 0
5 dpavlin 74 $order => 'date'
6 dpavlin 37 </%args>
7     <%init>
8 dpavlin 72
9     my $u = Jifty->web->current_user;
10    
11     warn "user->id: ", $u->id, " ", $u->admin ? 'admin' : '', "\n";
12    
13     use Data::Dumper;
14     warn Dumper( $u->admin );
15    
16 dpavlin 37 my $transports = Transports::Model::TransportCollection->new();
17 dpavlin 43 if (Jifty->web->current_user->admin) {
18     $transports->unlimit();
19 dpavlin 46 } elsif (Jifty->web->current_user->can_import) {
20     $transports->limit(
21     column => 'return_code',
22 dpavlin 59 operator => 'is',
23 dpavlin 46 value => 'null',
24     );
25 dpavlin 43 } else {
26     $transports->limit(
27     column => 'created_by',
28     value => Jifty->web->current_user->id,
29 dpavlin 46 );
30 dpavlin 43 }
31 dpavlin 74 $transports->order_by({ column => $order });
32 dpavlin 37 $transports->set_page_info(
33     current_page => $page,
34 dpavlin 69 per_page => 10,
35 dpavlin 37 );
36 dpavlin 46 if (my $nr = $transports->pager->total_entries) {
37     $m->out("Showing $nr transports.")
38 dpavlin 69
39 dpavlin 48 } elsif ( Jifty->web->current_user->can_import ) {
40     $m->out("No transports waiting for import.");
41 dpavlin 46 } else {
42     $m->out("No transports found.")
43     }
44 dpavlin 74
45 dpavlin 37 </%init>
46    
47 dpavlin 69 <% Jifty->web->link(
48     label => ( $show_description ? 'no ' : '' ) . ' description',
49     onclick => {
50     replace_with => '/transports/table',
51     args => { show_description => $show_description ? 0 : 1 },
52     }
53     ) %>
54    
55     <% Jifty->web->link(
56     label => ( $show_comment ? 'no ' : '' ) . ' import comment',
57     onclick => {
58     replace_with => '/transports/table',
59     args => { show_comment => $show_comment ? 0 : 1 },
60     }
61     ) %>
62    
63 dpavlin 72 <%perl>
64     use Data::Dumper;
65     my $t = $transports->first;
66     $transports->goto_first_item;
67     warn Dumper( $t->id );
68 dpavlin 74
69     sub th {
70     my ($label, $this_order, $order) = @_;
71     warn "order: $order this_order: $this_order\n";
72     if ($order eq $this_order) {
73     return $label;
74     } else {
75     return Jifty->web->link(
76     label => $label,
77     onclick => {
78     args => { order => $this_order },
79     }
80     );
81     }
82     }
83    
84 dpavlin 72 </%perl>
85    
86 dpavlin 37 <table>
87     <tr>
88 dpavlin 74 <th><% th('src','source',$order) %></th>
89     <th><% th('dest','destination',$order) %></th>
90     <th><% th('class','class',$order) %></th>
91     <th><% th('req.nr','request_nr',$order) %></th>
92     <th><% th('dep','client_dependent',$order) %></th>
93     <th><% th('created by','created_by',$order) %></th>
94 dpavlin 69 % if ($show_description) {
95 dpavlin 45 <th>description</th>
96 dpavlin 69 % }
97 dpavlin 74 <th><% th('import','return_code',$order) %></th>
98 dpavlin 69 % if ($show_comment) {
99     <th>comment</th>
100     % }
101     </th>
102 dpavlin 43 % if (Jifty->web->current_user->admin) {
103 dpavlin 37 <th>&nbsp;</th>
104 dpavlin 43 % }
105 dpavlin 37 </tr>
106    
107 dpavlin 72 % my $i = 0; $transports->goto_first_item;
108 dpavlin 37 % while (my $t = $transports->next) {
109 dpavlin 69
110 dpavlin 37 <tr class="<% ++$i % 2 == 0 ? 'alt' : '' %>">
111     <td><% $t->source->name %></td>
112     <td><% $t->destination->name %></td>
113 dpavlin 45 <td><% $t->class->name %></td>
114 dpavlin 37 <td><tt><% $t->request_nr %></tt></td>
115     <td>
116     <% $t->client_dependent ? 'client' : 'none' %>
117     </td>
118 dpavlin 59 <td><em><% $t->created_by->name %></em></td>
119 dpavlin 69 % if ($show_description) {
120 dpavlin 72 <td><% $t->description || '' %></td>
121 dpavlin 69 % }
122 dpavlin 46 <td>
123 dpavlin 69 % if ($t->return_code && $t->return_code->name) {
124 dpavlin 46 <% $t->return_code->name %>
125     % } elsif (Jifty->web->current_user->can_import) {
126 dpavlin 69 <% Jifty->web->link( label => 'import', onclick => {
127     replace_with => '/transports/import',
128     args => { id => $t->id },
129     } ) %>
130 dpavlin 46 % } else {
131     pending
132     % }
133     </td>
134 dpavlin 69 % if ($show_comment) {
135 dpavlin 72 <td><% $t->comment || '' %></td>
136 dpavlin 69 % }
137 dpavlin 45 % if (Jifty->web->current_user->admin) {
138 dpavlin 69 <td><% Jifty->web->link( label => 'edit', onclick => {
139     replace_with => '/transports/edit',
140     args => { id => $t->id },
141     } ) %></td>
142 dpavlin 45 % }
143 dpavlin 37 </tr>
144     % }
145     </table>
146    
147     % if ($transports->pager->previous_page) {
148     <% Jifty->web->link(
149 dpavlin 69 label => "Previous",
150 dpavlin 37 onclick => { args => { page => $transports->pager->previous_page } }
151     ) %>
152     % }
153    
154     % if ($transports->pager->last_page > 1) {
155     page <% $page %> of <% $transports->pager->last_page %>
156     % }
157    
158     % if ($transports->pager->next_page) {
159     <% Jifty->web->link(
160 dpavlin 69 label => "Next",
161 dpavlin 37 onclick => { args => { page => $transports->pager->next_page } }
162     ) %>
163     % }
164    

  ViewVC Help
Powered by ViewVC 1.1.26