Ignore:
Timestamp:
Oct 17, 2011, 4:45:52 PM (10 years ago)
Author:
Martin Svensson
Message:

References #330 The partition registration wizard is almost finished. Known issues are: not enough validation of data, no 'move forward on enter' in the fields and perhaps more

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/partitionform.jsp

    r1403 r1406  
    6262}
    6363
     64function step3IsValid()
     65{
     66  for (var i=0; i<spWeightsAreValid.length; i++)
     67  {
     68    if (spWeightsAreValid[i] == false ||
     69        apWeightsAreValid[i] == false ||
     70        hisWeightsAreValid[i] == false ||
     71        nofPiecesAreValid[i] == false)
     72    {
     73      return false;
     74    }
     75  }
     76  return true;
     77}
     78
    6479function gotoStep2()
    6580{
     
    91106  frm.partitionComment.disabled = true;
    92107 
    93   var tubes = caseSpecimenTubes.specimen;
     108  var tubes = caseInfo.specimen;
    94109  var inputWeightHtml;
    95110  if (tubes.length > 0)
     
    100115    nofPiecesAreValid = Array(tubes.lenth);
    101116   
     117   
    102118    inputWeightHtml = '';
     119    inputWeightHtml +='<tr>';
     120    inputWeightHtml += '<td class="prompt">Specimen tube</td>';
     121    inputWeightHtml += '<td><table class="prompt" style=width:90% class="input"><tr><td style=width:25%>Sp</td><td style=width:25%>Ap</td><td style=width:25%>His</td><td style=width:25%>NofPieces</td></tr></table></td>';
     122    inputWeightHtml += '<td>&nbsp;</td><td>&nbsp;</td>';
     123    inputWeightHtml +='</tr>';
    103124    for (var i=0;i<tubes.length; i++)
    104125    {
     126      spWeightsAreValid[i] = true;
     127      apWeightsAreValid[i] = true;
     128      hisWeightsAreValid[i] = true;
     129      nofPiecesAreValid[i] = true;
     130     
    105131      spInputTitle = '';
    106132      apInputTitle = '';
    107133      hisInputTitle = '';
    108134      nofPiecesTitle = '';
    109       if (i==0)
    110       {
    111         spInputTitle = 'Sp<br>';
    112         apInputTitle = 'Ap<br>';
    113         hisInputTitle = 'His<br>';
    114         nofPiecesTitle = 'NofPieces<br>';
    115       }
     135     
     136      var doOnTab = i==(tubes.length-1) ? 'doOnTab(event, goCreate)' : '';
    116137      inputWeightHtml += '<tr>';
    117       inputWeightHtml += '<td class="prompt">Specimen tube '+caseSpecimenTubes.name+'.'+(i+1)+'</td>';
     138      inputWeightHtml += '<td class="subprompt">'+caseInfo.name+'.'+(i+1)+' ['+tubes[i].box+'&nbsp;'+tubes[i].row+tubes[i].column+']</td>';
    118139      inputWeightHtml += '<td class="input">';
    119       inputWeightHtml += '<table>';     
     140      inputWeightHtml += '<table style=width:90%>';     
    120141      inputWeightHtml += '<tr>';
    121       inputWeightHtml += '<td>' + spInputTitle + '<input size=4 type="text" onChange="spWeightOnChange('+i+')" name="spWeight'+i+'" /></td>';
    122       inputWeightHtml += '<td>' + apInputTitle + '<input size=4 type="text" onChange="apWeightOnChange('+i+')" name="apWeight'+i+'" /></td>';
    123       inputWeightHtml += '<td>' + hisInputTitle + '<input size=4 type="text" onChange="hisWeightOnChange('+i+')" name="hisWeight'+i+'" /></td>';
    124       inputWeightHtml += '<td>' + nofPiecesTitle + '<input size=4 type="text" onChange="nofPiecesOnChange('+i+')" name="nofPieces'+i+'" /></td>';
     142      inputWeightHtml += '<td>' + spInputTitle + '<input size=3 type="text" onChange="spWeightOnChange('+i+')" name="spWeight'+i+'" /></td>';
     143      inputWeightHtml += '<td>' + apInputTitle + '<input size=3 type="text" onChange="apWeightOnChange('+i+')" name="apWeight'+i+'" /></td>';
     144      inputWeightHtml += '<td>' + hisInputTitle + '<input size=3 type="text" onChange="hisWeightOnChange('+i+')" name="hisWeight'+i+'" /></td>';
     145      inputWeightHtml += '<td>' + nofPiecesTitle + '<input size=3 type="text" onkeypress="'+doOnTab+'" onChange="nofPiecesOnChange('+i+')" name="nofPieces'+i+'" /></td>';
    125146      inputWeightHtml += '</tr>';
    126147      inputWeightHtml += '</table>';
     
    130151      inputWeightHtml += '<span id="weight'+i+'.message" class="message" style="display:none;"></span>';
    131152      inputWeightHtml += 'Weights should be given in [mg]</td>';
    132       inputWeightHtml += '</tr>';
    133      
     153      inputWeightHtml += '</tr>';     
    134154    }   
    135155    setInnerHTML('weightInputs', inputWeightHtml);
     
    282302  else
    283303  {
    284     setInputStatus('partitionDate', 'Missing', 'warning');
     304    setInputStatus('partitionDate', 'Missing', 'invalid');
     305    return;
    285306  }
    286307  partitionDateIsValid = true;
     
    305326    return false;
    306327  }
    307   caseSpecimenTubes = response.caseInfo;
     328  caseInfo = response.caseInfo;
     329}
     330
     331function goCreate()
     332{
     333  if (!step3IsValid()) return;
     334 
     335  Main.hide('gocancel');
     336  Main.hide('gocreate');
     337  var frm = document.forms['reggie'];
     338 
     339  var specimens = caseInfo.specimen;
     340  var nofTubes = specimens.length;
     341  var partitionDateValue = frm.elements['partitionDate'].value;
     342  var partitionCommentValue = frm.elements['partitionComment'].value;
     343  caseInfo.partitionDate = partitionDateValue;
     344  if (partitionCommentValue != null) caseInfo.partitionComment = partitionCommentValue;
     345 
     346  for (var i=0; i<nofTubes; i++)
     347  {
     348    frm.elements['spWeight'+i].disabled = true;
     349    frm.elements['apWeight'+i].disabled = true;
     350    frm.elements['hisWeight'+i].disabled = true;
     351    frm.elements['nofPieces'+i].disabled = true;
     352   
     353    var specimenTube = specimens[i];
     354   
     355    var spWeightValue = frm.elements['spWeight'+i].value;
     356    if (spWeightValue != '') specimenTube.spWeight = spWeightValue;
     357    var apWeightValue = frm.elements['apWeight'+i].value;
     358    if (apWeightValue != '') specimenTube.apWeight = apWeightValue;
     359    var hisWeightValue = frm.elements['hisWeight'+i].value;
     360    if (hisWeightValue != '') specimenTube.hisWeight = hisWeightValue;
     361    var nofPiecesValue = frm.elements['nofPieces'+i].value;
     362    if (nofPiecesValue != '') specimenTube.nofPieces = nofPiecesValue;
     363   
     364    caseInfo.specimen[i] = specimenTube;   
     365  }
     366  var submitInfo = new Object();
     367  submitInfo.caseInfo = caseInfo;
     368 
     369  if (debug) Main.debug(JSON.stringify(caseInfo));
     370 
     371  var request = Ajax.getXmlHttpRequest();
     372  var url = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=CreatePartitions';
     373  request.open("POST", url, false);
     374  request.setRequestHeader("Content-Type", "application/json");
     375  request.send(JSON.stringify(submitInfo));
     376
     377  if (debug) Main.debug(request.responseText);
     378
     379  var response = JSON.parse(request.responseText);
     380  if (response.status != 'ok')
     381  {
     382    setFatalError(response.message);
     383    return false;
     384  }
     385
     386  var msg = '<ul>';
     387  for (var i = 0; i < response.messages.length; i++)
     388  {
     389    msg += '<li>' + response.messages[i];
     390  }
     391  msg += '</ul>';
     392  setInnerHTML('done', msg);
     393 
     394 
     395  Main.show('done');
     396  Main.show('gorestart');
    308397}
    309398</script>
     
    366455          <td class="prompt">Partition date</td>
    367456          <td class="input"><input type="text" name="partitionDate"
    368             size="12" maxlength="10" onBlur="partitionDateOnBlur()"></td>
     457             onkeypress="focusOnEnter(event, 'partitionComment')" size="12" maxlength="10" onBlur="partitionDateOnBlur()"></td>
    369458          <td class="status" id="partitionDate.status"></td>
    370459          <td class="help"><span id="partitionDate.message" class="message" style="display: none;"></span>The date when the partition was done.</td>
Note: See TracChangeset for help on using the changeset viewer.