perl-embperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject svn commit: r1132733 - in /perl/embperl/trunk/Embperl/Form/Control: datetime.pm duration.pm grid.pm inputjoin.pm mult.pm price.pm
Date Mon, 06 Jun 2011 19:37:27 GMT
Author: richter
Date: Mon Jun  6 19:37:27 2011
New Revision: 1132733

URL: http://svn.apache.org/viewvc?rev=1132733&view=rev
Log:
Changes for jQuery

Modified:
    perl/embperl/trunk/Embperl/Form/Control/datetime.pm
    perl/embperl/trunk/Embperl/Form/Control/duration.pm
    perl/embperl/trunk/Embperl/Form/Control/grid.pm
    perl/embperl/trunk/Embperl/Form/Control/inputjoin.pm
    perl/embperl/trunk/Embperl/Form/Control/mult.pm
    perl/embperl/trunk/Embperl/Form/Control/price.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=1132733&r1=1132732&r2=1132733&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/datetime.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/datetime.pm Mon Jun  6 19:37:27 2011
@@ -53,9 +53,10 @@ sub init
 sub init_data
     {
     my ($self, $req, $parentctrl) = @_ ;
-    
+
+    my $fdat  = $req -> {docdata} || \%fdat ;
     my $name    = $self->{name} ;
-    my $time    = $fdat{$name} ;
+    my $time    = $fdat->{$name} ;
     return if ($time eq '') ;
 
     my ($y, $m, $d, $h, $min, $s, $z) = ($time =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(.)/)
;
@@ -75,7 +76,7 @@ sub init_data
 	$date = $time ;
 	}
 
-    $fdat{$name} = $date ;
+    $fdat->{$name} = $date ;
     }
 
 # ------------------------------------------------------------------------------------------
@@ -86,11 +87,12 @@ sub init_data
 sub prepare_fdat
     {
     my ($self, $req) = @_ ;
-
+
     return if ($self -> {readonly}) ;
     
+    my $fdat  = $req -> {form} || \%fdat ;
     my $name    = $self->{name} ;
-    my $date    = $fdat{$name} ;
+    my $date    = $fdat -> {$name} ;
     return if ($date eq '') ;
     
     my ($year, $mon, $day, $hour, $min, $sec) ;
@@ -112,7 +114,7 @@ sub prepare_fdat
 	    }
         ($day, $mon, $year) = map { $_ + 0 } split (/\./, $d) ;
         ($hour, $min, $sec) = map { $_ + 0 } split (/\:/, $t) ;
-
+
         if ($year == 0 || $mon == 0 || $day == 0)
             {
             my ($s, $min, $h, $md, $m, $y) = localtime ;
@@ -140,7 +142,7 @@ sub prepare_fdat
                             0, 0, -$tz_local, 0) if ($hour || $min || $sec) ;
         }
 
-    $fdat{$name} = $year?sprintf ('%04d%02d%02d%02d%02d%02dZ', $year, $mon, $day, $hour,
$min, $sec):'' ;
+    $fdat -> {$name} = $year?sprintf ('%04d%02d%02d%02d%02d%02dZ', $year, $mon, $day,
$hour, $min, $sec):'' ;
     }
 
 1 ;
@@ -165,7 +167,7 @@ $]
 [$if $self -> {maxlength} $]maxlength="[+ $self->{maxlength} +]"[$endif$]
 >
 <script type="text/javascript">
