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

  ViewVC Help
Powered by ViewVC 1.1.26