Author: richter Date: Thu Jan 19 06:23:19 2012 New Revision: 1233195 URL: http://svn.apache.org/viewvc?rev=1233195&view=rev Log: Embperl::Form formatting
Modified: perl/embperl/trunk/Embperl/Form/Control/datetime.pm perl/embperl/trunk/Embperl/Form/Control/grid.pm perl/embperl/trunk/Embperl/Form/Control/number.pm perl/embperl/trunk/Embperl/Form/Control/price.pm perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm Modified: perl/embperl/trunk/Embperl/Form/Control/datetime.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/datetime.pm?rev=1233195&r1=1233194&r2=1233195&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/datetime.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/datetime.pm Thu Jan 19 06:23:19 2012 @@ -67,7 +67,7 @@ sub init_data { my @time = gmtime(timegm_nocheck($s,$min,$h,$d,$m-1,$y-1900)+($tz_local*60)); - my $format = $s == 0 && $h == 0 && $min == 0?'%d.%m.%Y':'%d.%m.%Y, %H:%M' ; + my $format = $self -> {notime} || ($s == 0 && $h == 0 && $min == 0)?'%d.%m.%Y':'%d.%m.%Y, %H:%M' ; strftime ($format, @time[0..5]) ; } ; @@ -195,16 +195,17 @@ Embperl::Form::Control::price - A price =head1 DESCRIPTION -Used to create a price input control inside an Embperl Form. -Will format number as a money ammout. -Optionaly it can display an unit after the input field. +Used to create a datetime input control inside an Embperl Form. +Will format number as a date/time. See Embperl::Form on how to specify parameters. +Datetime format in %fdat is excpected as YYYYMMTTHHMMSSZ + =head2 PARAMETER =head3 type -Needs to be 'price' +Needs to be 'datetime' =head3 name @@ -218,18 +219,9 @@ Will be used as label for the numeric in Gives the size in characters. (Default: 10) -=head3 maxlength - -Gives the maximun length in characters - -=head3 unit - -Gives a string that should be displayed right of the input field. -(Default: ) - -=head3 use_comma +=head3 notime -If set the decimal character is comma instead of point (Default: on) +doe not display time =head1 Author Modified: perl/embperl/trunk/Embperl/Form/Control/grid.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/grid.pm?rev=1233195&r1=1233194&r2=1233195&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/grid.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/grid.pm Thu Jan 19 06:23:19 2012 @@ -102,7 +102,8 @@ sub init_data } } - my $data; + my $coloffset = defined ($self -> {coloffset})?$self -> {coloffset}:1 ; + my $data; my $i = 0 ; my $j ; my $col ; @@ -110,7 +111,7 @@ sub init_data foreach my $entry (@entries) { $data = ref $entry eq 'ARRAY'?$entry:[$ldap?ecos::LdapBase -> splitAttrValue($entry):$entry]; - my $rowno = shift @$data ; + shift @$data while ($coloffset-- > 0) ; $j = 0 ; foreach my $field ((@$fields, ($line2?($line2):()))) { @@ -122,8 +123,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" ; $field -> init_data ($req, $self) ; @@ -133,7 +135,7 @@ sub init_data $i++ ; } $fdat->{"__${name}_max"} = $i?$i:1; - } + } # ------------------------------------------------------------------------------------------ # @@ -177,7 +179,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):()) { @@ -186,11 +188,11 @@ sub prepare_fdat local $field->{name} = "__${name}_${j}_$i" ; $field -> prepare_fdat ($req) ; } - $ok++ ; + $ok++ ; $j++ ; } - next if (!$ok) ; + next if (!$ok) ; $order = $fdat->{"__${name}_#row#_$i"} ; next if (!defined($order)) ; @@ -200,24 +202,25 @@ sub prepare_fdat $self -> prepare_fdat_sub ($req) if ((ref ($self) =~ /::/)); + my $coloffset = defined ($self -> {coloffset})?$self -> {coloffset}:1 ; foreach my $order (sort keys %orders) { $i = $orders{$order} ; $j = 0 ; my $empty = 1 ; - my @data = ($i+1) ; + my @data = $coloffset?($i+1):() ; foreach my $field (@$fields) { $col = exists $field -> {col}?$field -> {col}:$j ; if ($colval = $field -> {colval}) { - $data[$col+1] .= $colval if ($fdat->{"__${name}_${j}_$i"}) ; + $data[$col+$coloffset] .= $colval if ($fdat->{"__${name}_${j}_$i"}) ; } else { - $data[$col+1] = $fdat->{"__${name}_${j}_$i"} ; + $data[$col+$coloffset] = $fdat->{"__${name}_${j}_$i"} ; } - $empty = 0 if ($data[$col+1] ne '') ; + $empty = 0 if ($data[$col+$coloffset] ne '') ; $j++ ; } $val = $ldap?ecos::LdapBase -> joinAttrValue(\@data):\@data ; @@ -324,6 +327,32 @@ $] [# --------------------------------------------------------------------------- # +# show_grid_footer Erzeugt den Tabellenfuß (Summenzeile) +#] + +[$ sub show_grid_footer ($self, $req) + + my $fields = $self->{'fields'}; + my $name = $self -> {name} ; + my $i = $fdat{"__${name}_footer"} ; + my $j = 0 ; + $] + + <tfoot> + <tr class="cGridFooter"> + [$ foreach my $field (@$fields) $] + <td class="cGridFooter cGridCellReadonly">[- + local $field -> {name} = "__${name}_${j}_$i" ; + $field -> show_control_readonly ($req) if (!$field -> {nofooter}) ; + $j++ ; + -]</td> + [$ endforeach $] + </tr> + </tfoot> +[$ endsub $] + +[# --------------------------------------------------------------------------- +# # show_grid_table_row Erzeugt eine Grid-Tabelle-Zeile #] @@ -471,6 +500,10 @@ Column to use as sort key Sort descending +=head3 coloffset + +Offset added to column number. Default: 1 +If > 1, column number will set to the rownumber =head2 Example Modified: perl/embperl/trunk/Embperl/Form/Control/number.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/number.pm?rev=1233195&r1=1233194&r2=1233195&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/number.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/number.pm Thu Jan 19 06:23:19 2012 @@ -21,6 +21,16 @@ use base 'Embperl::Form::Control::input' use Embperl::Inline ; +# ------------------------------------------------------------------------------------------ + +sub get_std_control_attr + { + my ($self, $id, $type, $addclass) = @_ ; + + return $self -> SUPER::get_std_control_attr ($id, $type, $type eq 'readonly'?'ef-control-number-readonly':$addclass) ; + } + + # --------------------------------------------------------------------------- # # show_control_readonly - output the control as readonly @@ -34,7 +44,7 @@ sub show_control_readonly my $unittext = $self -> form -> convert_text ($self, ($unit =~ /:/)?$unit:"unit:$unit", $unit) ; $unittext =~ s/^unit:// ; $value = $self -> {value} || $Embperl::fdat{$self -> {name}} if (!defined($value)) ; - $value .= $unittext if ($unit) ; + $value .= $unittext if ($unit && $value ne '') ; $self -> SUPER::show_control_readonly ($req, $value) ; } Modified: perl/embperl/trunk/Embperl/Form/Control/price.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/price.pm?rev=1233195&r1=1233194&r2=1233195&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/price.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/price.pm Thu Jan 19 06:23:19 2012 @@ -34,7 +34,7 @@ sub init my ($self) = @_ ; $self -> {use_comma} = 1 if (!defined $self -> {use_comma}) ; - $self->{unit} = '' if (!exists ($self->{unit}) && !defined ($self->{unit} )); + $self->{unit} = '' if (!defined ($self->{unit} )); return $self ; } Modified: perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm?rev=1233195&r1=1233194&r2=1233195&view=diff ============================================================================== --- perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm (original) +++ perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm Thu Jan 19 06:23:19 2012 @@ -23,6 +23,24 @@ use base 'Embperl::Form::ControlMultValu use Embperl::Inline ; # ------------------------------------------------------------------------------------------ + +sub get_std_control_attr + { + my ($self, $id, $type, $addclass) = @_ ; + + if ($type eq 'readonly') + { + $id = $self -> form -> {unique_id} . '_' . $self -> {name} ; + my $url = $self -> {showurl} ; + $url =~ s/%id%/$self -> get_id_from_value ($Embperl::fdat{$self -> {name}})/e ; + my $attr = $self -> SUPER::get_std_control_attr ($id, $type, 'ef-control-selectdyn-readonly') ; + return $attr . qq{ onDblClick="\$('#$self->{use_ajax}').ef_document ('load', '$url');"} ; + } + + return $self -> SUPER::get_std_control_attr ($id, $type, $addclass) ; + } + +# ------------------------------------------------------------------------------------------ # # prepare_fdat - daten zusammenfuehren # @@ -35,8 +53,7 @@ sub prepare_fdat my $fdat = $req -> {form} || \%fdat ; my $name = $self->{name} ; - my $val = $fdat -> {"_inp_$name"} ; - $fdat -> {$name} = '' if ($val eq '') ; + $fdat -> {$name} = '' if (exists ($fdat -> {"_inp_$name"}) && $fdat -> {"_inp_$name"} eq '') ; delete $fdat -> {"_inp_$name"} ; } @@ -55,10 +72,27 @@ __EMBPERL__ [# --------------------------------------------------------------------------- # +# show_control_readonly - output the control as readonly +#] + +[$ sub show_control_readonly ($self, $req, $value) + +my $id = $self -> form -> {unique_id} . '_' . $self -> {name} ; + +my $url = $self -> {popupurl} ; +$url =~ s/%id%/$self -> get_id_from_value ($Embperl::fdat{$self -> {name}})/e ; + +$] +[- $self -> SUPER::show_control_readonly ($req, $option) ; -] +<script>add_qtip($('#[+ $id +]'), '[+ $url +]');</script> +[$endsub$] + +[# --------------------------------------------------------------------------- +# # show_hidden - out hidden field #] -[$ sub show_hidden ($self, $req) +[$ sub xshow_hidden ($self, $req) my $noscript = $req -> {epf_no_script} ; $] <input type="hidden" name="[+ $self -> {name} +]" id="[+ $self -> {name} +]"> --------------------------------------------------------------------- To unsubscribe, e-mail: embperl-cvs-unsubscr...@perl.apache.org For additional commands, e-mail: embperl-cvs-h...@perl.apache.org