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

  ViewVC Help
Powered by ViewVC 1.1.26