/[Arh]/lib/Arh/View/UnitPictures.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/UnitPictures.pm

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

revision 30 by dpavlin, Mon Dec 10 15:51:52 2007 UTC revision 73 by dpavlin, Fri Apr 11 18:22:10 2008 UTC
# Line 8  use Jifty::View::Declare -base; Line 8  use Jifty::View::Declare -base;
8    
9  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
10    
11  sub object_type { 'UnitPicture' };  sub object_type { 'Picture' };
12    
13  private template search_region => sub {};  private template search_region => sub {};
14  private template 'no_items_found' => sub {};  private template 'no_items_found' => sub {};
# Line 31  template 'list' => sub { Line 31  template 'list' => sub {
31          my $fragment_for_new_picture = $self->fragment_for('new_picture');          my $fragment_for_new_picture = $self->fragment_for('new_picture');
32      my $collection =  $self->_current_collection();      my $collection =  $self->_current_collection();
33          # XXX show just pictures from current unit          # XXX show just pictures from current unit
34          $collection->limit( column => 'unit', value => $unit ) if $unit;          $collection->limit( column => 'unit', value => $unit );
35    
36            warn "## list page: $page unit: $unit fragment_for_new_picture: $fragment_for_new_picture item_path: $item_path";
37    
38      div {      div {
39                  { class is 'pictures' };                  { class is 'pictures' };
40    
# Line 61  template 'view' => sub :CRUDView { Line 64  template 'view' => sub :CRUDView {
64                  moniker => "delete-" . Jifty->web->serial,                  moniker => "delete-" . Jifty->web->serial,
65          );          );
66    
67          warn "## id: $id unit $unit";          warn "## view id: $id unit $unit";
68    
69          form {          form {
70                    { class is 'single-picture' };
71    
72                  if ( $record->current_user_can('delete') && $self->current_user->editing ) {                  if ( $record->current_user_can('delete') && $self->current_user->editing ) {
73                          outs_raw( $delete->button(                          outs_raw( $delete->button(
74                                  label   => _("Delete picture"),                                  label   => _("Delete picture"),
# Line 77  template 'view' => sub :CRUDView { Line 82  template 'view' => sub :CRUDView {
82                                  },                                  },
83                          ));                          ));
84                  };                  };
85                  img { attr { src => "/static/pics/" . $record->picture->filename } }  
86                  tt{ $record->picture->filename }                  img { attr { src => "/static/pics/thumb/" . $record->thumbnail } };
87                    span { $record->type->name };
88                    tt { $record->filename };
89    
90          };          };
91    
92  };  };
# Line 88  template 'new_picture' => sub { Line 96  template 'new_picture' => sub {
96          return unless $self->current_user->editing;          return unless $self->current_user->editing;
97    
98          my ( $id, $unit ) = get(qw(id unit));          my ( $id, $unit ) = get(qw(id unit));
99            warn "## new_picture id: $id unit: $unit";
100    
101          my $record_class = $self->record_class;          my $record_class = $self->record_class;
102          my $create = $record_class->as_create_action(          warn "## new_picture record_class: $record_class\n";
103    #       my $create = $record_class->as_create_action(
104            my $create = new_action(
105                    class => 'UploadPicture',
106                  moniker => "create-" . Jifty->web->serial,                  moniker => "create-" . Jifty->web->serial,
107          );          );
         warn "## unit $unit";  
108    
109          my $attach_to =          my $attach_to =
110                  Jifty->web->current_region->parent ?                  Jifty->web->current_region->parent ?
# Line 101  template 'new_picture' => sub { Line 113  template 'new_picture' => sub {
113    
114          warn "## attach_to = $attach_to";          warn "## attach_to = $attach_to";
115    
116      form {      div {
117                  render_param($create => 'picture');                  render_action( $create => [ 'campaign', 'content', 'type' ] );
118                  outs_raw( $create->hidden( unit => $unit ) );                  outs_raw( $create->hidden( unit => $unit ) );
119                    form_submit( label => _('Add picture') );
120    =for firefox-only
121                  hyperlink(                  hyperlink(
122                          label   => _("Add picture"),                          label   => _("Add picture"),
123                          class   => "float-crud-button button-add",                          class   => "float-crud-button button-add",
# Line 124  template 'new_picture' => sub { Line 138  template 'new_picture' => sub {
138                          ],                          ],
139                          as_button => 1,                          as_button => 1,
140                  );                  );
141    =cut
142      };      };
143  };  };
144    
# Line 132  template 'fragment' => sub { Line 147  template 'fragment' => sub {
147    
148          #warn "## unit = ", dump( $unit );          #warn "## unit = ", dump( $unit );
149    
150          my $unitpictures = Arh::Model::UnitPictureCollection->new;          my $unitpictures = Arh::Model::PictureCollection->new;
151          $unitpictures->limit( column => 'unit', value => $unit->id );          $unitpictures->limit( column => 'unit', value => $unit->id );
152          warn "## ", $unitpictures->count, " pictures for unit ",$unit->id;          warn "## ", $unitpictures->count, " pictures for unit ",$unit->id;
153    
154          div {          div {
155                  { class is 'pictures-by-unit' };                  { class is 'pictures-by-unit' };
156            
157                  em { 'pictures for unit ', $unit->name };                  if ( $unitpictures->count ) {
158                            em { _('Pictures for unit'), ' ', $unit->name };
159    
160                    } else {
161                            em { _('No pictures for unit'), ' ', $unit->name };
162                    }
163    
164                  set( search_collection => $unitpictures );                  set( search_collection => $unitpictures );
165    
166                  render_region(                  render_region(
167                          name => 'unit-pictures',                          name => 'unit-pictures',
168                          path => '/unitpictures/list',                          path => '/unitpictures/list',
# Line 150  template 'fragment' => sub { Line 171  template 'fragment' => sub {
171                                  unit => $unit->id,                                  unit => $unit->id,
172                          }                          }
173                  );                  );
174    
175          }          }
176  };  };
177    

Legend:
Removed from v.30  
changed lines
  Added in v.73

  ViewVC Help
Powered by ViewVC 1.1.26