/[Frey]/trunk/lib/Frey/Action.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 /trunk/lib/Frey/Action.pm

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

revision 640 by dpavlin, Sun Nov 30 15:13:32 2008 UTC revision 645 by dpavlin, Sun Nov 30 16:22:45 2008 UTC
# Line 114  sub params_form { Line 114  sub params_form {
114                  qq|<select title="$attr_type" name="$name">$options</select>| if $options;                  qq|<select title="$attr_type" name="$name">$options</select>| if $options;
115          }          }
116    
117          foreach my $name ( grep { ! $class->meta->get_attribute($_)->is_lazy } $self->attributes ) {          foreach my $checkbox ( split(/\s+/, $default->{'frey-checkboxes'} ) ) {
118                    next if defined $default->{ $checkbox };
119    
120                    $default->{ $checkbox } = 0;
121                    $self->params->{ $checkbox } = 0;
122                    warn "# checkbox $checkbox not ticked";
123            }
124    
125            my @checkboxes;
126    
127            foreach my $name (
128                    grep {
129                            ! $class->meta->get_attribute($_)->is_lazy
130                            && ! defined $default->{$_}
131                    } $self->attributes
132            ) {
133                  my $attr_type = '';                  my $attr_type = '';
134                  my $type = $name =~ m/^pass/ ? 'password' : 'text';                  my $type = $name =~ m/^pass/ ? 'password' : 'text';
135                  my $label = $name;                  my $label = $name;
                 my $value = '';  
136                  my $label_title = '';                  my $label_title = '';
137                  my $value_html = '';                  my $value_html = '';
138    
139                  my $attr = $class->meta->get_attribute( $name );                  my $attr = $class->meta->get_attribute( $name );
140                  $attr_type = $attr->type_constraint->name if $attr->has_type_constraint;                  $attr_type = $attr->type_constraint->name if $attr->has_type_constraint;
141    
142                  $value = $attr->default( $name ) if ! $value && $attr->has_default;                  my $value =
143                            defined $default->{$name} ? $default->{$name}       :
144                            $attr->has_default        ? $attr->default( $name ) :
145                            '';
146    
147                  if ( ref($config_params) eq 'HASH' ) {                  if ( ref($config_params) eq 'HASH' ) {
148                          $value = $config_params->{$name};                          $value = $config_params->{$name};
# Line 138  sub params_form { Line 155  sub params_form {
155                                  my $suffix = '';                                  my $suffix = '';
156                                  $suffix = ' checked' if $value;                                  $suffix = ' checked' if $value;
157                                  $value_html = qq|<input type="checkbox" name="$name" title="$attr_type" value="$value"$suffix>|;                                  $value_html = qq|<input type="checkbox" name="$name" title="$attr_type" value="$value"$suffix>|;
158                                    push @checkboxes, $name;
159                  } elsif ( $attr_type !~ m{^(Str|Int)$} ) {                  } elsif ( $attr_type !~ m{^(Str|Int)$} ) {
160                                  $value_html = qq|<textarea name="$name" title="$attr_type">$value</textarea>|;                                  $value_html = qq|<textarea name="$name" title="$attr_type">$value</textarea>|;
161                  }                  }
# Line 151  sub params_form { Line 169  sub params_form {
169  #               warn "# required $name ", $class->meta->get_attribute( $name )->dump( 2 );  #               warn "# required $name ", $class->meta->get_attribute( $name )->dump( 2 );
170                  $form .= qq|<label for="$name"$label_title>$label</label>| . $value_html;                  $form .= qq|<label for="$name"$label_title>$label</label>| . $value_html;
171          }          }
172          my $html = qq|<h1>$class params</h1><form method="post">$form<input type="submit" value="Run $class"></form>|;          $form .= qq|<input type="hidden" name="frey-checkboxes" value="| . join(' ', @checkboxes) . qq|">| if @checkboxes;
173    
174            my $html;
175    
176            $html = qq|
177                    <h1>$class params</h1>
178                    <form method="post">
179                    $form
180                    <input type="submit" value="Run $class">
181                    </form>
182            | if $form;
183    
184          $self->add_status({          $self->add_status({
185                  $self->class => {                  $self->class => {
186                          params  => $self->params,                          params  => $self->params,

Legend:
Removed from v.640  
changed lines
  Added in v.645

  ViewVC Help
Powered by ViewVC 1.1.26