/[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 12 by dpavlin, Thu Nov 29 19:32:41 2007 UTC revision 13 by dpavlin, Fri Nov 30 00:03:15 2007 UTC
# Line 44  template '/pictures' => page { Line 44  template '/pictures' => page {
44                                          }                                          }
45                                  }                                  }
46                          }                          }
47                          row {                          warn "current_user->id: ",current_user->id;
48                                  cell { attr { colspan => 2 } h1 { _('Pending pictures') } }                          if ( current_user->id ) {
                         };  
                         warn "## present = ",dump( $present );  
                         foreach my $f ( Arh::Model::Picture->all_filenames ) {  
                                 next if $present->{$f};  
                                 my $create = new_action( class => 'CreatePicture' );  
49                                  row {                                  row {
50                                          cell {                                          cell { attr { colspan => 2 } h1 { _('Pending pictures') } }
51                                                  attr { class => 'picture' };                                  };
52                                                  img { attr { src => "static/pics/$f" } }                                  warn "## present = ",dump( $present );
53                                                  div { tt{ $f } }                                  foreach my $f ( Arh::Model::Picture->all_filenames ) {
54                                          }                                          next if $present->{$f};
55                                          cell {                                          my $create = new_action( class => 'CreatePicture' );
56                                                  attr { class => 'picture-description' };                                          row {
57                                                  render_param( $create => 'campaign' );                                                  cell {
58                                                  render_param( $create => 'type' );                                                          attr { class => 'picture' };
59                                                  $create->button(                                                          img { attr { src => "static/pics/$f" } }
60                                                          submit => $create,                                                          div { tt{ $f } }
61                                                          label => _('Add'),                                                  }
62                                                          arguments => {                                                  cell {
63                                                                  filename => $f,                                                          attr { class => 'picture-description' };
64                                                          }                                                          render_param( $create => 'campaign' );
65                                                  );                                                          render_param( $create => 'type' );
66                                                            $create->button(
67                                                                    submit => $create,
68                                                                    label => _('Add'),
69                                                                    arguments => {
70                                                                            filename => $f,
71                                                                    }
72                                                            );
73                                                    }
74                                          }                                          }
75                                  }                                  }
76                          }                          }
# Line 90  template '/units' => page { Line 93  template '/units' => page {
93  sub unit {  sub unit {
94          my $unit = shift || die "no unit?";          my $unit = shift || die "no unit?";
95          my $a = new_action( class => 'UpdateUnit', record => $unit );          my $a = new_action( class => 'UpdateUnit', record => $unit );
         warn "## current_user = ",dump( current_user );  
96          form {          form {
97                  foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) {                  foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) {
98                            my $can_write = $unit->current_user_can('write',$f);
99                            #warn "write $f ",$can_write ? 'ok' : 'DENIED';
100                          if ( $f eq 'material' ) {                          if ( $f eq 'material' ) {
101                                  my $material = $unit->material;                                  set( UnitMaterialCollection => $unit->material );
102                                  while ( my $um = $material->next ) {                                  show( '/unit/materials' );
                                         my $m = new_action( class => 'UpdateMaterial', record => $um->material );  
                                         render_param( $m => 'name', label => _("Material"), render_mode => 'read' );  
                                 }  
103                          } else {                          } else {
104                                  my %opt;                                  my %opt;
105                                  $opt{render_mode} = 'read'; # unless                                  $opt{render_mode} = 'read' if ! $unit->current_user_can('write',$f);
                                 warn "write $f ",$unit->current_user_can('write',$f) ? 'ok' : 'DENIED';  
106                                  render_param( $a => $f, %opt );                                  render_param( $a => $f, %opt );
107                          }                          }
108                  }                  }
109          }          }
110  }  }
111    
112    template '/unit/materials' => sub {
113            my $materials = get('UnitMaterialCollection');
114            my $del_um = new_action( class => 'DeleteUnitMaterial', moniker => 'del_um' );
115            my $new_um = new_action( class => 'CreateUnitMaterial', moniker => 'new_um' );
116            my $can_write;
117            while ( my $um = $materials->next ) {
118                    div { attr { class is 'form_field' }
119                            span {
120                                    span { attr { class is 'label' } _("Material") };
121                                    span { $um->material->name };
122                    
123                                    $can_write ||= $um->current_user_can('write');
124                                    if ( $can_write ) {
125                                            outs_raw($del_um->button(
126                                                    submit => $del_um,
127                                                    label => _('Delete'),
128                                                    arguments => {
129                                                            unit => $um->unit,
130                                                            material => $um->material
131                                                    },
132                                            ));
133                                    }
134                            }
135                    };
136    
137                    if ( $can_write ) {
138                            render_param(
139                                    $new_um => 'material', label => _("Material"),
140                                    render_as => 'Arh::Web::Material',
141                                    # cludge to transfer arguments
142                                    hints => {
143                                            unit => $um->unit,
144                                    },
145                            );
146                    }
147            }
148    };
149    
150  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26