--- lib/Arh/View.pm 2007/11/30 16:46:39 15 +++ lib/Arh/View.pm 2007/12/10 14:56:12 28 @@ -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,13 +83,15 @@ 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") }; + show( 'toggle_edit' ); + my $search = Arh::Model::UnitCollection->new; $search->unlimit; @@ -102,4 +106,38 @@ }; +private template '/toggle_edit' => sub { + my $self = shift; + + # no fun for anonymous users + return unless $self->current_user->id; + + render_region( + name => 'toggle-edit', + path => '/toggle_edit_region', + ); + +}; + +template 'toggle_edit_region' => sub { + my $self = shift; + + my $toggleedit = new_action( class => 'ToggleEdit' ); + + my $label = $self->current_user->editing ? _("Disable editing") : _("Enable editing"); + + warn "## $label\n"; + + form { + hyperlink( + label => $label, + onclick => { + submit => $toggleedit, + refresh_self => 1, + }, + ) + } + +}; + 1;