--- lib/Arh/View/UnitPictures.pm 2007/12/14 14:44:42 36 +++ lib/Arh/View/UnitPictures.pm 2008/04/06 20:49:32 53 @@ -8,7 +8,7 @@ use Data::Dump qw/dump/; -sub object_type { 'UnitPicture' }; +sub object_type { 'Picture' }; private template search_region => sub {}; private template 'no_items_found' => sub {}; @@ -32,6 +32,9 @@ my $collection = $self->_current_collection(); # XXX show just pictures from current unit $collection->limit( column => 'unit', value => $unit ) if $unit; + + warn "## list page: $page unit: $unit fragment_for_new_picture: $fragment_for_new_picture item_path: $item_path"; + div { { class is 'pictures' }; @@ -61,9 +64,13 @@ moniker => "delete-" . Jifty->web->serial, ); - warn "## id: $id unit $unit"; + warn "## view id: $id unit $unit"; form { + img { attr { src => "/pictures/show/" . $record->filename } } + tt { $record->filename } + span { $record->type->name }; + if ( $record->current_user_can('delete') && $self->current_user->editing ) { outs_raw( $delete->button( label => _("Delete picture"), @@ -77,8 +84,6 @@ }, )); }; - img { attr { src => "/static/pics/" . $record->picture->filename } } - tt{ $record->picture->filename } }; }; @@ -88,21 +93,26 @@ return unless $self->current_user->editing; my ( $id, $unit ) = get(qw(id unit)); + warn "## new_picture id: $id unit: $unit"; + my $record_class = $self->record_class; - my $create = $record_class->as_create_action( + warn "## new_picture record_class: $record_class\n"; +# my $create = $record_class->as_create_action( + my $create = new_action( + class => 'UploadPicture', moniker => "create-" . Jifty->web->serial, ); - warn "## unit $unit"; my $attach_to = - Jifty->web->current_region->parent ? - Jifty->web->current_region->parent->get_element( 'div.list' ) : - Jifty->web->current_region; +# Jifty->web->current_region->parent ? +# Jifty->web->current_region->parent->get_element( 'div.list' ) : +# Jifty->web->current_region; + Jifty->web->current_region->parent->get_element( 'div.list' ); warn "## attach_to = $attach_to"; form { - render_param($create => 'picture'); + render_action( $create => [ 'campaign', 'content', 'type' ] ); outs_raw( $create->hidden( unit => $unit ) ); hyperlink( label => _("Add picture"), @@ -132,7 +142,7 @@ #warn "## unit = ", dump( $unit ); - my $unitpictures = Arh::Model::UnitPictureCollection->new; + my $unitpictures = Arh::Model::PictureCollection->new; $unitpictures->limit( column => 'unit', value => $unit->id ); warn "## ", $unitpictures->count, " pictures for unit ",$unit->id; @@ -141,20 +151,21 @@ if ( $unitpictures->count ) { em { _('Pictures for unit'), ' ', $unit->name }; + + set( search_collection => $unitpictures ); + render_region( + name => 'unit-pictures', + path => '/unitpictures/list', + defaults => { + page => 1, + unit => $unit->id, + } + ); + } else { em { _('No pictures for unit'), ' ', $unit->name }; } - set( search_collection => $unitpictures ); - render_region( - name => 'unit-pictures', - path => '/unitpictures/list', - defaults => { - page => 1, - unit => $unit->id, - } - ); - } };