/[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 72 - (hide 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 dpavlin 37 <%args>
2     $page => 1
3 dpavlin 69 $show_description => 0
4     $show_comment => 0
5 dpavlin 37 </%args>
6     <%init>
7 dpavlin 72
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 dpavlin 37 my $transports = Transports::Model::TransportCollection->new();
16 dpavlin 43 if (Jifty->web->current_user->admin) {
17     $transports->unlimit();
18 dpavlin 46 } elsif (Jifty->web->current_user->can_import) {
19     $transports->limit(
20     column => 'return_code',
21 dpavlin 59 operator => 'is',
22 dpavlin 46 value => 'null',
23     );
24 dpavlin 43 } else {
25     $transports->limit(
26     column => 'created_by',
27     value => Jifty->web->current_user->id,
28 dpavlin 46 );
29 dpavlin 43 }
30 dpavlin 37 $transports->order_by({ column => 'date' });
31     $transports->set_page_info(
32     current_page => $page,
33 dpavlin 69 per_page => 10,
34 dpavlin 37 );
35 dpavlin 46 if (my $nr = $transports->pager->total_entries) {
36     $m->out("Showing $nr transports.")
37 dpavlin 69
38 dpavlin 48 } elsif ( Jifty->web->current_user->can_import ) {
39     $m->out("No transports waiting for import.");
40 dpavlin 46 } else {
41     $m->out("No transports found.")
42     }
43 dpavlin 37 </%init>
44    
45 dpavlin 69 <% 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 dpavlin 72 <%perl>
62     use Data::Dumper;
63     my $t = $transports->first;
64     $transports->goto_first_item;
65     warn Dumper( $t->id );
66     </%perl>
67    
68 dpavlin 37 <table>
69     <tr>
70 dpavlin 45 <th>src</th>
71     <th>dest</th>
72     <th>class</th>
73     <th>req.nr</th>
74     <th>dep</th>
75 dpavlin 37 <th>created by</th>
76 dpavlin 69 % if ($show_description) {
77 dpavlin 45 <th>description</th>
78 dpavlin 69 % }
79 dpavlin 46 <th>import</th>
80 dpavlin 69 % if ($show_comment) {
81     <th>comment</th>
82     % }
83     </th>
84 dpavlin 43 % if (Jifty->web->current_user->admin) {
85 dpavlin 37 <th>&nbsp;</th>
86 dpavlin 43 % }
87 dpavlin 37 </tr>
88    
89 dpavlin 72 % my $i = 0; $transports->goto_first_item;
90 dpavlin 37 % while (my $t = $transports->next) {
91 dpavlin 69
92 dpavlin 37 <tr class="<% ++$i % 2 == 0 ? 'alt' : '' %>">
93     <td><% $t->source->name %></td>
94     <td><% $t->destination->name %></td>
95 dpavlin 45 <td><% $t->class->name %></td>
96 dpavlin 37 <td><tt><% $t->request_nr %></tt></td>
97     <td>
98     <% $t->client_dependent ? 'client' : 'none' %>
99     </td>
100 dpavlin 59 <td><em><% $t->created_by->name %></em></td>
101 dpavlin 69 % if ($show_description) {
102 dpavlin 72 <td><% $t->description || '' %></td>
103 dpavlin 69 % }
104 dpavlin 46 <td>
105 dpavlin 69 % if ($t->return_code && $t->return_code->name) {
106 dpavlin 46 <% $t->return_code->name %>
107     % } elsif (Jifty->web->current_user->can_import) {
108 dpavlin 69 <% Jifty->web->link( label => 'import', onclick => {
109     replace_with => '/transports/import',
110     args => { id => $t->id },
111     } ) %>
112 dpavlin 46 % } else {
113     pending
114     % }
115     </td>
116 dpavlin 69 % if ($show_comment) {
117 dpavlin 72 <td><% $t->comment || '' %></td>
118 dpavlin 69 % }
119 dpavlin 45 % if (Jifty->web->current_user->admin) {
120 dpavlin 69 <td><% Jifty->web->link( label => 'edit', onclick => {
121     replace_with => '/transports/edit',
122     args => { id => $t->id },
123     } ) %></td>
124 dpavlin 45 % }
125 dpavlin 37 </tr>
126     % }
127     </table>
128    
129     % if ($transports->pager->previous_page) {
130     <% Jifty->web->link(
131 dpavlin 69 label => "Previous",
132 dpavlin 37 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 dpavlin 69 label => "Next",
143 dpavlin 37 onclick => { args => { page => $transports->pager->next_page } }
144     ) %>
145     % }
146    

  ViewVC Help
Powered by ViewVC 1.1.26