/[Arh]/lib/Arh/View.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Arh/View.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 55 by dpavlin, Sun Apr 6 21:07:20 2008 UTC revision 80 by dpavlin, Sat Apr 19 23:07:08 2008 UTC
# Line 8  use Jifty::View::Declare -base; Line 8  use Jifty::View::Declare -base;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9    
10  use Jifty::View::Declare::CRUD;  use Jifty::View::Declare::CRUD;
11  Jifty::View::Declare::CRUD->mount_view('materials');  Jifty::View::Declare::CRUD->mount_view('Materials');
12  Jifty::View::Declare::CRUD->mount_view('UnitPictures');  Jifty::View::Declare::CRUD->mount_view('UnitPictures');
13  Jifty::View::Declare::CRUD->mount_view('units');  Jifty::View::Declare::CRUD->mount_view('Units');
14    Jifty::View::Declare::CRUD->mount_view('Units', 'Arh::View::Units', '/units/bulk' );
15  #Jifty::View::Declare::CRUD->mount_view('locations');  #Jifty::View::Declare::CRUD->mount_view('locations');
16    
17  template '/units' => page {  template '/units' => page {
# Line 27  template '/units' => page { Line 28  template '/units' => page {
28                  path => '/units/list',                  path => '/units/list',
29                  defaults => {                  defaults => {
30                          page => 1,                          page => 1,
31                            per_page => get('per_page'),
32                  }                  }
33          );          );
34    
# Line 35  template '/units' => page { Line 37  template '/units' => page {
37  template 'toggle_edit' => sub {  template 'toggle_edit' => sub {
38          my $self = shift;          my $self = shift;
39    
40            # don't show editing for anonymous users
41            return unless $self->current_user->id;
42    
43          my $toggleedit = new_action(          my $toggleedit = new_action(
44                  class => 'ToggleEdit',                  class => 'ToggleEdit',
45  #               moniker => 'toggle-edit',  #               moniker => 'toggle-edit',
# Line 65  template 'raw_pic' => sub { Line 70  template 'raw_pic' => sub {
70          }          }
71  };  };
72    
73    template '/index.html' => page {
74            my $units = Arh::Model::UnitCollection->new;
75            $units->unlimit;
76            $units->order_by( column => 'id', order => 'DESC' );
77    
78            my $last = get('last') || 15;
79    
80            h1 { _("Last %1 units entered", $last) };
81    
82            div {
83                    outs _('Limit:');
84                    foreach my $new_last ( 15, 50, 100 ) {
85                            outs_raw ' ';
86                            if ( $new_last == $last ) {
87                                    b { $new_last }
88                            } else {
89                                    hyperlink(
90                                            label => $new_last,
91                                            url => '/?last=' . $new_last,
92                                    );
93                            }
94                    }
95            }
96    
97            ol {
98                    class is 'units';
99                    for ( 1 .. $last ) {
100                            my $unit = $units->next || last;
101                            li {
102                                    div {
103                                            outs( $unit->name, ' ' );
104                                            hyperlink(
105                                                    label => $unit->unit_id,
106                                                    url => '/unit/' . $unit->id,
107                                            );
108                                    }
109                                    div { class is 'unit details';
110                                            outs join(', ', grep(defined($_),
111                                                    $unit->subcategory,
112                                                    $unit->category->name,
113                                                    $unit->location->name,
114                                                    $unit->site->name,
115                                            ));
116                                    }
117                            }
118                    }
119            }
120    
121    };
122    
123  1;  1;

Legend:
Removed from v.55  
changed lines
  Added in v.80

  ViewVC Help
Powered by ViewVC 1.1.26