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 2008/01/30 07:40:03 UTC

svn commit: r616655 - in /perl/embperl/trunk/Embperl/Form: Control/grid.pm Control/radio.pm Control/selectdyn.pm Control/table.pm ControlMultValue.pm

Author: richter
Date: Tue Jan 29 22:40:03 2008
New Revision: 616655

URL: http://svn.apache.org/viewvc?rev=616655&view=rev
Log:
Embperl::Form enhancements

Modified:
    perl/embperl/trunk/Embperl/Form/Control/grid.pm
    perl/embperl/trunk/Embperl/Form/Control/radio.pm
    perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm
    perl/embperl/trunk/Embperl/Form/Control/table.pm
    perl/embperl/trunk/Embperl/Form/ControlMultValue.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=616655&r1=616654&r2=616655&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/grid.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/grid.pm Tue Jan 29 22:40:03 2008
@@ -86,6 +86,11 @@
         foreach my $field (@$fields)
             {
             $fdat{"$name-$field->{name}-$i"} = $data[$j++] ;
+            if ($field -> can ('init_data'))
+                {
+                local $field->{name} = "$name-$field->{name}-$i" ;
+                $field -> init_data ($req, $self)  ;
+                }
             }
         $i++ ;
         }
@@ -94,6 +99,18 @@
 
 # ------------------------------------------------------------------------------------------
 #
+#   prepare_fdat_sub - wird aufgerufen nachdem die einzelen Controls abgearbeitet sind abd
+#                   bevor die daten zusammenfuehrt werden
+#
+
+sub prepare_fdat_sub
+    {
+    my ($self, $req) = @_ ;
+    
+    }
+    
+# ------------------------------------------------------------------------------------------
+#
 #   prepare_fdat - daten zusammenfuehren
 #
 
@@ -111,6 +128,20 @@
     my $val ;
     for (my $i = 0; $i < $max; $i++)
         {
+        foreach my $field (@$fields)
+            {
+            if ((ref ($field) =~ /::/) && $field -> can ('prepare_fdat'))
+                {
+                local $field->{name} = "$name-$field->{name}-$i" ;
+                $field -> prepare_fdat ($req)  ;
+                }
+            }
+        }
+
+    $self -> prepare_fdat_sub ($req) if ((ref ($self) =~ /::/));
+
+    for (my $i = 0; $i < $max; $i++)
+        {
         $j = 0 ;
         my @data = ($i+1) ;
         foreach my $field (@$fields)
@@ -200,7 +231,7 @@
  $]
          <tr class="cGridHeader">
          [$ foreach my $field (@$fields) $]
-            <td class="cGridHeader" [$if($width = $field->{width})$]width="[+$width+]"[$endif$]>[+ $self -> form -> convert_label ($self, $field->{name}) +]</td>
+            <td class="cGridHeader" [$if($width = $field->{width})$]width="[+$width+]"[$endif$]>[+ $self -> form -> convert_label ($self, $field->{name}, $field->{text}) +]</td>
          [$ endforeach $]
          </tr>
 [$ endsub $]

Modified: perl/embperl/trunk/Embperl/Form/Control/radio.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/radio.pm?rev=616655&r1=616654&r2=616655&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/radio.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/radio.pm Tue Jan 29 22:40:03 2008
@@ -56,6 +56,14 @@
     $self -> show_control ($req, "^\Q$fdat{$name}\\E\$", $values, $options) ;
     }
 
+# ---------------------------------------------------------------------------
+
+sub show_control_addons
+    {
+    my ($self, $req) = @_ ;
+
+    }
+
 1 ;
 
 __EMBPERL__

Modified: perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm?rev=616655&r1=616654&r2=616655&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/selectdyn.pm Tue Jan 29 22:40:03 2008
@@ -36,6 +36,16 @@
     }
 
 
+# ---------------------------------------------------------------------------
+
+sub show_control_addons
+    {
+    my ($self, $req) = @_ ;
+
+    }
+    
+    
+
 
 1 ;
 
