/[transports]/trunk/web/templates/fragments/user_on_landscape
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/fragments/user_on_landscape

Parent Directory Parent Directory | Revision Log Revision Log


Revision 60 - (hide annotations)
Thu Jun 8 11:44:26 2006 UTC (17 years, 11 months ago) by dpavlin
File size: 1402 byte(s)
much better interface for editing landscapes for user
1 dpavlin 51 <%args>
2     $user_id
3     $delete_user_on_landscape_id => 0
4 dpavlin 60 $add_user_to_landscape_id => 0
5 dpavlin 51 </%args>
6     <%init>
7    
8     if ($delete_user_on_landscape_id) {
9     my $u = Transports::Model::UserOnLandscape->new();
10 dpavlin 60 $u->load_by_cols(
11     user_on => $user_id,
12     landscape => $delete_user_on_landscape_id
13     );
14     # $m->out("Deleted ", $u->landscape->name);
15 dpavlin 51 $u->delete;
16     }
17    
18 dpavlin 60 if ($add_user_to_landscape_id) {
19     my $u = Transports::Model::UserOnLandscape->new();
20     $u->create(
21     user_on => $user_id,
22     landscape => $add_user_to_landscape_id,
23     );
24     # $m->out("Added ", $u->landscape->name);
25     }
26    
27 dpavlin 51 my $landscapes = Transports::Model::UserOnLandscapeCollection->new();
28     $landscapes->limit(
29     column => 'user_on',
30     value => $user_id,
31     quote_value => 0,
32     );
33    
34 dpavlin 60 my $selected_landscape;
35     map { $selected_landscape->{ $_->landscape->id }++ } @{ $landscapes->items_array_ref };
36    
37     warn "selected_lanscape: ",Dumper( $selected_landscape );
38    
39     my $all_landscapes = Transports::Model::LandscapeCollection->new();
40     $all_landscapes->unlimit;
41    
42 dpavlin 51 </%init>
43    
44 dpavlin 60 <div>
45 dpavlin 51 Landscapes:
46 dpavlin 60
47 dpavlin 51 <ul>
48 dpavlin 60 % while (my $l = $all_landscapes->next ) {
49     <li>
50     % if ($selected_landscape->{ $l->id }) {
51     <% $l->name %>
52 dpavlin 51 <% Jifty->web->link(
53     label => 'remove' ,
54 dpavlin 60 onclick => { args => { delete_user_on_landscape_id => $l->id }}
55 dpavlin 51 ) %>
56 dpavlin 60 % } else {
57     <del><% $l->name %></del>
58     <% Jifty->web->link(
59     label => 'add' ,
60     onclick => { args => { add_user_to_landscape_id => $l->id }}
61     ) %>
62     % }
63 dpavlin 51 </li>
64     % }
65     </ul>
66    
67 dpavlin 60 </div>
68 dpavlin 51

  ViewVC Help
Powered by ViewVC 1.1.26