/[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 28 by dpavlin, Mon Dec 10 14:56:12 2007 UTC revision 54 by dpavlin, Sun Apr 6 20:56:54 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 32  template 'list' => sub { Line 32  template 'list' => sub {
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 ) if $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                    img { attr { src => "/pictures/show/" . $record->filename } }
71                    tt { $record->filename }
72                    span { $record->type->name };
73    
74                  if ( $record->current_user_can('delete') && $self->current_user->editing ) {                  if ( $record->current_user_can('delete') && $self->current_user->editing ) {
75                          hyperlink(                          outs_raw( $delete->button(
76                                  label   => _("Delete picture"),                                  label   => _("Delete picture"),
77                                  class   => "float-crud-button button-delete",                                  class   => "float-crud-button button-delete",
78                                  onclick => {                                  onclick => {
# Line 75  template 'view' => sub :CRUDView { Line 82  template 'view' => sub :CRUDView {
82                                          refresh_self => 1,                                          refresh_self => 1,
83                                          args => { id => $id },                                          args => { id => $id },
84                                  },                                  },
85                                  as_button => 1,                          ));
                         );  
86                  };                  };
                 img { attr { src => "/static/pics/" . $record->picture->filename } }  
                 tt{ $record->picture->filename }  
87          };          };
88    
89  };  };
# Line 89  template 'new_picture' => sub { Line 93  template 'new_picture' => sub {
93          return unless $self->current_user->editing;          return unless $self->current_user->editing;
94    
95          my ( $id, $unit ) = get(qw(id unit));          my ( $id, $unit ) = get(qw(id unit));
96            warn "## new_picture id: $id unit: $unit";
97    
98          my $record_class = $self->record_class;          my $record_class = $self->record_class;
99          my $create = $record_class->as_create_action(          warn "## new_picture record_class: $record_class\n";
100    #       my $create = $record_class->as_create_action(
101            my $create = new_action(
102                    class => 'UploadPicture',
103                  moniker => "create-" . Jifty->web->serial,                  moniker => "create-" . Jifty->web->serial,
104          );          );
         warn "## unit $unit";  
105    
106          my $attach_to =          my $attach_to =
107                  Jifty->web->current_region->parent ?  #               Jifty->web->current_region->parent ?
108                  Jifty->web->current_region->parent->get_element( 'div.list' ) :  #               Jifty->web->current_region->parent->get_element( 'div.list' ) :
109                  Jifty->web->current_region;  #               Jifty->web->current_region;
110                    Jifty->web->current_region->parent->get_element( 'div.list' );
111    
112          warn "## attach_to = $attach_to";          warn "## attach_to = $attach_to";
113    
114      form {      form {
115                  render_param($create => 'picture');                  render_action( $create => [ 'campaign', 'content', 'type' ] );
116                  outs_raw( $create->hidden( unit => $unit ) );                  outs_raw( $create->hidden( unit => $unit ) );
117                  hyperlink(                  hyperlink(
118                          label   => _("Add picture"),                          label   => _("Add picture"),
# Line 131  template 'new_picture' => sub { Line 140  template 'new_picture' => sub {
140  template 'fragment' => sub {  template 'fragment' => sub {
141          my ( $self, $unit ) = @_;          my ( $self, $unit ) = @_;
142    
143          warn "## unit = ", dump( $unit );          #warn "## unit = ", dump( $unit );
144    
145          my $unitpictures = Arh::Model::UnitPictureCollection->new;          my $unitpictures = Arh::Model::PictureCollection->new;
146          $unitpictures->limit( column => 'unit', value => $unit->id );          $unitpictures->limit( column => 'unit', value => $unit->id );
147          warn "## ", $unitpictures->count, " pictures for unit ",$unit->id;          warn "## ", $unitpictures->count, " pictures for unit ",$unit->id;
148    
149          div {          div {
150                  { class is 'pictures-by-unit' };                  { class is 'pictures-by-unit' };
151            
152                  em { 'pictures for unit ', $unit->name };                  if ( $unitpictures->count ) {
153                            em { _('Pictures for unit'), ' ', $unit->name };
154    
155                    } else {
156                            em { _('No pictures for unit'), ' ', $unit->name };
157                    }
158    
159                  set( search_collection => $unitpictures );                  set( search_collection => $unitpictures );
160    
161                  render_region(                  render_region(
162                          name => 'unit-pictures',                          name => 'unit-pictures',
163                          path => '/unitpictures/list',                          path => '/unitpictures/list',
# Line 151  template 'fragment' => sub { Line 166  template 'fragment' => sub {
166                                  unit => $unit->id,                                  unit => $unit->id,
167                          }                          }
168                  );                  );
169    
170          }          }
171  };  };
172    

Legend:
Removed from v.28  
changed lines
  Added in v.54

  ViewVC Help
Powered by ViewVC 1.1.26