/[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 504 by dpavlin, Mon Nov 24 22:08:10 2008 UTC revision 640 by dpavlin, Sun Nov 30 15:13:32 2008 UTC
# Line 125  sub params_form { Line 125  sub params_form {
125                  my $attr = $class->meta->get_attribute( $name );                  my $attr = $class->meta->get_attribute( $name );
126                  $attr_type = $attr->type_constraint->name if $attr->has_type_constraint;                  $attr_type = $attr->type_constraint->name if $attr->has_type_constraint;
127    
128                    $value = $attr->default( $name ) if ! $value && $attr->has_default;
129    
130                  if ( ref($config_params) eq 'HASH' ) {                  if ( ref($config_params) eq 'HASH' ) {
131                          $value = $config_params->{$name};                          $value = $config_params->{$name};
132                  } elsif ( ref($config_params) eq 'ARRAY' ) {                  } elsif ( ref($config_params) eq 'ARRAY' ) {
# Line 132  sub params_form { Line 134  sub params_form {
134                          $default->{$name} = $config_params->[0]->{$name};                          $default->{$name} = $config_params->[0]->{$name};
135                  } elsif ( $attr->has_type_constraint && $attr->type_constraint->can('values') ) {                  } elsif ( $attr->has_type_constraint && $attr->type_constraint->can('values') ) {
136                                  $value_html = select_values( $name, $attr_type, $attr->type_constraint->values );                                  $value_html = select_values( $name, $attr_type, $attr->type_constraint->values );
137                    } elsif ( $attr_type =~ m{^Bool} ) {
138                                    my $suffix = '';
139                                    $suffix = ' checked' if $value;
140                                    $value_html = qq|<input type="checkbox" name="$name" title="$attr_type" value="$value"$suffix>|;
141                  } elsif ( $attr_type !~ m{^(Str|Int)$} ) {                  } elsif ( $attr_type !~ m{^(Str|Int)$} ) {
142                                  $value_html = qq|<textarea name="$name" title="$attr_type">$value</textarea>|;                                  $value_html = qq|<textarea name="$name" title="$attr_type">$value</textarea>|;
143                  }                  }
144                  $value = $attr->default( $name ) if ! $value && $attr->has_default;                  
145                  $label_title = qq| title="| . $attr->documentation . qq|"| if $attr->has_documentation;                  $label_title = qq| title="| . $attr->documentation . qq|"| if $attr->has_documentation;
146    
147                  $default->{$name} = $value unless defined $default->{$name};                  $default->{$name} = $value unless defined $default->{$name};
# Line 146  sub params_form { Line 152  sub params_form {
152                  $form .= qq|<label for="$name"$label_title>$label</label>| . $value_html;                  $form .= qq|<label for="$name"$label_title>$label</label>| . $value_html;
153          }          }
154          my $html = qq|<h1>$class params</h1><form method="post">$form<input type="submit" value="Run $class"></form>|;          my $html = qq|<h1>$class params</h1><form method="post">$form<input type="submit" value="Run $class"></form>|;
155          push @{ $self->status }, {          $self->add_status({
156                  $self->editor( $self->class ) => {                  $self->class => {
157                          params  => $self->params,                          params  => $self->params,
158                          config_params  => $config_params,                          config_params  => $config_params,
159                          default => $default                          default => $default
160                  },                  },
161          };          });
162    
163          return ($html,$default) if wantarray;          return ($html,$default) if wantarray;
164          return $html;          return $html;

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

  ViewVC Help
Powered by ViewVC 1.1.26