Author: richter Date: Thu Jan 3 21:55:57 2013 New Revision: 1428624 URL: http://svn.apache.org/viewvc?rev=1428624&view=rev Log: Embperl::Form Update
Modified: perl/embperl/trunk/Embperl/Form.pm perl/embperl/trunk/Embperl/Form/Control.pm perl/embperl/trunk/Embperl/Form/Control/checkbox.pm perl/embperl/trunk/Embperl/Form/Control/checkboxes.pm perl/embperl/trunk/Embperl/Form/Control/grid.pm perl/embperl/trunk/Embperl/Form/Control/mult.pm perl/embperl/trunk/Embperl/Form/Control/select.pm perl/embperl/trunk/Embperl/Form/Control/tabs.pm perl/embperl/trunk/Embperl/Syntax.pm Modified: perl/embperl/trunk/Embperl/Form.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form.pm?rev=1428624&r1=1428623&r2=1428624&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form.pm (original) +++ perl/embperl/trunk/Embperl/Form.pm Thu Jan 3 21:55:57 2013 @@ -88,12 +88,14 @@ sub sub_new $self -> {fields2empty} = [] ; $self -> {init_data} = [] ; $self -> {prepare_fdat} = [] ; + $self -> {code_refs} = [] ; } else { $self -> {fields2empty} = $self -> parent_form -> {fields2empty} ; $self -> {init_data} = $self -> parent_form -> {init_data} ; - $self -> {prepare_fdat} = $self -> parent_form -> {prepare_fdat} ; + $self -> {prepare_fdat} = $self -> parent_form -> {prepare_fdat} ; + $self -> {code_refs} = $self -> parent_form -> {code_refs} ; } $self -> new_controls ($controls, $options, undef, $id, $validate_rules, $options -> {masks}, $options -> {defaults}) ; @@ -311,7 +313,8 @@ sub new_controls if (!$no_init) { push @{$self -> {init_data}}, $control if ($control -> can ('init_data')) ; - push @{$self -> {prepare_fdat}}, $control if ($control -> can ('prepare_fdat')) ; + push @{$self -> {prepare_fdat}}, $control if ($control -> can ('prepare_fdat')) ; + push @{$self -> {code_refs}}, $control if ($control -> has_code_refs) ; } } $self -> {controlids}{$control->{id}} = $control ; @@ -601,6 +604,26 @@ sub prepare_fdat } } +# --------------------------------------------------------------------------- +# +# code_ref_fingerprint - returns a fingerprint of the result of all code refs +# can be used to check if is_readonly or is_disabled +# has dynamicly changed +# + +sub code_ref_fingerprint + + { + my ($self, $req) = @_ ; + + my $fp ; + foreach my $control (@{$self -> {code_refs}}) + { + $fp .= $control -> code_ref_fingerprint ($req) ; + } + return $fp ; + } + # --------------------------------------------------------------------------- # # validate - validate the form input Modified: perl/embperl/trunk/Embperl/Form/Control.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control.pm?rev=1428624&r1=1428623&r2=1428624&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control.pm Thu Jan 3 21:55:57 2013 @@ -122,6 +122,33 @@ sub is_hidden return ; } +# --------------------------------------------------------------------------- +# +# has_code_refs - returns true if is_readonly or is_disabled are coderefs +# + +sub has_code_refs + + { + my ($self, $req) = @_ ; + + return ref ($self -> {readonly}) eq 'CODE' || ref ($self -> {disable}) eq 'CODE' ; + } + + +# --------------------------------------------------------------------------- +# +# code_ref_fingerprint - returns fingerprint of is_readonly and is_disabled +# + +sub code_ref_fingerprint + + { + my ($self, $req) = @_ ; + + return $self -> is_readonly?'R':'W' . $self -> is_disabled?'D':'E' ; + } + # --------------------------------------------------------------------------- # @@ -448,7 +475,7 @@ $] $value = $self -> {value} || $fdat{$self -> {name}} if (!defined($value)) ; $] -<div [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req, '', 'readonly') } +]>[+ $value +]</div> +<div [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req, '', 'readonly') } +] _ef_divname="[+$self -> {name}+]">[+ $value +]</div> [$endsub$] [# --------------------------------------------------------------------------- Modified: perl/embperl/trunk/Embperl/Form/Control/checkbox.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/checkbox.pm?rev=1428624&r1=1428623&r2=1428624&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/checkbox.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/checkbox.pm Thu Jan 3 21:55:57 2013 @@ -92,7 +92,8 @@ __EMBPERL__ push @{$self -> form -> {fields2empty}}, $name ; $] <input type="checkbox" name="[+ $ctlname +]" [+ do { local $escmode = 0 ; $ctlattrs } +] value="[+ $val +]" ->[$if ($self -> {trigger}) $]<script >$('#[+ $ctlid +]').ef_checkbox ()</script>[$endif$] +[$if ($self -> {trigger}) $]_ef_attach="ef_checkbox"[$endif$] +> [$endsub$] __END__ Modified: perl/embperl/trunk/Embperl/Form/Control/checkboxes.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/checkboxes.pm?rev=1428624&r1=1428623&r2=1428624&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/checkboxes.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/checkboxes.pm Thu Jan 3 21:55:57 2013 @@ -87,7 +87,8 @@ $] [$ foreach $val (@$values) $] [$if !defined ($filter) || ($val =~ /$filter/i) $] [$ if $tab $][$ if $colcnt == 0 $]<[# #]tr>[- $colcnt = $tab -][$endif$]<td>[$endif$] - <input type="checkbox" name="[+ $name +]" value="[+ $val +]" [+ do { local $escmode = 0 ; $ctlattrs } +]> + <input type="checkbox" name="[+ $name +]" value="[+ $val +]" [+ do { local $escmode = 0 ; $ctlattrs } +] + [$if ($self -> {trigger}) $]_ef_attach="ef_checkbox"[$endif$] > [$ if $tab $]</td><td>[$endif$] [+ $options ->[$i] || $val +] [- $vert = $self -> {vert} -][$while $vert-- > 0 $]<br/>[$endwhile$] @@ -95,7 +96,6 @@ $] [$endif$] [* $i++ ; *] [$endforeach$] -[$if ($self -> {trigger}) $]<script >$('#[+ $ctlid +]').ef_checkbox ()</script>[$endif$] [$if $tab $]<[# #]/table>[$ endif $] [$endsub$] Modified: perl/embperl/trunk/Embperl/Form/Control/grid.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/grid.pm?rev=1428624&r1=1428623&r2=1428624&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/grid.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/grid.pm Thu Jan 3 21:55:57 2013 @@ -121,21 +121,21 @@ sub init_data } } - my $coloffset = defined ($self -> {coloffset})?$self -> {coloffset}:1 ; - my $data; + my $coloffset = defined ($self -> {coloffset})?$self -> {coloffset}:1 ; + my $data; my $i = 0 ; my $j ; my $col ; my $colval ; - my @rowclass ; + my @rowclass ; foreach my $entry (@entries) { $data = ref $entry eq 'ARRAY'?$entry:[$ldap?ecos::LdapBase -> splitAttrValue($entry):$entry]; - if (ref $self -> {rowclass} eq 'CODE') - { - $rowclass[$i] = &{$self -> {rowclass}}($data, $self) ; - } - my $co = $coloffset ; + if (ref $self -> {rowclass} eq 'CODE') + { + $rowclass[$i] = &{$self -> {rowclass}}($data, $self) ; + } + my $co = $coloffset ; shift @$data while ($co-- > 0) ; $j = 0 ; foreach my $field ((@$fields, ($line2?($line2):()))) @@ -148,9 +148,9 @@ sub init_data else { $fdat->{"__${name}_${j}_$i"} = $data->[$col] ; - } + } - if ($field -> can ('init_data')) + if ($field -> can ('init_data')) { local $field->{name} = "__${name}_${j}_$i" ; local $field -> {fullid} = "$self->{fullid}_${j}_$i" ; @@ -161,8 +161,8 @@ sub init_data $i++ ; } $fdat->{"__${name}_max"} = $i?$i:1; - $self -> {rowclasses} ||= \@rowclass ; - } + $self -> {rowclasses} ||= \@rowclass ; + } # ------------------------------------------------------------------------------------------ # @@ -206,7 +206,7 @@ sub prepare_fdat my $order ; for (my $i = 0; $i < $max; $i++) { - my $ok = 0 ; + my $ok = 0 ; my $j = 0 ; foreach my $field (@$fields, $line2?($line2):()) { @@ -216,11 +216,11 @@ sub prepare_fdat local $field -> {fullid} = "$self->{fullid}_${j}_$i" ; $field -> prepare_fdat ($req) ; } - $ok++ ; + $ok++ ; $j++ ; } - next if (!$ok) ; + next if (!$ok) ; $order = $fdat->{"__${name}_#row#_$i"} ; next if (!defined($order)) ; @@ -230,7 +230,7 @@ sub prepare_fdat $self -> prepare_fdat_sub ($req) if ((ref ($self) =~ /::/)); - my $coloffset = defined ($self -> {coloffset})?$self -> {coloffset}:1 ; + my $coloffset = defined ($self -> {coloffset})?$self -> {coloffset}:1 ; foreach my $order (sort { $a <=> $b } keys %orders) { $i = $orders{$order} ; @@ -336,9 +336,8 @@ __EMBPERL__ my $span = ($self->{width_percent}) ; my $nsprefix = $self -> form -> {jsnamespace} ; my $max = $fdat{"__${name}_max"} ; - my $on_grid_change = $self -> {on_grid_change} ; $self -> {fullid} = $req -> {uuid} . '_' . $self -> {id} ; -$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +][+ ' ' +][+ $self -> {state} +]"> +$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +][+ ' ' +][+ $self -> {state} +]" _ef_attach="ef_grid"> <tr> <td class="ui-label-box" colspan="[+ $span +]"> [- @@ -346,22 +345,19 @@ $]<table class="ef-element ef-element-wi my $span = 0 ; $self -> show_grid_title ($req); -] - <input type="hidden" name="__[+ $self -> {name} +]_max" id="__[+ $self -> {fullid} +]_max"> - <table class="cGridTable cBase [+ $self -> {state} +]" id="[+ $self -> {fullid} +]"> + <input type="hidden" name="__[+ $self -> {name} +]_max" class="ef-control-grid-max"> + <table class="cGridTable cBase ef-control-grid-table [+ $self -> {state} +]" > [- $self -> show_grid_header ($req); -] [- $self -> show_grid_table ($req) ; -] </table> [- $self -> show_grid_title ($req) if ($max > $self -> {header_bottom} && !$self -> {disable_controls}) -] - <table id="__[+ $self -> {fullid} +]_newrow" style="display: none"> + <table class="ef-control-grid-newrow" style="display: none"> [- local $req -> {epf_no_script} = 1 ; $self -> show_grid_table_row ($req, '%row%') ; -] </table> - <script> - $('#[+ $self -> {fullid} +]').eplgrid ([$if $on_grid_change $]{'onchange': [+ $on_grid_change +] }[$endif$]) ; - </script> </td> </tr> </table> @@ -381,10 +377,10 @@ $] [$if !($self -> is_readonly ($req)) && !$self -> {disable_controls} $] <td class="cBase cGridControlBox"> <div> - <span class="ui-icon ui-icon-circle-triangle-n ef-icon" id="[+ $self -> {fullid} +]-up" title="Zeile Hoch"></span> - <span class="ui-icon ui-icon-circle-triangle-s ef-icon" id="[+ $self -> {fullid} +]-down" title="Zeile Runter"></span> - <span class="ui-icon ui-icon-circle-plus ef-icon" id="[+ $self -> {fullid} +]-add" title="Zeile Hinzufügen"></span> - <span class="ui-icon ui-icon-circle-minus ef-icon" id="[+ $self -> {fullid} +]-del" title="Markierte Zeile Löschen"></span> + <span class="ui-icon ui-icon-circle-triangle-n ef-icon ef-control-grid-up" title="Zeile Hoch"></span> + <span class="ui-icon ui-icon-circle-triangle-s ef-icon ef-control-grid-down" title="Zeile Runter"></span> + <span class="ui-icon ui-icon-circle-plus ef-icon ef-control-grid-add" title="Zeile Hinzufügen"></span> + <span class="ui-icon ui-icon-circle-minus ef-icon ef-control-grid-del" title="Markierte Zeile Löschen"></span> </div> </td> [$endif$] @@ -404,7 +400,7 @@ $] <thead> <tr class="cGridHeader"> [$ foreach my $field (@$fields) $] - [* next if ($field -> is_hidden ) ; *] + [* next if ($field -> is_hidden ) ; *] <td class="cGridHeader" style="[$if($width = $field->{width})$]width: [+$width+];[$endif$] [$if($width = $field->{min_width})$]min-width: [+$width+];[$endif$]" _colattr="[+ $field->{name} +]">[+ $self -> form -> convert_label ($self, $field->{name}, $field->{text}) +]</td> [$ endforeach $] </tr> @@ -427,14 +423,14 @@ $] <tfoot> <tr class="cGridFooter"> [$ foreach my $field (@$fields) $] - [* next if ($field -> is_hidden ) ; *] + [* next if ($field -> is_hidden ) ; *] <td class="cGridFooter cGridCellReadonly">[- local $field -> {name} = "__${name}_${j}_$i" ; local $field -> {state} = $self -> {state} ; local $field -> {fullid} = "$self->{fullid}_${j}_$i" ; - $field -> show_control_readonly ($req) if (!$field -> {nofooter}) ; - $j++ ; - -]</td> + $field -> show_control_readonly ($req) if (!$field -> {nofooter}) ; + $j++ ; + -]</td> [$ endforeach $] </tr> </tfoot> @@ -459,11 +455,11 @@ $] <tr class="cGridRow [+ $self -> {rowclasses}[$i] +]" id="[+ "$id-row-$i" +]"> [$foreach $field (@$fields)$] - [$if $field -> is_hidden $][- + [$if $field -> is_hidden $][- local $field -> {name} = "__${name}_${j}_$i" ; local $field -> {state} = $self -> {state} ; local $field -> {fullid} = "${id}_${j}_$i" ; - $field -> show_control ($req) ; + $field -> show_control ($req) ; $j++ ; -][$else$] [- $ro = $gridro || $field -> is_readonly () ; -] @@ -481,7 +477,7 @@ $] } $j++ ; -]</td> - [$endif$] + [$endif$] [$endforeach$] </tr> [$if $line2 $] @@ -579,10 +575,6 @@ string if set. field defintion wich is show in a second line, full width. -=head3 on_grid_change - -JavaScript function that is called whan grid changes (i.e. add row, delete row etc.) - =head3 disable_controls If true, controls for add, delete, up and down will not be shown Modified: perl/embperl/trunk/Embperl/Form/Control/mult.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/mult.pm?rev=1428624&r1=1428623&r2=1428624&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/mult.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/mult.pm Thu Jan 3 21:55:57 2013 @@ -141,7 +141,6 @@ __EMBPERL__ my $jsname = $name ; $jsname =~ s/[^a-zA-Z0-9]/_/g ; $jsname .= 'Grid' ; - my $on_grid_change = $self -> {on_grid_change} ; $] [$ if ($max == 1 && $self -> is_readonly($req) ) $] [- @@ -155,24 +154,18 @@ $] $fdat{$name} = $self -> {default} if ($fdat{$name} eq '' && exists ($self -> {default})) ; my $span = 0 ; -] - <div [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req) } +]> - <input type="hidden" name="__[+ $self -> {name} +]_max" id="__[+ $self -> {fullid} +]_mult_max"> - <table class="ef-control-mult-table" id="[+ $self -> {fullid} +]_mult"> + <div [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req) } +] _ef_attach="ef_mult"> + <input type="hidden" class="ef-control-mult-max" name="__[+ $self -> {name} +]_max" > + <table class="ef-control-mult-table" > [- $self -> show_grid_table ($req) ; -] </table> - <table id="__[+ $self -> {fullid} +]_mult_newrow" style="display: none"> + <table class="ef-control-mult-newrow" style="display: none"> [- local $req -> {epf_no_script} = 1 ; $self -> show_grid_table_row ($req, '%row%') ; -] </table> </div> - -[$if (! $self -> is_readonly ($req)) $] - <[$if $noscript $]x-[$endif$]script> - $('#[+ $self -> {fullid} +]_mult').eplgrid ([$if $on_grid_change $]{'onchange': [+ $on_grid_change +] }[$endif$]) ; - </[$if $noscript $]x-[$endif$]script> -[$endif$] [$endif$] [$endsub$] @@ -222,8 +215,8 @@ $] $] [$if (! $self -> is_readonly ($req)) $] - <span class="ui-icon ui-icon-circle-plus ef-icon" id="[+ $self -> {fullid} +]_mult-add" title="Zeile Hinzufügen"></span> - <span class="ui-icon ui-icon-circle-minus ef-icon" id="[+ $self -> {fullid} +]_mult-del" title="Zeile Löschen"></span> + <span class="ui-icon ui-icon-circle-plus ef-icon" class="ef-control-mult-add" title="Zeile Hinzufügen"></span> + <span class="ui-icon ui-icon-circle-minus ef-icon" class="ef-control-mult-del" title="Zeile Löschen"></span> [$endif$] [$endsub$] Modified: perl/embperl/trunk/Embperl/Form/Control/select.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/select.pm?rev=1428624&r1=1428623&r2=1428624&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/select.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/select.pm Thu Jan 3 21:55:57 2013 @@ -56,6 +56,7 @@ __EMBPERL__ $] <select name="[+ $ctlname +]" [+ $self->{multiple}?'multiple':''+] [+ do { local $escmode = 0 ; $ctlattrs } +] [$if ($self -> {rows}) $] size="[+ $self->{rows} +]" [$endif$] +[$if ($self -> {trigger}) $]_ef_attach="ef_select"[$endif$] > [* $i = 0 ; *] [$ foreach $val (@$values) $] @@ -65,7 +66,6 @@ $] [* $i++ ; *] [$endforeach$] </select> -[$if ($self -> {trigger}) $]<script >$('#[+ $ctlid +]').ef_select ()</script>[$endif$] [$endsub$] __END__ Modified: perl/embperl/trunk/Embperl/Form/Control/tabs.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/tabs.pm?rev=1428624&r1=1428623&r2=1428624&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/tabs.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/tabs.pm Thu Jan 3 21:55:57 2013 @@ -108,11 +108,9 @@ __EMBPERL__ my $activeid = $self -> get_active_id ($req) ; my $form = $self -> form ; my $nsprefix = $form -> {jsnamespace} ; - my $uid = $req -> {uuid} ; - my $fullname = $uid . '_' . $name ; my $tabs_per_line = $self -> {'tabs_per_line'} || 99; $tabs_per_line = [$tabs_per_line, $tabs_per_line, $tabs_per_line, $tabs_per_line] - if (!ref $tabs_per_line) ; + if (!ref $tabs_per_line) ; my $val ; my $i = 0 ; @@ -121,7 +119,7 @@ __EMBPERL__ my $line = 0 ; $] -<div class="ef-tabs-content-cell" colspan="[+ $span +]" id="[+ $fullname +]"> +<div class="ef-tabs-content-cell" colspan="[+ $span +]" _ef_attach="ef_tabs"> [$ while ($more) $] <table class="ef-tabs-selector" ><tr class="ef-tabs-selector-row"> [* @@ -143,28 +141,25 @@ $] push @switch_code, $code if ($code) ; } my $js = join (';', @switch_code) ; - my $fullid = $uid . '_' . $id ; *] <td class="[+ $cellclass +]"><div class="ef-tabs-div [+ $divclass +]" [$ if $i - $start_i == 0 $]style="border-left: black 1px solid" [$endif$] - id="__tabs_[+ $fullid +]">[+ $options ->[$i] || $val +] - [#<a href="#" onClick="[+ $nsprefix +]tab_selected(document, '[+ $fullid +]','[+ $fullname +]'); [+ do { local $escmode = 0 ; $js } +]" style="color:black; text-decoration: none;">[+ $options ->[$i] || $val +]</a>#] + >[+ $options ->[$i] || $val +] </div></td> [* $i++ ; if ($i - $start_i >= $tabs && @$values > $i) - { - $more = 1 ; - $start_i = $i ; - last ; - } - *] + { + $more = 1 ; + $start_i = $i ; + last ; + } + *] [$endwhile $] [$if ($i == @$values) $]<td class="ef-tabs-cell-blank"> </td>[$endif$] </tr></table> [$endwhile$] [#<input type="hidden" name="[+ $name +]" id="[+ $fullname +]" class="ef-field-tab_select" value="[+ $uid +]_[+ $activeid +]">#] </div> -<script >$('#[+ $fullname +]').ef_tabs ()</script> [$endsub$] __END__ Modified: perl/embperl/trunk/Embperl/Syntax.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Syntax.pm?rev=1428624&r1=1428623&r2=1428624&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Syntax.pm (original) +++ perl/embperl/trunk/Embperl/Syntax.pm Thu Jan 3 21:55:57 2013 @@ -326,7 +326,7 @@ sub CloneHash embperl => { perlcode => q{ # any initialisation could be put here -$DB::single = 1 ; +#$DB::single = 1 ; $maxrow=100;$maxcol=10; }, compiletimeperlcode => q{ --------------------------------------------------------------------- To unsubscribe, e-mail: embperl-cvs-unsubscr...@perl.apache.org For additional commands, e-mail: embperl-cvs-h...@perl.apache.org