@@ -86,10 +96,22 @@
 [# --- Popup --- #]
 <div class="cPopupMenu" id="_menu_[+ $jsname +]"
 style="display:none; position: absolute; top: 15px; z-index: 99; margin: 0px; padding: 0px;
-border: 2px grey outset; background: white; text-align: center;"
+border: 2px grey outset; background: white; text-align: left;"
 >
 
 <a href="#" onClick="[+ $target +]location.href='ldapTreeData.epl?-id=' + encodeURIComponent([+ $jsname +]Popup.idval)">Anzeigen</a>&nbsp;
+
+[*
+    my $datasrc_ctrls      = $self -> get_datasource_controls ($req) ;
+*]
+[$if $datasrc_ctrls $]
+[$foreach my $ctrl (@$datasrc_ctrls) $]
+<a href="[+ do { local $escmode = 0 ; $ctrl->{href} } +]" target="[+ $self->{link_target} +]" onClick="[+ $ctrl->{onclick} +]">[+ $ctrl -> {text} +]</a>&nbsp;
+[#<a class="cControlAddonA" href="[+ $ctrl->{href} +]" onClick="[+ $ctrl->{onclick} +]">[$if $ctrl -> {icon} $]<img class="cControlAddonImg" src="[+ $ctrl -> {icon} +]" title="[+ $ctrl -> {text} +]" alt="[+ $ctrl -> {text} +]">[$else$][+ $ctrl -> {text} +][$endif$]</a>#]
+[$endforeach$]
+[$endif$]
+
+
 [#
 <a href="#" onClick="alert('ldapTreeData.epl?-id=' + [+ $jsname +]Popup.idval)">Durchsuchen</a>&nbsp;
 <a href="ldapTreeData?-id=">Neu</a>
@@ -103,13 +125,16 @@
 </div>
 
 [# --- input --- #]
-<input class="cBase cControl cAutoCompInput" id="_inp_[+ $jsname +]" type="text"
+<input class="cBase cControl cAutoCompInput cControlWidthSelectDyn" id="_inp_[+ $jsname +]" type="text"
 [$if $self -> {size} $]size="[+ $self->{size} +]"[$endif$]
 value="[+ $initval +]"
 onDblClick="u='ldapTreeData.epl?-id=' + encodeURIComponent(document.getElementById('[+ $name +]').value);[+ $target +]location.href=u;"
+onContextMenu="[+ $jsname +]Popup.showPopup(); return false ;"
 >
+[#
 <div  class="cAutoCompArrow" onclick="[+ $jsname +]Popup.showPopup()"
 >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
+#]
 <input type="hidden" name="[+ $name +]" id="[+ $name +]" >
 </div>
 

Modified: perl/embperl/trunk/Embperl/Form/Control/table.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/table.pm?rev=616655&r1=616654&r2=616655&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/table.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/table.pm Tue Jan 29 22:40:03 2008
@@ -21,6 +21,8 @@
 
 use Embperl::Inline ;
 
+sub cellstyle { '' } ;
+
 1 ;
 
 __EMBPERL__
@@ -49,19 +51,26 @@
 [$foreach $line (@{$self->{columns}}) $]
 <tr style="background: white">
 [$foreach $c (@$line) $]
-<td colspan="[+ ref $c?$c -> [2] || 1:1 +]" class="[+$self -> {line2} || (@{$self->{columns}} > 1 && $i == 0)?'cGridLabelBox':'cControlBox'+]">[+ $showtext?(ref $c?$c -> [1] || $c -> [0]:$c):$self -> form -> convert_label ($self, ref $c?$c -> [1]:$c) +]</td>
+<td colspan="[+ ref $c?$c -> [2] || 1:1 +]" class="[+$self -> {line2} || (@{$self->{columns}} > 1 && $i == 0)?'cGridLabelBox':'cControlBox'+]  cLdapReportColumnHead">[+ $showtext?(ref $c?$c -> [1] || $c -> [0]:$c):$self -> form -> convert_label ($self, ref $c?$c -> [1]:$c) +]</td>
 [$endforeach$]
 [- $i++ -]
 </tr>
 [$endforeach$]
 
 [# --- data --- #]
+[- $r = 0 -]
 [$foreach $o (@$data) $]
 [- $i = 0 -]
 [$foreach $line (@{$self->{columns}}) $]
 <tr style="background: white">
-[$foreach $c (@$line) $]
-<td colspan="[+ ref $c?$c -> [2] || 1:1 +]" class="[+$self -> {line2} || (@{$self->{columns}} > 1 && $i == 0)?'cGridLabelBox':'cControlBox'+]">[- $item = ref $c?$o -> {$c -> [0]}:$o -> {$c} -][+ ref $item?join ('; ',@$item):$item +]</td>
+[$foreach $c (@$line) $][-
+    $attr = ref $c?$c -> [0]:$c ;
+    $item = $o -> {$attr}
+    -]<td colspan="[+ ref $c?$c -> [2] || 1:1 +]" class="[# +$self -> {line2} || (@{$self->{columns}} > 1 && $i == 0)?'cGridLabelBox':'cControlBox'+ #] cLdapReportTd" style="[+ $self -> cellstyle ($item, $o, $r, $i, $attr) +]">[$ if $c -> [3] && ($item =~ /^&(.*?),(.*?),(.*)$/) $]
+            [$ if $1 eq 'checkbox' $]<input type="checkbox" name="[+ $2 +]" value="[+ $3 +]">[$endif$]
+            [$ if $1 eq 'radio' $]<input type="radio" name="[+ $2 +]" value="[+ $3 +]">[$endif$]
+            [$elsif ($c -> [4] && $o -> {$c -> [4]}) $]<a href="[+ do { local $escmode = 0 ; $o -> {$c -> [4]} } +]" target="[+ $c -> [5] +]">[+ ref $item?join ('; ',@$item):$item +]</a>
+            [$else$][+ ref $item?join ('; ',@$item):$item +][$endif$]</td>
 [$endforeach$]
 [- $i++ -]
 </tr>
@@ -71,6 +80,7 @@
     <td class="cControlBox" colspan="[+ scalar(@{$self->{columns}})+]">[+ join ('<br>', @{$o->{$self -> {line2}}}) +]</td>
     </tr>
 [$endif$]
+[- $r++ -]
 [$endforeach$]
 </table>
 </td>
@@ -127,6 +137,40 @@
 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.
+
+It is possible to add additional information. One entry might
+contain the following entries:
+
+=over
+
+=item 0
+
+Key for into data hashref
+
+=item 1
+
+Text to display
+
+=item 2
+
+Colspan (how many colums this cell should span)
+
+=item 3
+
+If set a control is displayed instead of a text. Must contain:
+
+radio,<name>,<value> or checkbox,<name>,<value>
+
+=item 4
+
+Display as link. This item contains the name of the key in the data hashref
+that holds the href.
+
+=item 5
+
+target for link
+
+=back
 
 =head3 line2
 

Modified: perl/embperl/trunk/Embperl/Form/ControlMultValue.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/ControlMultValue.pm?rev=616655&r1=616654&r2=616655&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/ControlMultValue.pm (original)
+++ perl/embperl/trunk/Embperl/Form/ControlMultValue.pm Tue Jan 29 22:40:03 2008
@@ -118,7 +118,9 @@
 
 [$ sub show_control_addons ($self, $req)
  
-    my $datasrc_ctrls      = $self -> get_datasource_controls ($req) ;
+my $datasrc_ctrls  ;
+$datasrc_ctrls = $self -> get_datasource_controls ($req)
+    unless ($self -> {no_datasource_controls}) ;
 
 $][$if $datasrc_ctrls $]
 [$foreach my $ctrl (@$datasrc_ctrls) $]
@@ -182,6 +184,10 @@
 values and options parameters. Either a full package name or
 a name, in which case all packages which are returned
 by Embperl::Form::get_datasrc_packages are searched.
+
+=head3 no_datasource_controls
+
+Disables the output of the additional controls
 
 =head1 AUTHOR
 



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-cvs-help@perl.apache.org