--- lib/Arh/View.pm 2007/11/30 16:46:39 15 +++ lib/Arh/View.pm 2008/04/06 18:31:14 51 @@ -7,13 +7,15 @@ use Data::Dump qw/dump/; -template '/pictures' => page { +template 'pictures' => page { my $fc = Arh::Model::PictureCollection->new; $fc->unlimit; my $present; form { if ( $fc->count ) { h1 { _("Pictures available in system") }; + } else { + span { outs _("No pubicly available pictures at this time...") } } table { while ( my $f = $fc->next ) { @@ -23,7 +25,7 @@ row { cell { attr { class => 'picture' }; - img { attr { src => "static/pics/" . $f->filename } } + img { attr { src => "/static/pics/" . $f->filename } } div { tt{ $f->filename } } } cell { @@ -34,7 +36,7 @@ div { $delete->button( submit => $delete, - label => _('Delete'), + label => _('Delete picture'), arguments => { id => $f->id, } @@ -56,7 +58,7 @@ row { cell { attr { class => 'picture' }; - img { attr { src => "static/pics/$f" } } + img { attr { src => "/static/pics/$f" } } div { tt{ $f } } } cell { @@ -81,9 +83,9 @@ use Jifty::View::Declare::CRUD; Jifty::View::Declare::CRUD->mount_view('materials'); - -use Jifty::View::Declare::CRUD; +Jifty::View::Declare::CRUD->mount_view('UnitPictures'); Jifty::View::Declare::CRUD->mount_view('units'); +#Jifty::View::Declare::CRUD->mount_view('locations'); template '/units' => page { h1 { _("Units available in system") }; @@ -91,6 +93,8 @@ my $search = Arh::Model::UnitCollection->new; $search->unlimit; + show( 'toggle_edit' ) if $search->count; + set( search_collection => $search ); render_region( name => 'units', @@ -102,4 +106,37 @@ }; +template 'toggle_edit' => sub { + my $self = shift; + + my $toggleedit = new_action( + class => 'ToggleEdit', +# moniker => 'toggle-edit', + ); + + my $label = $self->current_user->editing ? _("Disable editing") : _("Enable editing"); + + warn "## $label\n"; + + form { + outs_raw( $toggleedit->button( + label => $label, + submit => $toggleedit, + )); + } + +}; + +template 'raw_pic' => sub { + my $filename = get('filename') or die "no filename?"; + my $image = Arh::Model::Picture->new; + $image->load_by_cols( filename => $filename ); + if ( $image->id ) { + Jifty->handler->apache->content_type('image/jpg'); + Jifty->web->out($image->content); + } else { + die "can't find picture $filename"; + } +}; + 1;