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

Diff of /lib/Arh/View.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 13 by dpavlin, Fri Nov 30 00:03:15 2007 UTC revision 19 by dpavlin, Fri Nov 30 17:36:21 2007 UTC
# Line 14  template '/pictures' => page { Line 14  template '/pictures' => page {
14          form {          form {
15                  if ( $fc->count ) {                  if ( $fc->count ) {
16                          h1 { _("Pictures available in system") };                          h1 { _("Pictures available in system") };
17                    } else {
18                            span { outs _("No pubicly available pictures at this time...") }
19                  }                  }
20                  table {                  table {
21                          while ( my $f = $fc->next ) {                          while ( my $f = $fc->next ) {
# Line 79  template '/pictures' => page { Line 81  template '/pictures' => page {
81    
82  };  };
83    
84    use Jifty::View::Declare::CRUD;
85    Jifty::View::Declare::CRUD->mount_view('materials');
86    
87    use Jifty::View::Declare::CRUD;
88    Jifty::View::Declare::CRUD->mount_view('units');
89    
90  template '/units' => page {  template '/units' => page {
91          h1 { _("Units available in system") };          h1 { _("Units available in system") };
92    
93          my $units = Arh::Model::UnitCollection->new;          my $search = Arh::Model::UnitCollection->new;
94          $units->unlimit;          $search->unlimit;
95    
96          while ( my $u = $units->next ) {          set( search_collection => $search );
97                  unit( $u );          render_region(
98          }                  name => 'units',
99  };                  path => '/units/list',
100                    defaults => {
101  sub unit {                          page => 1,
         my $unit = shift || die "no unit?";  
         my $a = new_action( class => 'UpdateUnit', record => $unit );  
         form {  
                 foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) {  
                         my $can_write = $unit->current_user_can('write',$f);  
                         #warn "write $f ",$can_write ? 'ok' : 'DENIED';  
                         if ( $f eq 'material' ) {  
                                 set( UnitMaterialCollection => $unit->material );  
                                 show( '/unit/materials' );  
                         } else {  
                                 my %opt;  
                                 $opt{render_mode} = 'read' if ! $unit->current_user_can('write',$f);  
                                 render_param( $a => $f, %opt );  
                         }  
102                  }                  }
103          }          );
 }  
   
 template '/unit/materials' => sub {  
         my $materials = get('UnitMaterialCollection');  
         my $del_um = new_action( class => 'DeleteUnitMaterial', moniker => 'del_um' );  
         my $new_um = new_action( class => 'CreateUnitMaterial', moniker => 'new_um' );  
         my $can_write;  
         while ( my $um = $materials->next ) {  
                 div { attr { class is 'form_field' }  
                         span {  
                                 span { attr { class is 'label' } _("Material") };  
                                 span { $um->material->name };  
                   
                                 $can_write ||= $um->current_user_can('write');  
                                 if ( $can_write ) {  
                                         outs_raw($del_um->button(  
                                                 submit => $del_um,  
                                                 label => _('Delete'),  
                                                 arguments => {  
                                                         unit => $um->unit,  
                                                         material => $um->material  
                                                 },  
                                         ));  
                                 }  
                         }  
                 };  
104    
                 if ( $can_write ) {  
                         render_param(  
                                 $new_um => 'material', label => _("Material"),  
                                 render_as => 'Arh::Web::Material',  
                                 # cludge to transfer arguments  
                                 hints => {  
                                         unit => $um->unit,  
                                 },  
                         );  
                 }  
         }  
105  };  };
106    
107  1;  1;

Legend:
Removed from v.13  
changed lines
  Added in v.19

  ViewVC Help
Powered by ViewVC 1.1.26