--- lib/Arh/View.pm 2007/11/29 12:36:51 6 +++ lib/Arh/View.pm 2007/11/29 19:32:41 12 @@ -8,61 +8,66 @@ use Data::Dump qw/dump/; template '/pictures' => page { - h1 { _("Pictures available in system") }; my $fc = Arh::Model::PictureCollection->new; $fc->unlimit; my $present; form { + if ( $fc->count ) { + h1 { _("Pictures available in system") }; + } table { - row { - cell { _('Part of campaign') } - cell { _('Picture filename') } - cell { _('Type of picture') } - cell {} - }; while ( my $f = $fc->next ) { $present->{ $f->filename }++; my $delete = new_action( class => 'DeletePicture' ); + my $update = new_action( class => 'UpdatePicture', record => $f ); row { - cell { $f->campaign->name } cell { + attr { class => 'picture' }; img { attr { src => "static/pics/" . $f->filename } } div { tt{ $f->filename } } } - cell { $f->type->name } cell { - $delete->button( - submit => $delete, - label => _('Delete'), - arguments => { - id => $f->id, + attr { class => 'picture-description' }; + render_param( $update => 'campaign', render_mode => 'read' ); + render_param( $update => 'type', render_mode => 'read' ); + if ( $f->current_user_can('write') ) { + div { + $delete->button( + submit => $delete, + label => _('Delete'), + arguments => { + id => $f->id, + } + ) } - ) + } } } } row { - cell { attr { colspan => 4 } outs _('Pending pictures') } + cell { attr { colspan => 2 } h1 { _('Pending pictures') } } }; warn "## present = ",dump( $present ); foreach my $f ( Arh::Model::Picture->all_filenames ) { next if $present->{$f}; my $create = new_action( class => 'CreatePicture' ); row { - cell { render_param( $create => 'campaign' ) } cell { + attr { class => 'picture' }; img { attr { src => "static/pics/$f" } } div { tt{ $f } } } - cell { render_param( $create => 'type' ) } cell { + attr { class => 'picture-description' }; + render_param( $create => 'campaign' ); + render_param( $create => 'type' ); $create->button( submit => $create, label => _('Add'), arguments => { filename => $f, } - ) + ); } } } @@ -71,4 +76,37 @@ }; +template '/units' => page { + h1 { _("Units available in system") }; + + my $units = Arh::Model::UnitCollection->new; + $units->unlimit; + + while ( my $u = $units->next ) { + unit( $u ); + } +}; + +sub unit { + my $unit = shift || die "no unit?"; + my $a = new_action( class => 'UpdateUnit', record => $unit ); + warn "## current_user = ",dump( current_user ); + form { + foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) { + if ( $f eq 'material' ) { + my $material = $unit->material; + while ( my $um = $material->next ) { + my $m = new_action( class => 'UpdateMaterial', record => $um->material ); + render_param( $m => 'name', label => _("Material"), render_mode => 'read' ); + } + } else { + my %opt; + $opt{render_mode} = 'read'; # unless + warn "write $f ",$unit->current_user_can('write',$f) ? 'ok' : 'DENIED'; + render_param( $a => $f, %opt ); + } + } + } +} + 1;