Ignore:
Timestamp:
Nov 8, 2013, 8:15:38 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #489: Histology scoring wizard

Implemented 'Find HE glass', 'Select HE glass' and menu with uncompleted HE glass functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/branches/ticket-489/resources/sampleproc/histology_score.jsp

    r2123 r2124  
    77  import="net.sf.basedb.core.Application"
    88  import="net.sf.basedb.clients.web.Base"
     9  import="net.sf.basedb.clients.web.util.HTML"
    910  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
    1011  import="java.text.SimpleDateFormat"
     
    2627  final User user = User.getById(dc, sc.getLoggedInUserId());
    2728  final String today = new SimpleDateFormat("yyyyMMdd").format(new Date());
     29  final String name = request.getParameter("name");
    2830%>
    2931<base:page type="default" >
     
    4143{
    4244  var frm = document.forms['reggie'];
    43   heGlass = getHeGlassForScoring();
     45 
     46  var glassName = '<%=HTML.javaScriptEncode(name)%>'
     47  heGlass = getHeGlassForScoring(glassName);
    4448 
    4549  if (heGlass != null && heGlass.length > 0)
     
    98102  else
    99103  {
    100     var msg = 'No HE glass available for scoring.';
    101     msg += ' Specify HE glass name above to re-score.';
     104    var msg;
     105    if (glassName)
     106    {
     107      msg = 'Could not find HE glass with name: ' + Main.encodeTags(glassName);
     108    }
     109    else
     110    {
     111      msg = 'No HE glass available for scoring.';
     112      msg += ' Specify HE glass name above to re-score.';
     113    }
    102114    setInnerHTML('he-glass-container', '<div class="messagecontainer note">'+msg+'</div>');
    103115    Main.show('he-glass-container');
    104116  }
    105 }
    106 
    107 function getHeGlassForScoring()
     117 
     118  // Wait a second until loading uncompleted HE glass
     119  setTimeout(loadUncompletedHeGlass, 1000);
     120}
     121
     122function findHeGlass(glassName)
     123{
     124  var frm = document.forms['reggie'];
     125  if (!glassName)
     126  {
     127    glassName = frm.findGlassName.value;
     128    if (glassName.match(/^\d+$/))
     129    {
     130      while (glassName.length < 5)
     131      {
     132        glassName = '0'+glassName;
     133      }
     134      glassName = 'HE'+glassName;
     135    }
     136  }
     137  location.href = '<%=home%>/sampleproc/histology_score.jsp?ID=<%=ID%>&name='+encodeURIComponent(glassName);
     138}
     139
     140function selectHeGlass()
     141{
     142  var url = getRoot() + 'biomaterials/bioplates/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
     143  url += '&resetTemporary=1';
     144  url += '&tmpfilter:STRING:name='+encodeURIComponent('HE%');
     145  url += '&callback=setSelectedHeGlass'
     146  Main.openPopup(url, 'SelectHeGlass', 1050, 700);
     147}
     148
     149function setSelectedHeGlass(id, name)
     150{
     151  findHeGlass(name);
     152}
     153
     154function getHeGlassForScoring(glassName)
    108155{
    109156  var frm = document.forms['reggie'];
    110  
    111157  var request = Ajax.getXmlHttpRequest();
    112158  try
    113159  {
    114     showLoadingAnimation('Loading next HE glass for scoring...');
    115     var url = '../Histology.servlet?ID=<%=ID%>&cmd=GetHeGlassToScore';   
     160    var msg = glassName ? 'Finding HE glass: '+Main.encodeTags(glassName) : 'Loading next HE glass for scoring...';
     161    showLoadingAnimation(msg);
     162    var url = '../Histology.servlet?ID=<%=ID%>&cmd=GetHeGlassToScore';
     163    if (glassName)
     164    {
     165      url += '&name='+encodeURIComponent(glassName);
     166    }
    116167    request.open("GET", url, false); 
    117168    request.send(null);
     
    131182  return response.heGlasses;
    132183}
     184
    133185
    134186function createHeGlassSection(glass)
     
    360412}
    361413
    362 function selectHeGlass()
    363 {
    364   var url = getRoot() + 'biomaterials/bioplates/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone';
    365   url += '&resetTemporary=1';
    366   url += '&filter:STRING:name=HE%';
    367   Main.openPopup(url, 'SelectHeGlass', 1050, 700);
     414function loadUncompletedHeGlass()
     415{
     416  var request = Ajax.getXmlHttpRequest();
     417  try
     418  {
     419    //showLoadingAnimation('Loading next HE glass for scoring...');
     420    var url = '../Histology.servlet?ID=<%=ID%>&cmd=GetUncompletedHeGlass';
     421    request.open("GET", url, false); 
     422    request.send(null);
     423  }
     424  finally
     425  {
     426    //hideLoadingAnimation();
     427  }
     428 
     429  if (debug) Main.debug(request.responseText);
     430  var response = JSON.parse(request.responseText); 
     431  if (response.status == 'ok')
     432  {
     433    var uncompleted = response.heGlasses;
     434   
     435    if (uncompleted.length > 0)
     436    {
     437      // Populate menu item
     438      setInnerHTML('uncompletedHeGlass.text', uncompleted.length + ' uncompleted');
     439      var html = ''; 
     440      for (var glassNo = 0; glassNo < uncompleted.length; glassNo++)
     441      {
     442        var glass = uncompleted[glassNo];
     443     
     444        html += '<div class="menuitem enabled" id="glass-'+glass.id+'">';
     445        html += Main.encodeTags(glass.name)+'</div>';
     446      }
     447      setInnerHTML('select-uncompleted-heglass-menu', html);
     448      Main.show('uncompletedHeGlass');
     449    }
     450    else
     451    {
     452      Main.hide('uncompletedHeGlass');
     453    }
     454  }
     455}
     456
     457function showUncompletedHeGlassMenu(event)
     458{
     459  var menu = document.getElementById('select-uncompleted-heglass');
     460  menu.style.display = 'block';
     461 
     462  var pos = Main.getElementPosition(document.getElementById('uncompletedHeGlass'));
     463  var x = pos.left;
     464  var y = pos.top+pos.height;
     465
     466  menu.style.left = (x)+'px';
     467  menu.style.top = (y)+'px';
     468  event.stopPropagation();
     469}
     470
     471function uncompletedGlassSelected(event)
     472{
     473  findHeGlass(event.target.innerHTML);
    368474}
    369475</script>
     
    541647}
    542648
     649#select-uncompleted-heglass-menu
     650{
     651  max-height: 20em;
     652  overflow: auto;
     653}
     654
     655#select-uncompleted-heglass .menuitem
     656{
     657  padding-left: 16px;
     658}
     659
     660#select-uncompleted-heglass .menuitem:hover
     661{
     662  padding-left: 14px;
     663  background-position: 0px 50%;
     664}
    543665</style>
    544666
     
    551673    /></p:path>
    552674
    553   <div class="content">
     675  <div class="content" onclick="Main.hide('select-uncompleted-heglass')">
    554676  <%
    555677  if (sc.getActiveProjectId() == 0)
     
    563685  }
    564686  %>
     687 
     688  <div id="select-uncompleted-heglass" class="menu vertical" style="width: 150px; display: none;"
     689    onclick="uncompletedGlassSelected(event)">
     690    <div id="select-uncompleted-heglass-menu"></div>
     691  </div>
     692 
    565693  <form name="reggie" onsubmit="return false;">
    566694 
     
    574702      <tbl:toolbar subclass="bottomborder">
    575703        <tbl:label>
    576         <input type="text" style="width: 12em;" placeholder="Find HE glass" tooltip="Enter a HE glass name">
    577         <img src="../images/gonext.png">
     704        <input type="text" style="width: 12em;" name="findGlassName"
     705          placeholder="Find HE glass" title="Enter a full HE glass name or the last digits in the it's number before the dot"
     706          onkeypress="if (event.keyCode==13 && this.value) findHeGlass()"
     707          >
     708          <base:icon image="<%=home+"/images/gonext.png"%>" onclick="findHeGlass()"></base:icon>
    578709        </tbl:label>
    579710       
    580         <tbl:button
    581           id="uncompletedHeGlass"
    582           title="4 uncompleted HE glass"
    583           image="mini_scroll_down.png"
    584         />
    585711     
    586712        <tbl:button
     
    590716          tooltip="Manually select a different HE glass"
    591717        />
     718
     719        <tbl:button
     720          id="uncompletedHeGlass"
     721          title="Loading..."
     722          image="mini_scroll_down.png"
     723          onclick="showUncompletedHeGlassMenu(event)"
     724          tooltip="This list contain HE glass with partial scores"
     725        />
     726
    592727      </tbl:toolbar>
    593728     
     
    719854  <table style="margin-left: 20px; margin-top: 10px;" class="navigation" id="navigation">
    720855    <tr>
    721       <td><base:button id="gocancel" title="Cancel" onclick="goRestart(false)" /></td>
     856      <td><base:button id="gocancel" title="Cancel" onclick="goRestart(false)" style="display: none;" /></td>
    722857      <td><base:button id="gonext" title="Next" image="<%=home+"/images/gonext.png"%>" onclick="goNext(true)" style="display: none;" /></td>
    723858      <td><base:button id="gocreate" title="Save" image="<%=home+"/images/gonext.png"%>" onclick="goCreate()" style="display: none;" /></td>
Note: See TracChangeset for help on using the changeset viewer.