-  [+ $nsprefix +]Calendar.setup(
+   [+ $nsprefix +]Calendar.setup(
     {
       inputField  : document.getElementById('[+ $self -> {id} +]'),         // ID of the
input field
       ifFormat    : "%d.%m.%Y",    // the date format

Modified: perl/embperl/trunk/Embperl/Form/Control/duration.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/duration.pm?rev=1132733&r1=1132732&r2=1132733&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/duration.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/duration.pm Mon Jun  6 19:37:27 2011
@@ -47,8 +47,9 @@ sub init_data
     {
     my ($self, $req, $parentctrl) = @_ ;
     
+    my $fdat  = $req -> {docdata} || \%fdat ;
     my $name    = $self->{name} ;
-    my $val     = $fdat{$name} ;
+    my $val     = $fdat->{$name} ;
     return if ($val eq '') ;
 
     my $aval = abs ($val) ;
@@ -61,7 +62,7 @@ sub init_data
 	{
 	$duration .= sprintf (':%02d', $sec) ;
 	}
-    $fdat{$name} = $duration ;
+    $fdat->{$name} = $duration ;
     }
 
 # ------------------------------------------------------------------------------------------
@@ -73,8 +74,9 @@ sub prepare_fdat
     {
     my ($self, $req) = @_ ;
 
+    my $fdat  = $req -> {form} || \%fdat ;
     my $name    = $self->{name} ;
-    my $val     = $fdat{$name} ;
+    my $val     = $fdat->{$name} ;
     return if ($val eq '') ;
     
     my $neg = 0 ;
@@ -83,8 +85,8 @@ sub prepare_fdat
      
 
         
-    $fdat{$name} = @vals == 1?$vals[0] * 60:$vals[0] * 3600 + $vals[1] * 60 + $vals[2] ;
-    $fdat{$name} = - $fdat{$name} if ($neg) ;
+    $fdat->{$name} = @vals == 1?$vals[0] * 60:$vals[0] * 3600 + $vals[1] * 60 + $vals[2]
;
+    $fdat->{$name} = - $fdat{$name} if ($neg) ;
     }
 
 1 ;

Modified: perl/embperl/trunk/Embperl/Form/Control/grid.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/grid.pm?rev=1132733&r1=1132732&r2=1132733&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/grid.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/grid.pm Mon Jun  6 19:37:27 2011
@@ -72,9 +72,10 @@ sub init_data
     {
     my ($self, $req) = @_ ;
     
+    my $fdat  = $req -> {docdata} || \%fdat ;
     my $ldap    = $req->{ldap};
     my $name    = $self->{name} ;
-    my @entries = ref $fdat{$name} eq 'ARRAY'?@{$fdat{$name}}:split("\t",$fdat{$name});
+    my @entries = ref $fdat->{$name} eq 'ARRAY'?@{$fdat->{$name}}:split("\t",$fdat->{$name});
     my $fields  = $self -> {fields} ;
 
     my $data;
@@ -89,7 +90,7 @@ sub init_data
         foreach my $field (@$fields)
             {
             $col = exists $field -> {col}?$field -> {col}:$j ;
-            $fdat{"$name-$field->{name}-$i"} = $data->[$col] ;
+            $fdat->{"$name-$field->{name}-$i"} = $data->[$col] ;
             if ($field -> can ('init_data'))
                 {
                 local $field->{name} = "$name-$field->{name}-$i" ;
@@ -99,7 +100,7 @@ sub init_data
             }
         $i++ ;
         }
-    $fdat{"$name-max"} = $i?$i:1;
+    $fdat->{"$name-max"} = $i?$i:1;
     }
 
 # ------------------------------------------------------------------------------------------
@@ -124,11 +125,12 @@ sub prepare_fdat
     my ($self, $req) = @_ ;
     
     return if ($self -> {readonly}) ;
-    
+   
+    my $fdat  = $req -> {form} || \%fdat ;
     my $ldap    = $req->{ldap};
     my $name    = $self->{name} ;
     my $fields  = $self -> {fields} ;
-    my $max     = $fdat{"$name-max"} ;
+    my $max     = $fdat->{"$name-max"} ;
 
     my @rows;
     my $j ;
@@ -152,7 +154,8 @@ sub prepare_fdat
         
 	next if (!$ok) ;
 
-        $order = $fdat{"$name-#row#-$i"} ;
+        $order = $fdat->{"$name-#row#-$i"} ;
+        next if (!defined($order)) ;
         $order = $i + 10000 if (!defined($order)) ;
         $orders{$order} = $i ;
         }
@@ -167,13 +170,19 @@ sub prepare_fdat
         foreach my $field (@$fields)
             {
             $col = exists $field -> {col}?$field -> {col}:$j ;
-            $data[$col+1] = $fdat{"$name-$field->{name}-$i"} ;
+            $data[$col+1] = $fdat->{"$name-$field->{name}-$i"} ;
             $j++ ;
             }
-        $val = ecos::LdapBase -> joinAttrValue(\@data) ;
+        $val = $ldap?ecos::LdapBase -> joinAttrValue(\@data):\@data ;
         push @rows, $val if ($val ne '') ;    
         }
-    $fdat{$name} = \@rows ;    
+    $fdat->{$name} = \@rows ;
+    
+    
+    foreach my $key (keys %$fdat)
+        {
+        delete $fdat->{$key} if ($key =~ /^\Q$name-\E/) ;
+        }
     }
 
 1 ;
@@ -195,6 +204,7 @@ __EMBPERL__
     $jsname =~ s/[^a-zA-Z0-9]/_/g ;
     $jsname .= 'Grid' ;
     my $max    = $fdat{"$name-max"} ;
+    my $on_grid_change = $self -> {on_grid_change} ;
 $]
   <td class="cBase cLabelBox" colspan="[+ $span +]">
   [-
@@ -216,7 +226,7 @@ $]
     -]
   </table>
   <script>
