X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Felements%2Fedit.html;h=5f41ba0c1d26910075c799ef85f070cbb8381fab;hb=8ad827f9de1dd45c354381a58a2609f0d59fd8e7;hp=d18a37d5a7a356ca6aba6ba8dda3b1dfc5054e5d;hpb=df676d82034cb63ff357f8d8ed0f95ce788fb98b;p=freeside.git diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index d18a37d5a..5f41ba0c1 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -40,8 +40,10 @@ Example: 'disabled' => 0, 'onchange' => 'javascript_function', - #m2 stuff only tested w/selectlayers so far - #might work w/select too, dunno others + 'include_opt_callback' => sub { #my $ = @_; + ( 'option' => 'value', ); + }, + 'm2name_table' => 'table_name', 'm2name_namecol' => 'name_column', #OR# @@ -132,37 +134,39 @@ Example: # initialization callbacks ### - ###global callbacks + ###global callbacks, always run if provided - #always run if provided, after decoding long CGI "redirect=" responses but + #after decoding long CGI "redirect=" responses but # before object creation/search # (useful if you have a long form that might trigger redirect= and you need # to do things with $cgi params - they're not decoded in the calling # <%init> block yet) 'begin_callback' = sub { my( $cgi, $fields_listref, $opt_hashref ) = @_; }, - #always run, after the mode-specific object creation/search + #after the mode-specific object creation/search 'end_callback' = sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, - ###mode-specific callbacks + ###mode-specific callbacks. one (and only one) of these four is called + #run when adding + 'new_callback' => sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, + + #run when editing + 'edit_callback' => sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, + #run when re-displaying with an error 'error_callback' => sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, - #run when editing - 'edit_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; }, - + #run when cloning + 'clone_callback' => sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, + + ###callbacks called in new mode only + # returns a hashref for the new object 'new_hashref_callback' # returns the new object iself (otherwise, ->new is called) 'new_object_callback' - - #run when adding - 'new_callback' => sub { my( $cgi, $object, $fields_listref ) = @_; }, - - #run when cloning - 'clone_callback' => sub { my( $cgi, $object, $fields_listref, $opt_hashref ) = @_; }, ###display callbacks @@ -276,7 +280,7 @@ Example: % % #select-table, checkboxes-table % $include_common{$_} = $f->{$_} -% foreach grep exists($f->{$_}), qw( table name_col ); +% foreach grep exists($f->{$_}), qw( table name_col value_col ); % % #checkboxes-table % $include_common{$_} = $f->{$_} @@ -287,7 +291,12 @@ Example: % foreach grep exists($f->{$_}), qw( hashref agent_virt agent_null_right ); % % if ( $type eq 'tablebreak-tr-title' ) { -% $include_common{'table_id'} = 'TableNumber'. $tablenum++ +% $include_common{'table_id'} = 'TableNumber'. $tablenum++; +% $include_common{'colspan'} = $f->{colspan} if $f->{colspan}; +% } +% +% if ( $f->{include_opt_callback} ) { +% %include_common = ( %include_common, &{ $f->{include_opt_callback} } ); % } % % my $layer_prefix_on = ''; @@ -315,6 +324,27 @@ Example: % @include; % }; % +% my $column_sub = sub { +% my %opt = @_; +% +% my $column = delete($opt{field}); +% my $fieldnum = delete($opt{fieldnum}); +% my $include = delete($opt{type}) || 'text'; +% $include = "input-$include" if $include =~ /^(text|money|percentage)$/; +% +% ( "/elements/$include.html", +% 'field' => $field.'__'.$column.$fieldnum, +% 'id' => $field.'__'.$column.$fieldnum, +% 'layer_prefix' => $field.'__'.$column.$fieldnum.".", +% ( $fieldnum +% ? ('cell_style' => 'border-top:1px solid black') +% : () +% ), +% 'cgi' => $cgi, +% %opt, +% ); +% }; +% % unless ( $type =~ /^column/ ) { % $g_row = 1 if $type eq 'tablebreak-tr-title'; % $g_row++; @@ -380,8 +410,35 @@ Example: % 'layer_values' => $layer_values, % 'cell_style' => ( $fieldnum ? 'border-top:1px solid black' : '' ), % ); +% $existing[0] =~ s(^/elements/tr-)(/elements/); +% my @label = @existing; +% $label[0] = '/elements/tr-td-label.html'; + <% include( @label ) %> + <% include( @existing ) %> + + +% if ( $f->{'m2_fields'} ) { +% foreach my $c ( @{ $f->{'m2_fields'} } ) { +% my $column = $c->{field}; +% my @column = &{ $column_sub }( %$c, +% 'fieldnum' => $fieldnum, +% 'curr_value' => $name_obj->$column() +% ); + + + <% $c->{'label'} || '' %> + + + <% include( @column ) %> + +% } +% } + + % $fieldnum++; % $g_row++; @@ -407,9 +464,40 @@ Example: % 'onchange' => $onchange, % ( $fieldnum ? ('cell_style' => 'border-top:1px solid black') : () ), % ); +% +% if ( $f->{'m2name_table'} || $f->{'m2m_method'} ) { +% $include[0] =~ s(^/elements/tr-)(/elements/); +% my @label = @include; +% $label[0] = '/elements/tr-td-label.html'; + + <% include( @label ) %> + + <% include( @include ) %> + + +% if ( $f->{'m2_fields'} ) { +% foreach my $c ( @{ $f->{'m2_fields'} } ) { +% my $column = $c->{field}; +% my @column = &{ $column_sub }( %$c, 'fieldnum' => $fieldnum ); + + + <% $c->{'label'} || '' %> + + + <% include( @column ) %> + +% } +% } + + + +% } else { - <% include( @include ) %> + <% include( @include ) %> +% } % if ( $f->{'m2name_table'} || $f->{'m2m_method'} ) {