You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl-cvs@perl.apache.org by ri...@apache.org on 2011/03/11 07:53:45 UTC
svn commit: r1080466 - in /perl/embperl/trunk/Embperl/Form/Control: grid.pm
table.pm
Author: richter
Date: Fri Mar 11 06:53:44 2011
New Revision: 1080466
URL: http://svn.apache.org/viewvc?rev=1080466&view=rev
Log:
Embperl::Form update
Modified:
perl/embperl/trunk/Embperl/Form/Control/grid.pm
perl/embperl/trunk/Embperl/Form/Control/table.pm
Modified: perl/embperl/trunk/Embperl/Form/Control/grid.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/grid.pm?rev=1080466&r1=1080465&r2=1080466&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/grid.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/grid.pm Fri Mar 11 06:53:44 2011
@@ -214,9 +214,12 @@ $]
-]
</table>
<script>
+ $('#[+ $self -> {id} +]').eplgrid () ;
+ [#
[+ $jsname +] = new [+ $nsprefix +]Grid (document.getElementById('[+ $self -> {id} +]'),
document.getElementById('[+ $self -> {id} +]-newrow'),
document.getElementById('[+ $self -> {id} +]-max')) ;
+ #]
</script>
</td>
[$endsub$]
@@ -234,10 +237,10 @@ $]
<td class="cBase cGridLabelBox">[+ $self -> form -> convert_label ($self) +]</td>
[$if !($self -> {readonly}) $]
<td class="cBase cGridControlBox">
- <img src="[+ $self -> {imagedir} +]/toup.gif" id="cmdUp" name="-up" title="Zeile Hoch" onclick="[+ $jsname +].upRow()">
- <img src="[+ $self -> {imagedir} +]/todown.gif" id="cmdDown" name="-down" title="Zeile runter" onclick="[+ $jsname +].downRow()">
- <img src="[+ $self -> {imagedir} +]/button_neu.gif" id="cmdAdd" name="-add" title="Zeile Hinzufügen Alt-NUM+" onclick="[+ $jsname +].addRow()">
- <img src="[+ $self -> {imagedir} +]/button_loeschen.gif" id="cmdDelete" name="-delete" title="Markierte Zeile Löschen Alt-NUM-" onclick="[+ $jsname +].delRow()">
+ <img src="[+ $self -> {imagedir} +]/btn_up.gif" id="[+ $self -> {id} +]-up" title="Zeile Hoch">
+ <img src="[+ $self -> {imagedir} +]/btn_down.gif" id="[+ $self -> {id} +]-down" title="Zeile runter">
+ <img src="[+ $self -> {imagedir} +]/btn_add.gif" id="[+ $self -> {id} +]-add" title="Zeile Hinzufügen Alt-NUM+" >
+ <img src="[+ $self -> {imagedir} +]/btn_del.gif" id="[+ $self -> {id} +]-del" title="Markierte Zeile Löschen Alt-NUM-" >
</td>
[$endif$]
</tr>
Modified: perl/embperl/trunk/Embperl/Form/Control/table.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/table.pm?rev=1080466&r1=1080465&r2=1080466&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/table.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/table.pm Fri Mar 11 06:53:44 2011
@@ -23,6 +23,16 @@ use Embperl::Inline ;
sub cellstyle { '' } ;
+sub show
+
+ {
+ my ($self, $req) = @_ ;
+
+ my $name = $self -> {name} ;
+ my $data = $Embperl::fdat{$name} ;
+ $self -> show_table ($data) ;
+ }
+
1 ;
__EMBPERL__
@@ -67,10 +77,17 @@ $]
<tr style="background: white">
[$foreach $c (@$line) $][-
$attr = ref $c?$c -> [0]:$c ;
- foreach my $prefix (@$dataprefix)
+ if (ref ($o) eq 'ARRAY')
+ {
+ $item = $o -> [$attr] ;
+ }
+ else
{
- last if ($prefix?($item = $o -> {$prefix}{$attr}):($item = $o -> {$attr}))
- }
+ foreach my $prefix (@$dataprefix)
+ {
+ last if ($prefix?($item = $o -> {$prefix}{$attr}):($item = $o -> {$attr}))
+ }
+ }
$item = ref $item?join ('; ',@$item):$item ;
if ($filter = $c -> [6])
{
@@ -112,8 +129,23 @@ $]
</tr>
[$endforeach$]
[$if $self -> {line2} $]
+ [-
+ $attr = $self -> {line2} ;
+ if (ref ($o) eq 'ARRAY')
+ {
+ $item = $o -> [$attr] ;
+ }
+ else
+ {
+ foreach my $prefix (@$dataprefix)
+ {
+ last if ($prefix?($item = $o -> {$prefix}{$attr}):($item = $o -> {$attr}))
+ }
+ }
+ $item = [$item] if (!ref $item) ;
+ -]
<tr>
- <td class="cControlBox" colspan="[+ scalar(@{$self->{columns}})+]">[+ join ('<br>', @{$o->{$self -> {line2}}}) +]</td>
+ <td class="cControlBox" colspan="[+ scalar(@{$self->{columns}})+]">[+ join ('<br>', @$item) +]</td>
</tr>
[$endif$]
[- $r++ -]
@@ -129,7 +161,7 @@ __END__
=head1 NAME
-Embperl::Form::Control::table - A table which get data from LDAP composed via joinAttrValue
+Embperl::Form::Control::table - A table which get data from array of arrays or array of hashs
=head1 SYNOPSIS
@@ -144,9 +176,12 @@ Embperl::Form::Control::table - A table
Used as a base class to create an table control inside an Embperl Form.
See Embperl::Form on how to specify parameters.
-You need to overwrite this class and call the method
-show_table. show_table takes an arrayref of hashrefs as parameter
+In most cases you need to overwrite this class and call the method
+show_table. show_table takes an arrayref of hashrefs or
+arrayref of arrays as parameter
which is used as data to display.
+In case you have this data directly in %fdat you can use this control
+directly.
=head2 PARAMETER
@@ -162,7 +197,7 @@ Will be used as label for the control
Arraryref which contains an arrayrefs with definition of columns names.
Allows to specify multiple rows per data entry. Column definition
-is either the name in the data hashref or an arrayref with the name in
+is either the key name in the data hashref or an arrayref with the name in
the hash ref and the text to display as heading. Example:
[
@@ -173,6 +208,8 @@ the hash ref and the text to display as
email and phone will be display on the first line with headings
'E-Mail Address' and 'Phone' and foo and bar will be displayed
on the second line for each entry.
+In case your data is an array of arrays you have to specifiy the
+array index instead of the hash key name.
It is possible to add additional information. One entry might
contain the following entries:
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-cvs-help@perl.apache.org