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

  ViewVC Help
Powered by ViewVC 1.1.26