Changeset 5722


Ignore:
Timestamp:
Sep 7, 2011, 11:26:07 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1597: Subtypes of items

Update the "Move biomaterial" plate event wizard to use item subtypes when possible.

Display item subtype for biomaterials in tooltip on the single-item page for plates.

Location:
trunk/www
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/biomaterials/bioplates/view_bioplate.jsp

    r5708 r5722  
    187187      var pos = Main.getElementPosition(wellTd);
    188188      wellInfo.style.left = (pos.left + pos.width - 5) + 'px';
    189       wellInfo.style.top = (pos.top + 15) + 'px';
     189      wellInfo.style.top = (pos.top + 10) + 'px';
    190190      Main.show('wellInfo');
    191191
     
    210210          var id = bioMaterial.id;
    211211          var type = bioMaterial.type;
    212           html = '<b>' + type + '</b>: ';
    213           html += Main.linkItem('<%=ID%>', type, id, bioMaterial.editable, bioMaterial.name);
     212          var subtype = bioMaterial.subtype;
     213          html = Main.linkItem('<%=ID%>', type, id, bioMaterial.editable, bioMaterial.name);
     214          html += ': <b>' + type + '</b>';
     215          if (subtype) html += ' <span class="itemsubtype">[' + subtype.name + ']</span>';
    214216          html += '<br>'+bioMaterial.description;
    215217        }
     
    523525        %>
    524526        </table>
    525         <div class="postit" id="wellInfo" style="display:none; width: 300px;" onmouseout="event.cancelBubble=true"></div>
     527        <div class="postit" id="wellInfo" style="display:none; width: 300px; min-height: 30px;" onmouseout="event.cancelBubble=true"></div>
    526528      </base:section>
    527529      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
  • trunk/www/biomaterials/bioplates/wells/ajax.jsp

    r5557 r5722  
    2828  import="net.sf.basedb.core.BioWell"
    2929  import="net.sf.basedb.core.MeasuredBioMaterial"
     30  import="net.sf.basedb.core.ItemSubtype"
    3031  import="net.sf.basedb.core.InvalidDataException"
    3132  import="net.sf.basedb.core.PermissionDeniedException"
     
    7273        jsonBioMaterial.put("description", encodeStrings ? HTML.niceFormat(bioMaterial.getDescription()) : bioMaterial.getDescription());
    7374        jsonBioMaterial.put("editable", bioMaterial.hasPermission(Permission.WRITE));
     75        ItemSubtype subtype = bioMaterial.getItemSubtype();
     76        if (subtype != null)
     77        {
     78          JSONObject jsonSubtype = new JSONObject();
     79          jsonSubtype.put("id", subtype.getId());
     80          jsonSubtype.put("name", HTML.encodeTags(subtype.getName()));
     81          jsonBioMaterial.put("subtype", jsonSubtype);
     82        }
    7483      }
    7584      catch (PermissionDeniedException ex)
     
    7988      json.put("bioMaterial", jsonBioMaterial);
    8089    }
    81     /*
    82     String status = "Ok";
    83     MeasuredBioMaterial bioMaterial = null;
    84     if (isEmpty && !hasBeenUsed)
    85     {
    86       status = "Empty";
    87     }
    88     else
    89     {
    90       try
    91       {
    92         bm = isEmpty ? w.getOriginalBioMaterial() : w.getBioMaterial();
    93       }
    94       catch (PermissionDeniedException ex)
    95       {
    96         status = "Denied";
    97         bm = null;
    98       }
    99     }
    100     aw.ajaxPrintEntry("status", status);
    101     aw.ajaxPrintEntry("id", w.getId());
    102     json.put("id", well.getId());
    103    
    104     if (bm != null)
    105     {
    106       aw.ajaxPrintEntry("bm.id", bm.getId());
    107       aw.ajaxPrintEntry("bm.type", bm.getType().name());
    108       aw.ajaxPrintEntry("bm.editable", bm.hasPermission(Permission.WRITE) ? "1" : "0");
    109       aw.ajaxPrintEntry("bm.name", encodeStrings ? HTML.encodeTags(bm.getName()) : bm.getName());
    110       aw.ajaxPrintEntry("bm.description", encodeStrings ? HTML.niceFormat(bm.getDescription()) : bm.getDescription());
    111     }
    112     aw.ajaxEndRecord();
    113     */
    11490    dc.close();
    11591  }
  • trunk/www/biomaterials/events/index.jsp

    r5590 r5722  
    5555<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
    5656<%!
    57   private static final ItemContext defaultContext = Base.createDefaultContext("entryDate", "type,entryDate,eventDate,quantity,protocol,comment");
     57  private static final ItemContext defaultContext = Base.createDefaultContext("entryDate", "type,bioPlateEvent,entryDate,eventDate,quantity,protocol,comment");
    5858  private static final Item itemType = Item.BIOMATERIALEVENT;
    5959%>
  • trunk/www/biomaterials/wizards/index.jsp

    r5662 r5722  
    2222  @author Nicklas
    2323--%>
    24 <%@page import="net.sf.basedb.core.BioMaterialEventSource"%>
    2524<%@ page pageEncoding="UTF-8" session="false"
    2625  import="net.sf.basedb.core.SessionControl"
    2726  import="net.sf.basedb.core.BioMaterial"
    2827  import="net.sf.basedb.core.BioMaterialEvent"
     28  import="net.sf.basedb.core.BioMaterialEventSource"
    2929  import="net.sf.basedb.core.BioPlate"
    3030  import="net.sf.basedb.core.BioPlateType"
     
    310310              {
    311311                child = Extract.getNew(dc, destParticipant);
    312                 if (!pooled) ((Extract)child).setSample((Sample)parent).setUsedQuantity(usedQuantity);
     312                //if (!pooled) ((Extract)child).setSample((Sample)parent).setUsedQuantity(usedQuantity);
    313313              }
    314314              /*
  • trunk/www/biomaterials/wizards/move_biomaterial.jsp

    r5557 r5722  
    2828  import="net.sf.basedb.core.BioPlateEventType"
    2929  import="net.sf.basedb.core.MeasuredBioMaterial"
     30  import="net.sf.basedb.core.BioWell"
     31  import="net.sf.basedb.core.ItemSubtype"
    3032  import="net.sf.basedb.core.Hardware"
    3133  import="net.sf.basedb.core.Protocol"
     
    7173  catch (PermissionDeniedException ex)
    7274  {}
     75  ItemSubtype commonSubtype = null;
     76  boolean first = true;
     77  for (BioWell well : sourcePlate.getBioWells().list(dc))
     78  {
     79    try
     80    {
     81      if (!well.isEmpty())
     82      {
     83        ItemSubtype subtype = well.getBioMaterial().getItemSubtype();
     84        if (first)
     85        {
     86          commonSubtype = subtype;
     87          first = false;
     88        }
     89        else
     90        {
     91          if (subtype == null || !subtype.equals(commonSubtype))
     92          {
     93            commonSubtype = null;
     94            break;
     95          }
     96        }
     97      }
     98    }
     99    catch (PermissionDeniedException ex)
     100    {}
     101  }
     102  if (commonSubtype != null && itemType == null)
     103  {
     104    itemType = commonSubtype.getMainItemType();
     105  }
    73106 
    74107  final String clazz = "class=\"text\"";
     
    368401      var url = '../bioplates/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setBioPlateCallback';
    369402      url += '&resetTemporary=1&tmpfilter:INT:bioPlateType.bioMaterialType=<%=itemType == null ? "=" : "|" + itemType.getValue()%>'
     403      <%
     404      if (commonSubtype != null)
     405      {
     406        %>
     407        url += '&tmpfilter:INT:bioPlateType.itemSubtype=|<%=commonSubtype.getId()%>'
     408        <%
     409      }
     410      %>
    370411      url += '&exclude='+sourcePlate.id;
    371412      Main.openPopup(url, 'SelectBioPlate', 1000, 700);
     
    374415    function setBioPlateCallback(bioPlateId, name, isSourcePlate)
    375416    {
     417      var win = Main.getWindow('SelectBioPlate');
    376418      if (!isSourcePlate && bioPlateId == sourcePlate.id)
    377419      {
    378         alert('It is not possible to use the same plate as both source and destination plate.');
     420        win.alert('It is not possible to use the same plate as both source and destination plate.');
    379421        return;
    380422      }
     
    388430      if (plateInfo.status != 'ok')
    389431      {
    390         alert(plateInfo.message);
    391         return false;
     432        win.alert(plateInfo.message);
     433        return;
    392434      }
    393435
     
    556598      }
    557599      url += '&resetTemporary=1';
     600      <%
     601      if (commonSubtype != null)
     602      {
     603        ItemSubtype hardwareType = commonSubtype.getRelatedSubtype(Item.HARDWARE);
     604        if (hardwareType != null)
     605        {
     606          %>
     607          url += '&tmpfilter:INT:itemSubtype=<%=hardwareType.getId()%>';
     608          <%
     609        }
     610      }
     611      %>
    558612      Main.openPopup(url, 'SelectHardware', 1000, 700);
    559613    }
     
    581635      }
    582636      url += '&resetTemporary=1';
     637      <%
     638      ItemSubtype protocolType = null;
     639      if (commonSubtype != null)
     640      {
     641        protocolType = commonSubtype.getRelatedSubtype(Item.PROTOCOL);
     642        if (protocolType != null)
     643        {
     644          %>
     645          url += '&tmpfilter:INT:itemSubtype=<%=protocolType.getId()%>';
     646          <%
     647        }
     648      }
     649      %>
    583650      Main.openPopup(url, 'SelectProtocol', 1000, 700);
    584651    }
     
    621688      request.send(null);
    622689      var mappingInfo = Ajax.parseJsonResponse(request.responseText);
     690      var win = Main.getWindow('SelectPlateMapping');
    623691      if (mappingInfo.status != 'ok')
    624692      {
    625         alert(mappingInfo.message);
     693        win.alert(mappingInfo.message);
    626694        return false;
    627695      }
     
    629697      if (mappingInfo.sourcePlates != 1 || mappingInfo.sourceRows != sourcePlate.rows || mappingInfo.sourceColumns != sourcePlate.columns)
    630698      {
    631         if (!confirm("The selected mapping doesn't match the geometry of the source plate.\nContinue mapping overlapping positions?")) return;
     699        if (!win.confirm("The selected mapping doesn't match the geometry of the source plate.\nContinue mapping overlapping positions?")) return;
    632700      }
    633701      else if (mappingInfo.destinationPlates != 1 || mappingInfo.destinationRows != destPlate.rows || mappingInfo.destinationColumns != destPlate.columns)
    634702      {
    635         if (!confirm("The selected mapping doesn't match the geometry of the destination plate.\nContinue mapping overlapping positions?")) return;
     703        if (!win.confirm("The selected mapping doesn't match the geometry of the destination plate.\nContinue mapping overlapping positions?")) return;
    636704      }
    637705     
     
    662730  <base:body onload="init()">
    663731    <div id="canvas"></div>
    664     <h3>Move biomaterial to plate</h3>
     732    <h3>Move biomaterial to plate <base:help helpid="bioplateevent.move" /></h3>
    665733    <div class="boxedbottom" style="height: <%=(int)(scale*500)%>px; padding: 0px;">
    666734      <form name="main" action="index.jsp" method="post">
     
    776844          <div style="max-height: <%=(int)(scale*350)%>px; overflow: auto;">
    777845            <b>Source plate:</b> <span id="plate.src.name"></span>
     846            <%=commonSubtype != null ? "<span class=\"itemsubtype\">[" + HTML.encodeTags(commonSubtype.getName()) + "]</span>" : "" %>
    778847            <div id="plate.src"></div>
    779848          </div>
  • trunk/www/include/scripts/main.js

    r5714 r5722  
    156156    var win = this.getPageValue('open.windows', windowName);
    157157    if (win) win.focus();
     158  }
     159 
     160  /**
     161    Get a reference to a named window. If the window
     162    doesn't exists or if it is closed, a reference to
     163    the current window is returned.
     164   */
     165  this.getWindow = function(windowName)
     166  {
     167    var win = this.getPageValue('open.windows', windowName);
     168    if (!win || win.closed) win = window;
     169    return win;
    158170  }
    159171 
Note: See TracChangeset for help on using the changeset viewer.