/[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

Contents of /trunk/web/templates/transports/table

Parent Directory Parent Directory | Revision Log Revision Log


Revision 97 - (show 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 <%args>
2 $page => 1
3 $show_description => 0
4 $show_comment => 0
5 $show_imported => 0
6 $order => 'date'
7 </%args>
8 <%init>
9
10 my $u = Jifty->web->current_user;
11
12 # warn "user->id: ", $u->id, " ", $u->admin ? 'admin' : '', "\n";
13
14 my $transports = Transports::Model::TransportCollection->new();
15 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 } else {
26 $transports->limit(
27 column => 'created_by',
28 value => Jifty->web->current_user->id,
29 );
30 }
31 $transports->order_by({ column => $order });
32 $transports->set_page_info(
33 current_page => $page,
34 per_page => 10,
35 );
36 if (my $nr = $transports->pager->total_entries) {
37 $m->out("Showing $nr transports.")
38
39 } elsif ( Jifty->web->current_user->can_import ) {
40 $m->out("No transports waiting for import.");
41 } else {
42 $m->out("No transports found.")
43 }
44
45 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 </%init>
58
59 <% 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
65 <%perl>
66
67 sub th {
68 my ($label, $this_order, $order) = @_;
69 # warn "order: $order this_order: $this_order\n";
70 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 </%perl>
83
84 <table>
85 <tr>
86 <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 % if ($show_description) {
93 <th>description</th>
94 % }
95 <th><% th('import','return_code',$order) %></th>
96 % if ($show_comment) {
97 <th>comment</th>
98 % }
99 </th>
100 % if (Jifty->web->current_user->admin) {
101 <th>&nbsp;</th>
102 % }
103 </tr>
104
105 % my $i = 0; $transports->goto_first_item;
106 % while (my $t = $transports->next) {
107
108 <tr class="<% ++$i % 2 == 0 ? 'alt' : '' %>">
109 <td><% $t->source->name %></td>
110 <td><% $t->destination->name %></td>
111 <td><% $t->class->name %></td>
112 <td><tt><% $t->request_nr %></tt></td>
113 <td>
114 <% $t->client_dependent ? 'client' : 'none' %>
115 </td>
116 <td><em><% $t->created_by->name %></em></td>
117 % if ($show_description) {
118 <td><% $t->description || '' %></td>
119 % }
120 <td>
121 % if ($t->return_code && $t->return_code->name) {
122 <% $t->return_code->name %>
123 % } elsif (Jifty->web->current_user->can_import) {
124 <% Jifty->web->link( label => 'import', onclick => {
125 replace_with => '/transports/import',
126 args => { id => $t->id },
127 } ) %>
128 % } else {
129 pending
130 % }
131 </td>
132 % if ($show_comment) {
133 <td><% $t->comment || '' %></td>
134 % }
135 % if (Jifty->web->current_user->admin) {
136 <td><% Jifty->web->link( label => 'edit', onclick => {
137 replace_with => '/transports/edit',
138 args => { id => $t->id },
139 } ) %></td>
140 % }
141 </tr>
142 % }
143 </table>
144
145 % if ($transports->pager->previous_page) {
146 <% Jifty->web->link(
147 label => "Previous",
148 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 label => "Next",
159 onclick => { args => { page => $transports->pager->next_page } }
160 ) %>
161 % }
162

  ViewVC Help
Powered by ViewVC 1.1.26