-       $('#[+ $self -> {id} +]').eplgrid () ;
+       $('#[+ $self -> {id} +]').eplgrid ([$if $on_grid_change $]{'onchange': [+ $on_grid_change
+] }[$endif$]) ;
        [#
       [+ $jsname +] = new [+ $nsprefix +]Grid (document.getElementById('[+ $self -> {id}
+]'),
                                                document.getElementById('[+ $self -> {id}
+]-newrow'),
@@ -360,6 +370,10 @@ Column number inside the @data array, wh
 
 =back
 
+=head3 on_grid_change
+
+JavaScrip function that is called whan grid changes (i.e. add row, delete row etc.)
+
 =head3 header_bottom
 
 If grid has more rows as given in this parameter,

Modified: perl/embperl/trunk/Embperl/Form/Control/inputjoin.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/inputjoin.pm?rev=1132733&r1=1132732&r2=1132733&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/inputjoin.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/inputjoin.pm Mon Jun  6 19:37:27 2011
@@ -32,14 +32,15 @@ sub init_data
     {
     my ($self, $req) = @_ ;
     
+    my $fdat  = $req -> {docdata} || \%fdat ;
     my $name  = $self -> {name} ;
     my $split = $self -> {split} || $self -> {join} ;
     my $num   = $self -> {numinputs} || 1 ;
     my $i     = 0 ;
-    my @vals  = split /$split/, $fdat{$name} ;
+    my @vals  = split /$split/, $fdat->{$name} ;
     for (my $i = 0; $i < $num; $i++)
 	{
-	$fdat{"$name-_-$i"} = $vals[$i] ;
+	$fdat->{"$name-_-$i"} = $vals[$i] ;
 	}
     }
 
@@ -52,15 +53,16 @@ sub prepare_fdat
     {
     my ($self, $req) = @_ ;
     
+    my $fdat  = $req -> {form} || \%fdat ;
     my $name  = $self -> {name} ;
     my $join  = $self -> {join} ;
     my $num   = $self -> {numinputs} || 1 ;
     my @vals ;
     for (my $i = 0; $i < $num; $i++)
 	{
-	push @vals, $fdat{"$name-_-$i"} ;
+	push @vals, $fdat->{"$name-_-$i"} ;
 	}
-    $fdat{$name} = join ($join, @vals) ;
+    $fdat->{$name} = join ($join, @vals) ;
     }
 
 

Modified: perl/embperl/trunk/Embperl/Form/Control/mult.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/mult.pm?rev=1132733&r1=1132732&r2=1132733&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/mult.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/mult.pm Mon Jun  6 19:37:27 2011
@@ -69,18 +69,18 @@ sub init_data
     {
     my ($self, $req) = @_ ;
     
-    my $ldap    = $req->{ldap};
+    my $fdat  = $req -> {docdata} || \%fdat ;
     my $name    = $self->{name} ;
-    my @entries = split("\t",$fdat{$name});
+    my @entries = split("\t",$fdat->{$name});
 
     my $i = 0 ;
     foreach my $entry (@entries)
         {
-        $fdat{"$name--$i"} = $entry ;
+        $fdat->{"$name--$i"} = $entry ;
             
         $i++ ;
         }
-    $fdat{"$name-max"} = $i?$i:1;
+    $fdat->{"$name-max"} = $i?$i:1;
     }
 
 # ------------------------------------------------------------------------------------------
@@ -91,18 +91,19 @@ sub init_data
 sub prepare_fdat
     {
     my ($self, $req) = @_ ;
+    my $fdat  = $req -> {form} || \%fdat ;
     my $ldap    = $req->{ldap};
     my $name    = $self->{name} ;
-    my $max     = $fdat{"$name-max"} || 1 ;
+    my $max     = $fdat->{"$name-max"} || 1 ;
 
     my @rows;
     my $val ;
     for (my $i = 0; $i < $max; $i++)
         {
-        $val = $fdat{"$name--$i"} ;
+        $val = $fdat->{"$name--$i"} ;
         push @rows, $val if ($val ne '') ;
         }
-    $fdat{$name} = \@rows ;    
+    $fdat->{$name} = \@rows ;    
     }
 
 sub show { Embperl::Form::Control::show (@_) } 

Modified: perl/embperl/trunk/Embperl/Form/Control/price.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/price.pm?rev=1132733&r1=1132732&r2=1132733&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/price.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/price.pm Mon Jun  6 19:37:27 2011
@@ -48,9 +48,10 @@ sub init_data
     {
     my ($self, $req, $parentctrl) = @_ ;
     
+    my $fdat  = $req -> {docdata} || \%fdat ;
     delete $self -> {unit} if ($parentctrl) ;
     my $name    = $self->{name} ;
-    my $val     = $fdat{$name} ;
+    my $val     = $fdat->{$name} ;
     return if ($val eq '') ;
 
     my $sep ;
@@ -81,7 +82,7 @@ sub init_data
     $int[0] =~ s/^0+// ;
     $int[0] = '0' if (@int == 1 && !$int[0]) ;
     $frac   = substr ($frac . '00', 0, 2) ;
-    $fdat{$name} = ($minus?'-':'') . join ($sep, @int) . $dec . $frac ;
+    $fdat->{$name} = ($minus?'-':'') . join ($sep, @int) . $dec . $frac ;
     }
 
 # ------------------------------------------------------------------------------------------
@@ -93,8 +94,9 @@ sub prepare_fdat
     {
     my ($self, $req) = @_ ;
 
+    my $fdat  = $req -> {form} || \%fdat ;
     my $name    = $self->{name} ;
-    my $val     = $fdat{$name} ;
+    my $val     = $fdat->{$name} ;
     return if ($val eq '') ;
     
     $val =~ s/\s+//g ;
@@ -104,7 +106,7 @@ sub prepare_fdat
         $val =~ s/\,/./ ;
         }
         
-    $fdat{$name} = $val + 0 ;
+    $fdat->{$name} = $val + 0 ;
     }
 
 1 ;



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


Mime
View raw message