/[Arh]/lib/Arh/View/Units.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

Annotation of /lib/Arh/View/Units.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (hide annotations)
Fri Nov 30 16:46:39 2007 UTC (16 years, 4 months ago) by dpavlin
File size: 1117 byte(s)
refactor unit around Jifty::View::Declare::CRUD
1 dpavlin 15 package Arh::View::Units;
2    
3     use strict;
4     use warnings;
5    
6     use base 'Jifty::View::Declare::CRUD';
7     use Jifty::View::Declare -base;
8    
9     sub object_type { 'Unit' };
10    
11     #private template search_region => sub {};
12    
13     template 'view' => sub :CRUDView {
14     my $self = shift;
15     my $record = $self->_get_record( get('id') );
16    
17     my $update = $record->as_update_action(
18     moniker => "update-" . Jifty->web->serial,
19     );
20    
21     my $can_write = $record->current_user_can('write');
22     #warn "write ",$can_write ? 'ok' : 'DENIED';
23    
24     form {
25     foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) {
26     if ( $f eq 'material' ) {
27     set( search_collection => $record->material );
28     render_region(
29     name => 'unit-materials',
30     path => '/materials/list',
31     defaults => {
32     page => 1,
33     unit => $record->id,
34     }
35     );
36     } else {
37     my %opt;
38     $opt{render_mode} = 'read' if ! $can_write;
39     render_param( $update => $f, %opt );
40     }
41     };
42     hyperlink(
43     label => _('Update'),
44     onclick => {
45     submit => $update,
46     refresh_self => 1,
47     },
48     ) if $can_write;
49     };
50     hr {};
51     };
52    
53     1;

  ViewVC Help
Powered by ViewVC 1.1.26