Changeset 1638


Ignore:
Timestamp:
May 7, 2012, 1:41:31 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #389: The partition wizard should not allow missing weights in some cases

File:
1 edited

Legend:

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

    r1628 r1638  
    4040var apWeightsAreValid;
    4141var hisWeightsAreValid;
    42 var oneOrMoreWeightsAreSet;
     42var allWeightsAreValid;
    4343var nofPiecesAreValid;
    4444var isRestoringFromLocalStorage = false; // A flag to keep track of what is happening
     
    104104      return false;
    105105    }
    106     if (oneOrMoreWeightsAreSet[i] == false)
     106    if (allWeightsAreValid[i] == false)
    107107    {
    108108      return false;
     
    183183    hisWeightsAreValid = Array();
    184184    nofPiecesAreValid = Array();
    185     oneOrMoreWeightsAreSet = Array();
     185    allWeightsAreValid = Array();
    186186   
    187187    for (var i=0;i<selectedTubes.length;i++)
     
    191191      hisWeightsAreValid[i] = true;
    192192      nofPiecesAreValid[i] = false;
    193       oneOrMoreWeightsAreSet[i] = false;     
     193      allWeightsAreValid[i] = false;     
    194194    }
    195195   
     
    315315function isNumberKey(evt)
    316316{
     317  return true;
    317318  evt = (evt) ? evt : ((window.event) ? event : null);
    318319    if (evt) {
     
    458459  var apWeightValue = frm.elements['apWeight'+tubeIndex].value;
    459460  var hisWeightValue = frm.elements['hisWeight'+tubeIndex].value;
    460   if (spWeightValue == '' && apWeightValue == '' && hisWeightValue == '')
    461   {
    462     oneOrMoreWeightsAreSet[tubeIndex] = false;
    463     setInputStatus(tubeIndex, 'No weight is defined.', 'invalid');
    464     return;
    465   }
    466   oneOrMoreWeightsAreSet[tubeIndex] = true;
    467   setInputStatus(tubeIndex, '', 'valid');
    468 }
    469 
     461 
     462  if (apWeightValue == '')
     463  {
     464    allWeightsAreValid[tubeIndex] = false;
     465    setInputStatus(tubeIndex, 'No ApWeight is defined.', 'invalid');
     466  }
     467  else if (hisWeightValue == '' && spWeightValue != '')
     468  {
     469    allWeightsAreValid[tubeIndex] = false;
     470    setInputStatus(tubeIndex, 'SpWeight is set but not HisWeight', 'invalid');
     471   
     472  }
     473  else
     474  {
     475    allWeightsAreValid[tubeIndex] = true;
     476    if (apWeightValue == '0')
     477    {
     478      setInputStatus(tubeIndex, 'No Lysate item will be created!', 'warning');
     479    }
     480    else if (hisWeightValue == '0')
     481    {
     482      setInputStatus(tubeIndex, 'No Histology item will be created!', 'warning');
     483    }
     484    else
     485    {
     486      setInputStatus(tubeIndex, '', 'valid');
     487    }
     488  }
     489 
     490}
     491
     492//Check the SpWeight value -- empty or >= 0 are ok.
    470493function spWeightOnChange(tubeIndex)
    471494{
     
    473496  var frm = document.forms['reggie'];
    474497  var weightInput = frm.elements[inputName].value;
    475   if (weightInput != '')
    476   {
    477     if (weightInput < 0)
    478     {
    479       spWeightsAreValid[tubeIndex] = false;
    480       updateInputStatus(tubeIndex);
    481       return;
    482     }
    483     if (weightInput == '0')
    484     {
    485       frm.elements[inputName].value = '';
    486     }
    487   }
    488   spWeightsAreValid[tubeIndex] = true;
     498  if (weightInput == '' || parseFloat(weightInput) >= 0)
     499  {
     500    spWeightsAreValid[tubeIndex] = true;
     501  }
     502  else
     503  {
     504    spWeightsAreValid[tubeIndex] = false;
     505  }
    489506  updateInputStatus(tubeIndex);
    490507}
    491508
     509// Check the ApWeight value -- empty or >= 0 are ok.
    492510function apWeightOnChange(tubeIndex)
    493511{
     
    495513  var frm = document.forms['reggie'];
    496514  var weightInput = frm.elements[inputName].value;
    497   if (weightInput != '')
    498   {
    499     if (weightInput < 0)
    500     {
    501       apWeightsAreValid[tubeIndex] = false;
    502       updateInputStatus(tubeIndex);
    503       return;
    504     }
    505     if (weightInput == '0')
    506     {
    507       frm.elements[inputName].value = '';
    508     }
    509   }
    510   apWeightsAreValid[tubeIndex] = true;
     515  if (weightInput == '' || parseFloat(weightInput) >= 0)
     516  {
     517    apWeightsAreValid[tubeIndex] = true;
     518  }
     519  else
     520  {
     521    apWeightsAreValid[tubeIndex] = false;
     522  }
    511523  updateInputStatus(tubeIndex);
    512524}
    513525
     526//Check the HisWeight value -- empty or >= 0 are ok.
    514527function hisWeightOnChange(tubeIndex)
    515528{
     
    517530  var frm = document.forms['reggie'];
    518531  var weightInput = frm.elements[inputName].value;
    519   if (weightInput != '')
    520   {
    521     if (weightInput < 0)
    522     {
    523       hisWeightsAreValid[tubeIndex] = false;
    524       updateInputStatus(tubeIndex);
    525       return;
    526     }
    527     if (weightInput == '0')
    528     {
    529       frm.elements[inputName].value = '';
    530     }   
    531   }
    532   hisWeightsAreValid[tubeIndex] = true;
     532  if (weightInput == '' || parseFloat(weightInput) >= 0)
     533  {
     534    hisWeightsAreValid[tubeIndex] = true;
     535  }
     536  else
     537  {
     538    hisWeightsAreValid[tubeIndex] = false;
     539  }
    533540  updateInputStatus(tubeIndex);
    534541}
Note: See TracChangeset for help on using the changeset viewer.