r4916 - in trunk: lib/style/common/templates src/perl

walbridge at ecoinformatics.org walbridge at ecoinformatics.org
Mon Apr 13 16:27:23 PDT 2009


Author: walbridge
Date: 2009-04-13 16:27:23 -0700 (Mon, 13 Apr 2009)
New Revision: 4916

Modified:
   trunk/lib/style/common/templates/entryForm.js
   trunk/src/perl/register-dataset.cgi
Log:
Further fixes to handle mixed-file uploads:
 - set the fileCount object based on upCount existing files
 - use ucount only if it exists; remove debugging'     
 - the entry form javascript now correctly tracks the file numbers, and can be relied on instead of using upCount

Cosmetic:
 - fix large boxes appearing around new keywords / associated parties / taxons by forcing them to use corrected style


k
M    lib/style/common/templates/entryForm.js
M    src/perl/register-dataset.cgi


Modified: trunk/lib/style/common/templates/entryForm.js
===================================================================
--- trunk/lib/style/common/templates/entryForm.js	2009-04-13 23:13:49 UTC (rev 4915)
+++ trunk/lib/style/common/templates/entryForm.js	2009-04-13 23:27:23 UTC (rev 4916)
@@ -208,6 +208,13 @@
     return count;
 }
 
+function setCount(_count, val) {
+    var countField = document.getElementById(_count);
+    var count = countField.getAttribute("value");
+    countField.setAttribute("value", val);
+    return count;
+}
+
 function createImageLink(imgSrc, imgAlt, imgOnClick, cursor) {
     var link = document.createElement("a");
     var img = document.createElement("img");
@@ -396,7 +403,8 @@
     labelTD.appendChild(createHiddenInput("aoRole", AORole));
     
     var imgTD = createTD("","right");
-    
+    imgTD.className = 'rightCol';
+        
     imgTD.appendChild(createImageLink(contextUrl + "/style/images/previous.gif",
                                       "Move Up","moveUpRow(event)","pointer"));
     imgTD.appendChild(document.createTextNode(" "));
@@ -551,6 +559,8 @@
     labelTD.appendChild(createHiddenInput("taxonRank", taxonRank));
     
     var imgTD = createTD("","right");
+    imgTD.className = 'rightCol';
+
     imgTD.appendChild(createImageLink(contextUrl + "/style/images/previous.gif",
                                       "Move Up", "moveUpRow(event)",
                                       "pointer"));
@@ -676,6 +686,8 @@
     labelTD.appendChild(createHiddenInput("keywordTh", keywordTh));
     
     var imgTD = createTD("","right");
+    imgTD.className = 'rightCol';
+
     imgTD.appendChild(createImageLink(contextUrl + "/style/images/previous.gif",
                                       "Move Up", "moveUpRow(event)",
                                       "pointer"));
@@ -1001,9 +1013,8 @@
         this.id = fcount.value;
     } else {
         // upCount contains pre-existing uploads, check this for editing existing packages
-        if (ucount.value > 0) {
+        if (ucount != null && ucount.value > 0) {
             this.id = ucount.value;
-            alert(this.id);
         }
     }
 
@@ -1028,8 +1039,14 @@
 
             // What to do when a file is selected
             element.onchange = function() {
-            // Increment file counter
-            var fileCount = incrementCount("fileCount");
+                // Increment file counter
+                var fileCount = incrementCount("fileCount");
+                // If pre-existing uploads exist, make sure the fileCount is synced
+                if (ucount != null && ucount.value > 0) {
+                    fileCount += ucount.value;
+                    setCount("fileCount", fileCount);
+                }
+
                 // Clean up file text
                 var comment_element = document.getElementById( 'file_comment' );
                 if (comment_element) {

Modified: trunk/src/perl/register-dataset.cgi
===================================================================
--- trunk/src/perl/register-dataset.cgi	2009-04-13 23:13:49 UTC (rev 4915)
+++ trunk/src/perl/register-dataset.cgi	2009-04-13 23:27:23 UTC (rev 4916)
@@ -3846,12 +3846,10 @@
             debug("Processing file: $fn");
             # Upload the file object itself to a temporary file, copy file metadata to form
             my $fileInfo = processFile($fileName);
-            # if we have existing uploads, increment the counter to avoid overwriting
-            my $totalFileNum = $fileNum + $FORM::upCount;
-            $$templateVars{"upload_$totalFileNum"} = $fileInfo->{'fileHash'};
-            $$templateVars{"uploadname_$totalFileNum"} = $fileInfo->{'fileName'};
-            $$templateVars{"uploadtype_$totalFileNum"} = $fileInfo->{'contentType'};
-            $$templateVars{"uploadperm_$totalFileNum"} = param("uploadperm_$fileNum");
+            $$templateVars{"upload_$fileNum"} = $fileInfo->{'fileHash'};
+            $$templateVars{"uploadname_$fileNum"} = $fileInfo->{'fileName'};
+            $$templateVars{"uploadtype_$fileNum"} = $fileInfo->{'contentType'};
+            $$templateVars{"uploadperm_$fileNum"} = param("uploadperm_$fileNum");
             $uploadCount++;
         }
     }



More information about the Metacat-cvs mailing list