/[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 23 by dpavlin, Fri Nov 30 23:23:14 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;          show( 'toggle_edit' );
         $units->unlimit;  
94    
95          while ( my $u = $units->next ) {          my $search = Arh::Model::UnitCollection->new;
96                  unit( $u );          $search->unlimit;
         }  
 };  
97    
98  sub unit {          set( search_collection => $search );
99          my $unit = shift || die "no unit?";          render_region(
100          my $a = new_action( class => 'UpdateUnit', record => $unit );                  name => 'units',
101          form {                  path => '/units/list',
102                  foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) {                  defaults => {
103                          my $can_write = $unit->current_user_can('write',$f);                          page => 1,
                         #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 );  
                         }  
104                  }                  }
105          }          );
 }  
106    
107  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  
                                                 },  
                                         ));  
                                 }  
                         }  
                 };  
108    
109                  if ( $can_write ) {  private template '/toggle_edit' => sub {
110                          render_param(          my $self = shift;
111                                  $new_um => 'material', label => _("Material"),  
112                                  render_as => 'Arh::Web::Material',          # no fun for anonymous users
113                                  # cludge to transfer arguments          return unless $self->current_user->id;
114                                  hints => {  
115                                          unit => $um->unit,          render_region(
116                                  },                  name => 'toggle-edit',
117                          );                  path => '/toggle_edit_region',
118                  }          );
119    
120    };
121    
122    template 'toggle_edit_region' => sub {
123            my $self = shift;
124    
125            my $toggleedit = new_action( class => 'ToggleEdit' );
126    
127            my $label = $self->current_user->editing ? _("Disable editing") : _("Enable editing");
128    
129            warn "## $label\n";
130    
131            form {
132                    hyperlink(
133                            label => $label,
134                            onclick => {
135                                    submit => $toggleedit,
136                                    refresh_self => 1,
137                            },
138                    )
139          }          }
140    
141  };  };
142    
143  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26