Project

General

Profile

« Previous | Next » 

Revision 4916

Added by walbridge about 15 years ago

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

View differences:

lib/style/common/templates/entryForm.js
208 208
    return count;
209 209
}
210 210

  
211
function setCount(_count, val) {
212
    var countField = document.getElementById(_count);
213
    var count = countField.getAttribute("value");
214
    countField.setAttribute("value", val);
215
    return count;
216
}
217

  
211 218
function createImageLink(imgSrc, imgAlt, imgOnClick, cursor) {
212 219
    var link = document.createElement("a");
213 220
    var img = document.createElement("img");
......
396 403
    labelTD.appendChild(createHiddenInput("aoRole", AORole));
397 404
    
398 405
    var imgTD = createTD("","right");
399
    
406
    imgTD.className = 'rightCol';
407
        
400 408
    imgTD.appendChild(createImageLink(contextUrl + "/style/images/previous.gif",
401 409
                                      "Move Up","moveUpRow(event)","pointer"));
402 410
    imgTD.appendChild(document.createTextNode(" "));
......
551 559
    labelTD.appendChild(createHiddenInput("taxonRank", taxonRank));
552 560
    
553 561
    var imgTD = createTD("","right");
562
    imgTD.className = 'rightCol';
563

  
554 564
    imgTD.appendChild(createImageLink(contextUrl + "/style/images/previous.gif",
555 565
                                      "Move Up", "moveUpRow(event)",
556 566
                                      "pointer"));
......
676 686
    labelTD.appendChild(createHiddenInput("keywordTh", keywordTh));
677 687
    
678 688
    var imgTD = createTD("","right");
689
    imgTD.className = 'rightCol';
690

  
679 691
    imgTD.appendChild(createImageLink(contextUrl + "/style/images/previous.gif",
680 692
                                      "Move Up", "moveUpRow(event)",
681 693
                                      "pointer"));
......
1001 1013
        this.id = fcount.value;
1002 1014
    } else {
1003 1015
        // upCount contains pre-existing uploads, check this for editing existing packages
1004
        if (ucount.value > 0) {
1016
        if (ucount != null && ucount.value > 0) {
1005 1017
            this.id = ucount.value;
1006
            alert(this.id);
1007 1018
        }
1008 1019
    }
1009 1020

  
......
1028 1039

  
1029 1040
            // What to do when a file is selected
1030 1041
            element.onchange = function() {
1031
            // Increment file counter
1032
            var fileCount = incrementCount("fileCount");
1042
                // Increment file counter
1043
                var fileCount = incrementCount("fileCount");
1044
                // If pre-existing uploads exist, make sure the fileCount is synced
1045
                if (ucount != null && ucount.value > 0) {
1046
                    fileCount += ucount.value;
1047
                    setCount("fileCount", fileCount);
1048
                }
1049

  
1033 1050
                // Clean up file text
1034 1051
                var comment_element = document.getElementById( 'file_comment' );
1035 1052
                if (comment_element) {
src/perl/register-dataset.cgi
3846 3846
            debug("Processing file: $fn");
3847 3847
            # Upload the file object itself to a temporary file, copy file metadata to form
3848 3848
            my $fileInfo = processFile($fileName);
3849
            # if we have existing uploads, increment the counter to avoid overwriting
3850
            my $totalFileNum = $fileNum + $FORM::upCount;
3851
            $$templateVars{"upload_$totalFileNum"} = $fileInfo->{'fileHash'};
3852
            $$templateVars{"uploadname_$totalFileNum"} = $fileInfo->{'fileName'};
3853
            $$templateVars{"uploadtype_$totalFileNum"} = $fileInfo->{'contentType'};
3854
            $$templateVars{"uploadperm_$totalFileNum"} = param("uploadperm_$fileNum");
3849
            $$templateVars{"upload_$fileNum"} = $fileInfo->{'fileHash'};
3850
            $$templateVars{"uploadname_$fileNum"} = $fileInfo->{'fileName'};
3851
            $$templateVars{"uploadtype_$fileNum"} = $fileInfo->{'contentType'};
3852
            $$templateVars{"uploadperm_$fileNum"} = param("uploadperm_$fileNum");
3855 3853
            $uploadCount++;
3856 3854
        }
3857 3855
    }

Also available in: Unified diff