Mailing List Archive

svn commit: r1676669 - /perl/embperl/trunk/Embperl/Form/Control/attachment.pm
Author: richter
Date: Wed Apr 29 04:59:20 2015
New Revision: 1676669

URL: http://svn.apache.org/r1676669
Log:
Implement attachement control readonly display

Modified:
perl/embperl/trunk/Embperl/Form/Control/attachment.pm

Modified: perl/embperl/trunk/Embperl/Form/Control/attachment.pm
URL: http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/attachment.pm?rev=1676669&r1=1676668&r2=1676669&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/attachment.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/attachment.pm Wed Apr 29 04:59:20 2015
@@ -42,24 +42,50 @@ our @divs =
1 => 'B',
) ;

+# ---------------------------------------------------------------------------
+#
+# should_init_data - returns true if init_data should be called for this control
+#
+
+sub should_init_data

-sub init_data
{
- my ($self, $req, $parentctrl, $force) = @_ ;
-
- my $fdat = $req -> {docdata} || \%fdat ;
- my $name = $self->{name} ;
- my $val = $fdat->{$name} ;
+ my ($self, $req) = @_ ;
+
+ return !$self -> is_disabled ($req) ;
+ }
+
+# ------------------------------------------------------------------------------------------
+#
+# get_display_text - returns the text that should be displayed
+#
+
+sub get_display_text
+ {
+ my ($self, $req, $val) = @_ ;
return if ($val eq '' || ($val !~ /^\d+$/)) ;

for (my $i = 0; $i < @divs; $i +=2)
{
if ($val >= $divs[$i])
{
- $fdat->{$name} = int ($val /$divs[$i]) . ' ' . $divs[$i+1] ;
- return ;
+ return int ($val /$divs[$i]) . ' ' . $divs[$i+1] ;
}
}
+ return ;
+ }
+
+
+sub init_data
+ {
+ my ($self, $req, $parentctrl, $force) = @_ ;
+
+ my $fdat = $req -> {docdata} || \%fdat ;
+ my $name = $self->{name} ;
+ my $val = $fdat->{$name} ;
+ return if ($val eq '' || ($val !~ /^\d+$/)) ;
+
+ $fdat->{$name} = $self -> get_display_text ($req, $val) ;

return ;
}
@@ -84,7 +110,7 @@ $]
[$if !$self -> {no_upload} $]<a class="ef-attachment-upload" href="#">Upload</a>&nbsp;[$endif$]
[$if !$self -> {no_delete} $]<a class="ef-attachment-delete" href="#">L&ouml;schen</a>&nbsp;[$endif$]
<input type="file" multiple style="display: none" name=[+ $name +]>&nbsp;
- <div _ef_divname="[+ $name +]" class="ef-attachment-info"></div>
+ <div _ef_divname="[+ $name +]" class="ef-attachment-info">[+ $fdat{$name} +]</div>
</div>
[$ endsub $]

@@ -98,10 +124,10 @@ $]
my $name = $self -> {name};

$]
-<div [.+ do { local $escmode = 0 ; $self -> get_std_control_attr($req) } +] _ef_attach="ef_attachment" _ef_dynid="<_id>" _ef_attr="[+ $name +] _ef_always_download="[+ $self -> {always_download} +]">
+<div [.+ do { local $escmode = 0 ; $self -> get_std_control_attr($req) } +] _ef_attach="ef_attachment" _ef_dynid="<_id>" _ef_attr="[+ $name +]" _ef_always_download="[+ $self -> {always_download} +]">
[$if !$self -> {no_download} $]<a class="ef-attachment-download" href="#">Download</a>&nbsp;[$endif$]
<input type="file" multiple style="display: none" name=[+ $name +]>&nbsp;
- <div _ef_divname="[+ $name +]" class="ef-attachment-info"></div>
+ <div _ef_divname="[+ $name +]" class="ef-attachment-info">[+ $fdat{$name} +]</div>
</div>
[$ endsub $]




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