Changeset 1961


Ignore:
Timestamp:
May 6, 2013, 3:21:02 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #473: Register library processing results

The library registration now uses 'local storage' to temporarily save the form. In case the registration fails for any reason (common: data files are not correctly formatted), the saved data is used to re-populate all input fields so that the user doesn't have to enter all values again.

File:
1 edited

Legend:

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

    r1934 r1961  
    127127  Main.show('goregister');
    128128 
     129  var libInfo = getStoredInfo(frm.bioplate.value);
     130  if (libInfo)
     131  {
     132    if (debug) Main.debug(JSON.stringify(libInfo));
     133    var failed = document.getElementById('outcomeFailed').checked
     134   
     135    if (libInfo.libDate)
     136    {
     137      frm.libDate.value = libInfo.libDate;
     138      libDateOnChange();
     139    }
     140    if (!failed)
     141    {
     142      if (libInfo.wellTable.id && libInfo.wellTable.path)
     143      {
     144        lastPrefix = 'welltable';
     145        setFileCallback(libInfo.wellTable.id, libInfo.wellTable.path);
     146      }
     147      if (libInfo.caliperGxd.id && libInfo.caliperGxd.path)
     148      {
     149        lastPrefix = 'calipergxd';
     150        setFileCallback(libInfo.caliperGxd.id, libInfo.caliperGxd.path);
     151      }
     152      if (libInfo.caliperPdf.id && libInfo.caliperPdf.path)
     153      {
     154        lastPrefix = 'caliperpdf';
     155        setFileCallback(libInfo.caliperPdf.id, libInfo.caliperPdf.path);
     156      }
     157      if (libInfo.qubitCsv.id && libInfo.qubitCsv.path)
     158      {
     159        lastPrefix = 'qubitcsv';
     160        setFileCallback(libInfo.qubitCsv.id, libInfo.qubitCsv.path);
     161      }
     162    }
     163    if (libInfo.libOperator) frm.libOperator.value = libInfo.libOperator;
     164    if (libInfo.libComments)
     165    {
     166      frm.libComments.value = libInfo.libComments;
     167      libDateOnChange();
     168    }
     169  }
     170 
    129171  Main.show('step.2.section');
    130172  frm.libDate.focus();
     
    183225    Main.addClass(frm.libComments, 'required');
    184226    Main.hide('filesSection');
     227  }
     228  else
     229  {
     230    Main.removeClass(frm.libComments, 'required');
     231    Main.show('filesSection');
    185232  }
    186233}
     
    350397{
    351398  if (!step2IsValid()) return;
    352   var frm = document.forms['reggie'];
    353 
    354399 
    355400  Main.hide('goregister');
    356401  Main.hide('gocancel');
    357402
     403  var frm = document.forms['reggie'];
     404  var libPlateId = parseInt(frm.bioplate.value, 10);
    358405  var submitInfo = {};
    359   submitInfo.bioplate = parseInt(frm.bioplate.value, 10);
     406  submitInfo.bioplate = libPlateId;
    360407
    361408  Main.addClass(document.getElementById('step.2.section'), 'disabled');
     
    366413  if (!failed)
    367414  {
     415    saveToLocalStorage(libPlateId);
    368416    submitInfo.wellTableCsv = parseInt(frm['welltable.id'].value, 10);
    369417    submitInfo.caliperGxd = parseInt(frm['calipergxd.id'].value, 10);
     
    420468    return false;
    421469  }
     470  else
     471  {
     472    removeFromLocalStorage(libPlateId);
     473  }
    422474
    423475  Main.show('gorestart');
     476}
     477
     478
     479/**
     480  Save as much information as possible about the library registration.
     481  The information is stored in the localStorage()
     482  under the key 'reggie.libplate.<id>.info' where
     483  <id> is the ID of the library plate.
     484*/
     485function saveToLocalStorage(libPlateId)
     486{
     487  if (window.localStorage)
     488  {
     489    var frm = document.forms['reggie'];
     490    var libInfo = new Object();
     491    libInfo.id = libPlateId;
     492    libInfo.libDate = frm.libDate.value;
     493    libInfo.wellTable = { id: frm['welltable.id'].value, path: frm['welltable.path'].value };
     494    libInfo.caliperGxd = { id: frm['calipergxd.id'].value, path: frm['calipergxd.path'].value };
     495    libInfo.caliperPdf = { id: frm['caliperpdf.id'].value, path: frm['caliperpdf.path'].value };
     496    libInfo.qubitCsv = { id: frm['qubitcsv.id'].value, path: frm['qubitcsv.path'].value };
     497    libInfo.libProtocol = frm.libProtocol.value;
     498    libInfo.libOperator = frm.libOperator.value;
     499    libInfo.libComments = frm.libComments.value;
     500   
     501    window.localStorage.setItem('reggie.libplate.' + libPlateId + '.info', JSON.stringify(libInfo));
     502    if (debug)
     503    {
     504      Main.debug(libPlateId + ': ' + window.localStorage.getItem('reggie.libplate.' + libPlateId + '.info'));
     505    }
     506  }
     507}
     508
     509function removeFromLocalStorage(libPlateId)
     510{
     511  if (!window.localStorage) return;
     512  if (debug) Main.debug('removeFromLocalStorage:' + libPlateId);
     513  window.localStorage.removeItem('reggie.libplate.' + libPlateId + '.info');
     514}
     515
     516function getStoredInfo(libPlateId)
     517{
     518  if (!window.localStorage) return null;
     519  try
     520  {
     521    var stored = window.localStorage.getItem('reggie.libplate.' + libPlateId + '.info');
     522    if (debug) Main.debug(stored);
     523    return stored ? JSON.parse(stored) : null;
     524  }
     525  catch (e)
     526  {
     527    Main.debug('Could not load stored information for tube ' + tubeId + ': ' + e);
     528  }
    424529}
    425530
     
    554659            name="calipergxd.path" value=""
    555660            size="50" onkeypress="doOnEnter(event, function(){document.getElementById('btnCaliperGxd').click()})"
    556             onblur="caliperGxdFileOnChange()"
    557661            ></td>
    558662          <td style="padding-left: 4px;"><base:button
     
    579683            name="caliperpdf.path" value=""
    580684            size="50" onkeypress="doOnEnter(event, function(){document.getElementById('btnCaliperPdf').click()})"
    581             onblur="caliperPdfFileOnChange()"
    582685            ></td>
    583686          <td style="padding-left: 4px;"><base:button
Note: See TracChangeset for help on using the changeset viewer.