/[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 51 by dpavlin, Sun Apr 6 18:31:14 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 65  template 'view' => sub :CRUDView { Line 65  template 'view' => sub :CRUDView {
65    
66          form {          form {
67                  if ( $record->current_user_can('delete') && $self->current_user->editing ) {                  if ( $record->current_user_can('delete') && $self->current_user->editing ) {
68                          hyperlink(                          outs_raw( $delete->button(
69                                  label   => _("Delete picture"),                                  label   => _("Delete picture"),
70                                  class   => "float-crud-button button-delete",                                  class   => "float-crud-button button-delete",
71                                  onclick => {                                  onclick => {
# Line 75  template 'view' => sub :CRUDView { Line 75  template 'view' => sub :CRUDView {
75                                          refresh_self => 1,                                          refresh_self => 1,
76                                          args => { id => $id },                                          args => { id => $id },
77                                  },                                  },
78                                  as_button => 1,                          ));
                         );  
79                  };                  };
80                  img { attr { src => "/static/pics/" . $record->picture->filename } }                  img { attr { src => "/pictures/show/" . $record->filename } }
81                  tt{ $record->picture->filename }                  tt{ $record->filename }
82          };          };
83    
84  };  };
# Line 89  template 'new_picture' => sub { Line 88  template 'new_picture' => sub {
88          return unless $self->current_user->editing;          return unless $self->current_user->editing;
89    
90          my ( $id, $unit ) = get(qw(id unit));          my ( $id, $unit ) = get(qw(id unit));
91            warn "## new_picture id: $id unit: $unit";
92    
93          my $record_class = $self->record_class;          my $record_class = $self->record_class;
94            warn "## new_picture record_class: $record_class\n";
95          my $create = $record_class->as_create_action(          my $create = $record_class->as_create_action(
96                  moniker => "create-" . Jifty->web->serial,                  moniker => "create-" . Jifty->web->serial,
97          );          );
         warn "## unit $unit";  
98    
99          my $attach_to =          my $attach_to =
100                  Jifty->web->current_region->parent ?                  Jifty->web->current_region->parent ?
# Line 103  template 'new_picture' => sub { Line 104  template 'new_picture' => sub {
104          warn "## attach_to = $attach_to";          warn "## attach_to = $attach_to";
105    
106      form {      form {
107                  render_param($create => 'picture');                  render_action( $create => [ 'campaign', 'content', 'type' ] );
                 outs_raw( $create->hidden( unit => $unit ) );  
108                  hyperlink(                  hyperlink(
109                          label   => _("Add picture"),                          label   => _("Add picture"),
110                          class   => "float-crud-button button-add",                          class   => "float-crud-button button-add",
111                          onclick => [                          onclick => [
112                                  {                                  {
113                                          submit => $create,                                          submit => $create,
114                                            args => {
115                                                    unit => $unit,
116                                            }
117                                  },                                  },
118                                  {       refresh_self => 1       },                                  {       refresh_self => 1       },
119                                  {                                  {
# Line 131  template 'new_picture' => sub { Line 134  template 'new_picture' => sub {
134  template 'fragment' => sub {  template 'fragment' => sub {
135          my ( $self, $unit ) = @_;          my ( $self, $unit ) = @_;
136    
137          warn "## unit = ", dump( $unit );          #warn "## unit = ", dump( $unit );
138    
139          my $unitpictures = Arh::Model::UnitPictureCollection->new;          my $unitpictures = Arh::Model::PictureCollection->new;
140          $unitpictures->limit( column => 'unit', value => $unit->id );          $unitpictures->limit( column => 'unit', value => $unit->id );
141          warn "## ", $unitpictures->count, " pictures for unit ",$unit->id;          warn "## ", $unitpictures->count, " pictures for unit ",$unit->id;
142    
143          div {          div {
144                  { class is 'pictures-by-unit' };                  { class is 'pictures-by-unit' };
           
                 em { 'pictures for unit ', $unit->name };  
145    
146                  set( search_collection => $unitpictures );                  if ( $unitpictures->count ) {
147                  render_region(                          em { _('Pictures for unit'), ' ', $unit->name };
148                          name => 'unit-pictures',  
149                          path => '/unitpictures/list',                          set( search_collection => $unitpictures );
150                          defaults => {                          render_region(
151                                  page => 1,                                  name => 'unit-pictures',
152                                  unit => $unit->id,                                  path => '/unitpictures/list',
153                          }                                  defaults => {
154                  );                                          page => 1,
155                                            unit => $unit->id,
156                                    }
157                            );
158    
159                    } else {
160                            em { _('No pictures for unit'), ' ', $unit->name };
161                    }
162    
163          }          }
164  };  };
165    

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

  ViewVC Help
Powered by ViewVC 1.1.26