[LON-CAPA-cvs] cvs: loncom /interface lonspreadsheet.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 02 Jul 2002 21:57:38 -0000


www		Tue Jul  2 17:57:38 2002 EDT

  Modified files:              
    /loncom/interface	lonspreadsheet.pm 
  Log:
  Towards bug 507.
  Has buttons now, but adds too many rows.
  
  
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.91 loncom/interface/lonspreadsheet.pm:1.92
--- loncom/interface/lonspreadsheet.pm:1.91	Sat Jun  8 11:27:06 2002
+++ loncom/interface/lonspreadsheet.pm	Tue Jul  2 17:57:38 2002
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.91 2002/06/08 15:27:06 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.92 2002/07/02 21:57:38 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -863,9 +863,11 @@
     my @cols=();
     if ($n) {
        my ($usy,$ufn)=split(/\_\_\&\&\&\_\_/,$f{'A'.$n});
+      if ($rl{$usy}) {
        $cols[0]=$rl{$usy}.'<br>'.
                 '<select name="sel_'.$n.'" onChange="changesheet('.$n.
                 ')"><option name="default">Default</option>';
+      } else { $cols[0]=''; }
        foreach (@os) {
            $cols[0].='<option name="'.$_.'"';
             if ($ufn eq $_) {
@@ -1466,6 +1468,7 @@
     $fn=$tmpdir.$fn.'.tmp';
     my $fh;
     my %fo=();
+    my $countrows=0;
     if ($fh=Apache::File->new($fn)) {
         my $name;
         while ($name=<$fh>) {
@@ -1473,6 +1476,7 @@
             my $value=<$fh>;
             chomp($value);
             $fo{$name}=$value;
+            $countrows++;
         }
     }
     if ($nform eq 'changesheet') {
@@ -1480,6 +1484,12 @@
         unless ($ENV{'form.sel_'.$nfield} eq 'Default') {
 	    $fo{'A'.$nfield}.='__&&&__'.$ENV{'form.sel_'.$nfield};
         }
+    } elsif ($nfield eq 'insertrow') {
+        if ($nform eq 'top') {
+	    $fo{'A'.$countrows}='AAAAA_'.$countrows;
+        } else {
+            $fo{'A'.$countrows}='zzzzz_'.$countrows;
+        }
     } else {
        if ($nfield) { $fo{$nfield}=$nform; }
     }
@@ -2452,6 +2462,12 @@
         document.sheet.submit();
     }
 
+    function insertrow(cn) {
+	document.sheet.unewfield.value='insertrow';
+        document.sheet.unewformula.value=cn;
+        document.sheet.submit();
+    }
+
 </script>
 ENDSCRIPT
     $r->print('</head><body bgcolor="#FFFFFF">'.
@@ -2675,6 +2691,17 @@
        if ($ENV{'form.showcsv'}) { $r->print(' checked'); }
        $r->print('>');
     }
+
+# ------------------------------------------------------------------ Insertrows
+
+   $r->print(<<ENDINSERTBUTTONS);
+<br>
+<input type='button' onClick='insertrow("top");' 
+value='Insert Row Top'>
+<input type='button' onClick='insertrow("bottom");' 
+value='Insert Row Bottom'><br>
+ENDINSERTBUTTONS
+
 # ------------------------------------------------------------- Print out sheet
 
     &outsheet($r,$asheet);