Ignore:
Timestamp:
Oct 28, 2011, 9:49:16 AM (10 years ago)
Author:
Martin Svensson
Message:

References #330 The partition wizard has partly got a new look. Most of the changes are done in the weight section. Background functions are not implemented yet.

File:
1 edited

Legend:

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

    r1409 r1419  
    2929var currentStep = 1;
    3030
    31 var caseSpecimenTubes = null;
     31var specimenTubes = null;
     32var selectedTubes = null;
    3233
    3334var partitionDateIsValid = false;
     
    4142{
    4243  var frm = document.forms['reggie'];
    43   frm.caseName.focus();
     44  var selectList = frm.tubesSelect;
     45  getSpecimenTubes();
     46 
     47  var specimenTubeOptions = '';
     48  if (specimenTubes != null && specimenTubes.length > 0)
     49  {
     50    for (var i=0;i<specimenTubes.length;i++)
     51    {
     52      var tube = specimenTubes[i];
     53      selectList.options[selectList.length] = new Option(tube.name, tube.name);
     54    }
     55  }
     56  else
     57  {
     58    selectList.disabled = true;
     59    Main.hide('gonext');   
     60    setInputStatus('tubes','No tubes available for partition', 'invalid')
     61  }
    4462}
    4563
     
    5371  else if (currentStep == 2)
    5472  {
     73    partitionDateOnBlur();
    5574    if (step2IsValid()) gotoStep3();
    5675  }
     
    8099{
    81100  var frm = document.forms['reggie'];
    82   var caseName = frm.caseName.value;
    83   if (caseName == '')
    84   {
    85     setInputStatus('case', 'Missing', 'invalid');
     101  var selectList = frm.tubesSelect;
     102  selectedTubes = new Array();
     103  for (var i=0;i<selectList.length; i++)
     104  {
     105    if (selectList.options[i].selected)
     106      selectedTubes.push(specimenTubes[i]);
     107  }   
     108 
     109  if (selectedTubes.length == 0)
     110  {
     111    setInputStatus('tubes', 'Missing', 'invalid');
    86112    return;
    87113  }
    88   setInputStatus('case', '', 'valid');
    89  
    90   getSpecimenTubes();
    91  
    92  
     114 
     115  setInputStatus('tubes', '', 'valid');
    93116  // Change section
    94   frm.caseName.disabled = true;
     117  frm.tubesSelect.disabled = true;
    95118 
    96119  Main.show('partitionSection');
    97120  Main.show('gocancel');
     121  var currentTime = new Date();
     122  frm.partitionDate.value = currentTime.getFullYear().toString()+(currentTime.getMonth()+1).toString()+currentTime.getDate().toString();
     123  frm.partitionDate.setSelectionRange(0,frm.partitionDate.value.length);
    98124  frm.partitionDate.focus();
    99125  currentStep = 2;
     
    103129{
    104130  var frm = document.forms['reggie'];
    105   frm.partitionDate.disabled = true;
    106   frm.partitionComment.disabled = true;
    107  
    108   var tubes = caseInfo.specimen;
    109   var inputWeightHtml;
    110   if (tubes.length > 0)
    111   {
    112     spWeightsAreValid = Array(tubes.length);
    113     apWeightsAreValid = Array(tubes.length);
    114     hisWeightsAreValid = Array(tubes.length);
    115     nofPiecesAreValid = Array(tubes.lenth);
    116    
    117    
     131  frm.partitionDate.disabled = true; 
     132   
     133  var inputWeightHtml; 
     134  if (selectedTubes.length > 0)
     135  {
     136    spWeightsAreValid = Array();
     137    apWeightsAreValid = Array();
     138    hisWeightsAreValid = Array();
     139    nofPiecesAreValid = Array();
     140       
    118141    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>';
    124     for (var i=0;i<tubes.length; i++)
    125     {
    126       spWeightsAreValid[i] = true;
    127       apWeightsAreValid[i] = true;
    128       hisWeightsAreValid[i] = true;
    129       nofPiecesAreValid[i] = true;
     142
     143    var spTitle = 'SpWeight<br>';
     144    var apTitle = 'ApWeight<br>';
     145    var hisTitle = 'HisWeight<br>';
     146    var nofTitle = 'NofPieces<br>';
     147    var appearanceTitle = 'Appearance<br>';
     148    var necrosisTitle = 'Necrosis%<br>';
     149    var fatTitle = 'Fat%<br>';
     150    var colouredTitle = 'Coloured<br>';
     151    var bloodyTitle = 'Bloody<br>';
     152   
     153    var appearanceOptions = '<option selected></option>'; 
     154    appearanceOptions += '<option value=homogenus>Homogenus</option>';
     155    appearanceOptions += '<option value=heterogenus>Heterogenus</option>';
     156   
     157    var necrosisOptions = '<option selected value=0>0</option>';
     158    necrosisOptions += '<option value=20>20</option>';
     159    necrosisOptions += '<option value=40>40</option>';
     160    necrosisOptions += '<option value=60>60</option>';
     161    necrosisOptions += '<option value=80>80</option>';
     162    necrosisOptions += '<option value=100>100</option>';
     163   
     164    var fatOptions = '<option selected value=0>0</option>';
     165    fatOptions += '<option value=20>20</option>';
     166    fatOptions += '<option value=40>40</option>';
     167    fatOptions += '<option value=60>60</option>';
     168    fatOptions += '<option value=80>80</option>';
     169    fatOptions += '<option value=100>100</option>';
     170   
     171    for (var i=0;i<selectedTubes.length; i++)
     172    {
     173      var tube = selectedTubes[i];
     174      var nextStep = i<(selectedTubes.length-1) ? 'focusOnEnter(event, \'bloody'+(i+1)+'\')' : 'doOnTabOrEnter(event, goCreate)';
    130175     
    131       spInputTitle = '';
    132       apInputTitle = '';
    133       hisInputTitle = '';
    134       nofPiecesTitle = '';
     176      inputWeightHtml += '<tr>';
     177      inputWeightHtml += '<td rowspan=2 class=prompt>'+tube.name+' ['+tube.box+'&nbsp;'+tube.row+tube.column+']</td>';
    135178     
    136       var doOnTab = i==(tubes.length-1) ? 'doOnTab(event, goCreate)' : 'focusOnEnter(event, \'spWeight'+(i+1)+'\')';
    137       inputWeightHtml += '<tr>';
    138       inputWeightHtml += '<td class="subprompt">'+caseInfo.name+'.'+(i+1)+' ['+tubes[i].box+'&nbsp;'+tubes[i].row+tubes[i].column+']</td>';
    139       inputWeightHtml += '<td class="input">';
    140       inputWeightHtml += '<table style=width:90%>';     
    141       inputWeightHtml += '<tr>';
    142       inputWeightHtml += '<td>' + spInputTitle + '<input size=3 type="text" onkeypress="focusOnEnter(event, \'apWeight'+i+'\')" onChange="spWeightOnChange('+i+')" name="spWeight'+i+'" /></td>';
    143       inputWeightHtml += '<td>' + apInputTitle + '<input size=3 type="text" onkeypress="focusOnEnter(event, \'hisWeight'+i+'\')" onChange="apWeightOnChange('+i+')" name="apWeight'+i+'" /></td>';
    144       inputWeightHtml += '<td>' + hisInputTitle + '<input size=3 type="text" onkeypress="focusOnEnter(event, \'nofPieces'+i+'\')" 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>';
     179      inputWeightHtml += '<td style="width:400px;">';
     180      inputWeightHtml += '<table style="width:100%"><tr>';     
     181      inputWeightHtml += '<td>'+bloodyTitle+'<input type=checkbox onkeypress="checkOnNumber(event, this);focusOnEnter(event, \'appearance'+i+'\')" onfocus="messageOnFocus(0,'+i+')" name=bloody'+i+' /></td>';
     182      inputWeightHtml += '<td>'+appearanceTitle+'<select name=appearance'+i+' onfocus="messageOnFocus(1,'+i+')" onkeypress="focusOnEnter(event, \'necrosis'+i+'\')">'+appearanceOptions+'</select></td>';
     183      inputWeightHtml += '<td>'+necrosisTitle+'<select name=necrosis'+i+' onfocus="messageOnFocus(2,'+i+')" onkeypress="focusOnEnter(event, \'fat'+i+'\')">'+necrosisOptions+'</select></td>'; 
     184      inputWeightHtml += '<td>'+fatTitle+'<select name=fat'+i+' onfocus="messageOnFocus(3,'+i+')" onkeypress="focusOnEnter(event, \'coloured'+i+'\')">'+fatOptions+'</select></td>';
     185      inputWeightHtml += '<td>'+colouredTitle+'<input type=checkbox name=coloured'+i+' onfocus="messageOnFocus(4,'+i+')" onkeypress="checkOnNumber(event, this);focusOnEnter(event, \'nofPieces'+i+'\')" /></td>'
     186      inputWeightHtml += '<td>'+nofTitle+'<input name="nofPieces'+i+'" onfocus="messageOnFocus(5,'+i+')" onchange="nofPiecesOnChange('+i+')" onkeypress="focusOnEnter(event, \'spWeight'+i+'\')" size=2 /></td>';
     187      inputWeightHtml += '<td>'+spTitle+'<input name="spWeight'+i+'" onfocus="messageOnFocus(6,'+i+')" onchange="spWeightOnChange('+i+')" onkeypress="focusOnEnter(event, \'hisWeight'+i+'\')" size=2 /></td>';
     188      inputWeightHtml += '<td>'+hisTitle+'<input name="hisWeight'+i+'" onfocus="messageOnFocus(7,'+i+')" onchange="hisWeightOnChange('+i+')" onkeypress="focusOnEnter(event, \'apWeight'+i+'\')" size=2 /></td>';
     189      inputWeightHtml += '<td>'+apTitle+'<input name="apWeight'+i+'" onfocus="messageOnFocus(8,'+i+')" onchange="apWeightOnChange('+i+')" onkeypress="'+nextStep+'" size=2 /></td>';     
    146190      inputWeightHtml += '</tr>';
    147191      inputWeightHtml += '</table>';
    148192      inputWeightHtml += '</td>';
    149       inputWeightHtml += '<td id="weight'+i+'.status" class="status"></td>';
    150       inputWeightHtml += '<td class="help">';
    151       inputWeightHtml += '<span id="weight'+i+'.message" class="message" style="display:none;"></span>';
    152       inputWeightHtml += 'Weights should be given in [mg]</td>';
    153       inputWeightHtml += '</tr>';     
    154     }   
     193      inputWeightHtml += '<td rowspan=2 class="status" id="'+i+'.status"></td>';     
     194      inputWeightHtml += '</tr>';
     195     
     196      inputWeightHtml += '<tr>';
     197      inputWeightHtml += '<td style="width:400px;" class="help"><span class="message" id="'+i+'.message"></span><span id="'+i+'.help"></span></td>';     
     198      inputWeightHtml += '</tr>';
     199     
     200      inputWeightHtml += '<tr><td>&nbsp;</td></tr>';
     201    }
    155202    setInnerHTML('weightInputs', inputWeightHtml);
    156203  }
     
    158205  Main.hide('gonext');
    159206  Main.show('gocreate');
    160   frm.spWeight0.focus();
     207  frm.bloody0.focus(); 
     208}
     209
     210function checkOnNumber(event, element)
     211{
     212  if (event.charCode == 48)
     213  {
     214    element.checked = false;
     215  }
     216  else if (event.charCode == 49)
     217  {
     218    element.checked = true;
     219  }
     220  return true;
     221}
     222
     223function messageOnFocus(order, tubeIndex)
     224{
     225  var helpMessage;
     226  switch(order)
     227  {
     228    case 0:
     229      helpMessage = 'Check this if the partition is bloody. Unchecked is default.';
     230      break;
     231    case 1:
     232      helpMessage = 'Select appearance. Empty is default';
     233      break;
     234    case 2:
     235      helpMessage = 'Select percentage of necrosis. \'0\' is default.';
     236      break;
     237    case 3:
     238      helpMessage = 'Select percentage of fat. \'0\' is default.';
     239      break;
     240    case 4:
     241      helpMessage = 'Check this if the partition is coloured. Unchecked is default.';
     242      break;
     243    case 5:
     244      helpMessage = 'Number of pieces in this partition.';
     245      break;
     246    case 6:
     247      helpMessage = 'Sp weight in [mg].';
     248      break;
     249    case 7:
     250      helpMessage = 'His weight in [mg].';
     251      break;
     252    case 8:
     253      helpMessage = 'Ap weight in [mg].';
     254      break;
     255    default:
     256      helpMessage='&nbsp;';
     257  }
     258  for (var i=0;i<selectedTubes.length;i++)
     259  {
     260    if (i!=tubeIndex) setInnerHTML(i+'.help', '&nbsp;')
     261  }
     262  setInnerHTML(tubeIndex+'.help', helpMessage);
    161263}
    162264
    163265function updateInputStatus(tubeIndex)
    164266{
     267  var frm = document.forms['reggie'];
     268  if(nofPiecesAreValid[tubeIndex] == false)
     269  {
     270    setInputStatus(tubeIndex, 'NofPieces is invalid.', 'invalid');
     271    frm.elements['nofPieces'+tubeIndex].focus();
     272    return ;
     273  }
    165274  if (spWeightsAreValid[tubeIndex] == false)
    166275  {
    167     setInputStatus('weight'+tubeIndex, 'SpWeight is invalid','invalid');
     276    setInputStatus(tubeIndex, 'SpWeight is invalid.','invalid');
    168277    return;
    169278  }
     279  if(hisWeightsAreValid[tubeIndex] == false)
     280  {
     281    setInputStatus(tubeIndex, 'HisWeight is invalid.', 'invalid');
     282    return;
     283  }
    170284  if(apWeightsAreValid[tubeIndex] == false)
    171285  {
    172     setInputStatus('weight'+tubeIndex, 'APWeight is invalid', 'invalid');
     286    setInputStatus(tubeIndex, 'APWeight is invalid.', 'invalid');
    173287    return;
    174   }
    175   if(hisWeightsAreValid[tubeIndex] == false)
    176   {
    177     setInputStatus('weight'+tubeIndex, 'HisWeight is invalid', 'invalid');
    178     return;
    179   }
    180   if(nofPiecesAreValid[tubeIndex] == false)
    181   {
    182     setInputStatus('weight'+tubeIndex, 'NofPieces is invalid', 'invalid');
    183     return;
    184   }
    185   setInputStatus('weight'+tubeIndex, '', 'valid');
     288  }   
     289  setInputStatus(tubeIndex, '', 'valid');
    186290}
    187291
     
    311415{
    312416  var frm = document.forms['reggie'];
    313   var caseName = frm.caseName.value;
     417 
    314418  var request = Ajax.getXmlHttpRequest();
    315   var url = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=GetSpecimenTubes';
    316   url += '&caseName=' + caseName;
    317   request.open("GET", url, false);
     419  var url = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=GetSpecimenTubes';   
     420  request.open("GET", url, false); 
    318421  request.send(null);
    319422
    320   if (debug) Main.debug(request.responseText);
    321 
    322   var response = JSON.parse(request.responseText);
     423  if (debug) Main.debug(request.responseText); 
     424  var response = JSON.parse(request.responseText); 
    323425  if (response.status != 'ok')
    324426  {
    325427    setFatalError(response.message);
    326428    return false;
    327   }
    328   caseInfo = response.caseInfo;
     429  } 
     430  specimenTubes = response.tubeInfo.specimenTubes;
    329431}
    330432
    331433function goCreate()
    332434{
     435  alert('goCreate');
    333436  if (!step3IsValid()) return;
    334437 
     
    340443  var nofTubes = specimens.length;
    341444  var partitionDateValue = frm.elements['partitionDate'].value;
    342   var partitionCommentValue = frm.elements['partitionComment'].value;
     445  //var partitionCommentValue = frm.elements['partitionComment'].value;
    343446  caseInfo.partitionDate = partitionDateValue;
    344   if (partitionCommentValue != null) caseInfo.otherPartitionComment = partitionCommentValue;
     447// if (partitionCommentValue != null) caseInfo.otherPartitionComment = partitionCommentValue;
    345448 
    346449  for (var i=0; i<nofTubes; i++)
     
    424527  <tr>
    425528    <td rowspan="3" class="stepno">1</td>
    426     <td class="steptitle">Enter Case Name</td>
     529    <td class="steptitle">Select specimen tubes</td>
    427530  </tr>
    428531  <tr>
     
    430533      <table border="0" cellspacing="0" cellpadding="0" width="100%">
    431534      <tr valign="top">
    432         <td class="prompt">Case name</td>
    433         <td class="input"><input type="text" name="caseName"
    434           size="18" maxlength="12" onkeypress="doOnTabOrEnter(event, goNext)"></td>
    435         <td class="status" id="case.status"></td>
    436         <td class="help"><span id="case.message" class="message" style="display: none;"></span>The case (barcode) associated with the partitions.</td>
     535        <td class="prompt">Specimen tubes</td>
     536        <td class="input"><select style="width:50%" name="tubeSelect" id="tubesSelect" multiple="multiple" size="5" onkeypress='doOnTab(event, goNext)'></select></td>
     537        <td class="status" id="tubes.status"></td>
     538        <td class="help"><span id="tubes.message" class="message" style="display: none;"></span>Select specimen tubes to include in the partition.</td>
    437539      </tr>
    438540      </table>
     
    455557          <td class="prompt">Partition date</td>
    456558          <td class="input"><input type="text" name="partitionDate"
    457              onkeypress="focusOnEnter(event, 'partitionComment')" size="12" maxlength="10" onBlur="partitionDateOnBlur()"></td>
     559             onkeypress="doOnTabOrEnter(event, goNext)" size="12" maxlength="10" onBlur="partitionDateOnBlur()"></td>
    458560          <td class="status" id="partitionDate.status"></td>
    459561          <td class="help"><span id="partitionDate.message" class="message" style="display: none;"></span>The date when the partition was done.</td>
    460         </tr>
    461         <tr valign="top">
    462           <td class="prompt" id="partitionComment.prompt">Other partition comment</td>
    463           <td class="input" id="partitionComment.input"><textarea rows="3" cols="30"
    464             name="partitionComment" value="" onkeypress="doOnTab(event, goNext)"></textarea></td>
    465           <td class="status" id="partitionComment.status"></td>
    466           <td class="help"><span id="partitionComment.message" class="message" style="display: none;"></span></td>
    467         </tr>
     562        </tr>       
    468563        </table>
    469564      </td>
Note: See TracChangeset for help on using the changeset viewer.