Changeset 2472


Ignore:
Timestamp:
Jul 31, 2006, 8:43:18 AM (17 years ago)
Author:
Martin Svensson
Message:

Added pool button for samples, extracts and labeledextracts.

Location:
trunk/www
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/biomaterials/extracts/edit_extract.jsp

    r2466 r2472  
    9393      name = currentSample.getName() + ".e" + (currentSample.countExtracts() + 1);     
    9494    }
     95    else if(Values.getBoolean(request.getParameter("pooled")))
     96    {
     97      isPooled = true;
     98      name = Values.getString(cc.getPropertyValue("name"), "New pooled extract");
     99    }
    95100    else
    96101    {
     
    283288      {
    284289        frm.used_quantity.value = item.value;
     290        frm.used_quantity.focus();
    285291      }
    286292      else
     
    348354          %>
    349355          Link.addNewItem(extracts, new Item('E', <%=e.getId()%>, '<%=HTML.javaScriptEncode(e.getName())%> [<%=usedQuantity%> µg]', '<%=usedQuantity%>'));
     356          <%
     357        }
     358      }
     359      else if (extract == null && Values.getBoolean(request.getParameter("pooled")))
     360      {
     361        for (int eId : cc.getSelected())
     362        {
     363          Extract extractToPool = Extract.getById(dc, eId);
     364          %>
     365          Link.addNewItem(extracts, new Item('E', <%=extractToPool.getId()%>, '<%=HTML.javaScriptEncode(extractToPool.getName())%> [-]', '', '0'));
    350366          <%
    351367        }
  • trunk/www/biomaterials/extracts/index.jsp

    r2464 r2472  
    124124    forward = editPage;
    125125  }
     126  else if ("NewPooledItem".equals(cmd))
     127  {
     128    // Display the edit page for a new pooled item (should be opened in a popup)
     129    if (!sc.hasPermission(Permission.CREATE, itemType))
     130    {
     131      throw new PermissionDeniedException(Permission.CREATE, itemType.toString());
     132    }
     133    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     134    cc.setId(0);
     135    forward = editPage+"&pooled="+true;
     136  }
    126137  else if ("UpdateItem".equals(cmd))
    127138  {
  • trunk/www/biomaterials/extracts/list_extracts.jsp

    r2464 r2472  
    107107      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', 0, true);
    108108    }
     109    function newPooledItem()
     110    {
     111      Table.poolItems(submitPage, '<%=ID%>', formId, '<%=itemType.name()%>', 'NewPooledItem');
     112    }
    109113    function editItem(itemId)
    110114    {
     
    349353          title="New&hellip;"
    350354          tooltip="<%=createPermission ? "Create new extract" : "You do not have permission to create extracts"%>"
     355        />
     356        <tbl:button
     357          disabled="<%=createPermission ? false : true%>"
     358          image="<%=createPermission ? "new_pooled.gif" : "new_pooled_disabled.gif"%>"
     359          onclick="newPooledItem()"
     360          title="Pool&hellip;"
     361          tooltip="<%=createPermission ? "Create new pooled extract" : "You do not have permission to create extracts"%>"
    351362        />
    352363        <tbl:button
  • trunk/www/biomaterials/labeledextracts/edit_labeledextract.jsp

    r2466 r2472  
    105105      name = currentExtract.getName() +".lbe"+ (currentExtract.countLabeledExtracts() + 1);
    106106    }
     107    else if (Values.getBoolean(request.getParameter("pooled")))
     108    {
     109      isPooled = true;
     110      name = Values.getString(cc.getPropertyValue("name"), "New pooled labeled extract");
     111    }
    107112    else
    108113    {
     
    311316      {
    312317        frm.used_quantity.value = item.value;
     318        frm.used_quantity.focus();
    313319      }
    314320      else
     
    375381          %>
    376382          Link.addNewItem(extracts, new Item('E', <%=e.getId()%>, '<%=HTML.javaScriptEncode(e.getName())%> [<%=usedQuantity%> µg]', '<%=usedQuantity%>'));
     383          <%
     384        }
     385      }
     386      else if (extract == null  && Values.getBoolean(request.getParameter("pooled")))
     387      {
     388        for (int id : cc.getSelected())
     389        {
     390          LabeledExtract e = LabeledExtract.getById(dc, id);
     391          %>
     392          Link.addNewItem(extracts, new Item('E', <%=e.getId()%>, '<%=HTML.javaScriptEncode(e.getName())%> [-]', '', '0'));
    377393          <%
    378394        }
     
    584600          <td>
    585601            <select name="labeledextracts" size="5" multiple style="width: 20em;"
    586               onchange="extractsOnChange()">
     602              onchange="labeledExtractsOnChange()">
    587603            </select>&nbsp;<br>
    588604            Used
  • trunk/www/biomaterials/labeledextracts/index.jsp

    r2465 r2472  
    125125    forward  = editPage;
    126126  }
     127  else if ("NewPooledItem".equals(cmd))
     128  {
     129    //Display the edit page for a new pooled item (should be opened in a popup)
     130    if (!sc.hasPermission(Permission.CREATE, itemType))
     131    {
     132      throw new PermissionDeniedException(Permission.CREATE, itemType.toString());
     133    }
     134    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     135    cc.setId(0);
     136    forward  = editPage+"&pooled="+true;
     137  }
    127138  else if ("UpdateItem".equals(cmd))
    128139  {
  • trunk/www/biomaterials/labeledextracts/list_labeledextracts.jsp

    r2466 r2472  
    103103      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', 0, true);
    104104    }
     105    function newPooledItem()
     106    {
     107      Table.poolItems(submitPage, '<%=ID%>', formId, '<%=itemType.name()%>', 'NewPooledItem');
     108    }
    105109    function editItem(itemId)
    106110    {
     
    290294      />
    291295      <tbl:columndef
    292         id="parent"
    293         title="Parent"
     296        id="parents"
     297        title="Parents"
    294298      />
    295299      <tbl:columndef
     
    357361          title="New&hellip;"
    358362          tooltip="<%=createPermission ? "Create new labeled extract" : "You do not have permission to create labeled extracts"%>"
     363        />
     364        <tbl:button
     365          disabled="<%=createPermission ? false : true%>"
     366          image="<%=createPermission ? "new_pooled.gif" : "new_pooled_disabled.gif"%>"
     367          onclick="newPooledItem()"
     368          title="Pool&hellip;"
     369          tooltip="<%=createPermission ? "Create new pooled labeled extract" : "You do not have permission to create labeled extracts"%>"
    359370        />
    360371        <tbl:button
     
    520531                <tbl:cell column="eventDate"><%=Values.formatDate(creationEvent.getEventDate())%></tbl:cell>
    521532                <tbl:cell column="entryDate"><%=Values.formatDate(creationEvent.getEntryDate())%></tbl:cell>
    522                 <tbl:cell column="parent">
     533                <tbl:cell column="parents">
    523534                  <%
    524535                  if (!item.isPooled())
     
    531542                  {
    532543                    String separator = "";
    533                     ItemQuery<Extract> parentQuery = (ItemQuery<Extract>)item.getCreationEvent().getSources();
     544                    ItemQuery<LabeledExtract> parentQuery = (ItemQuery<LabeledExtract>)item.getCreationEvent().getSources();
    534545                    parentQuery.include(Include.MINE, Include.OTHERS, Include.IN_PROJECT, Include.SHARED);
    535546                    parentQuery.order(Orders.asc(Hql.property("name")));
    536547                   
    537                     for (Extract e : parentQuery.list(dc))
     548                    for (LabeledExtract e : parentQuery.list(dc))
    538549                    {
    539550                      out.write(separator);
  • trunk/www/biomaterials/samples/edit_sample.jsp

    r2456 r2472  
    9292      name = currentBioSource.getName() + ".s" + (currentBioSource.countSamples() + 1);
    9393    }
     94    else if (Values.getBoolean(request.getParameter("pooled")))
     95    {   
     96      isPooled = true;
     97      name = Values.getString(cc.getPropertyValue("name"),"New pooled sample");
     98    }
    9499    else
    95100    {
     
    279284      {
    280285        frm.used_quantity.value = item.value;
     286        frm.used_quantity.focus();
    281287      }
    282288      else
     
    333339          %>
    334340          Link.addNewItem(samples, new Item('S', <%=s.getId()%>, '<%=HTML.javaScriptEncode(s.getName())%> [<%=usedQuantity%> µg]', '<%=usedQuantity%>'));
     341          <%
     342        }
     343      }
     344      else if(sample == null && Values.getBoolean(request.getParameter("pooled")))
     345      {
     346        for (int sid : cc.getSelected())
     347        {
     348          Sample sampleToPool = Sample.getById(dc, sid);
     349          %>
     350          Link.addNewItem(samples, new Item('S', <%=sampleToPool.getId()%>, '<%=HTML.javaScriptEncode(sampleToPool.getName())%> [-]', '', '0'));
    335351          <%
    336352        }
  • trunk/www/biomaterials/samples/index.jsp

    r2421 r2472  
    124124    forward = editPage;
    125125  }
     126  else if ("NewPooledItem".equals(cmd))
     127  {
     128    // Display the edit page for a new pooled item (should be opened in a popup)
     129    if (!sc.hasPermission(Permission.CREATE, itemType))
     130    {
     131      throw new PermissionDeniedException(Permission.CREATE, itemType.toString());
     132    }
     133    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     134    cc.setId(0);
     135    forward = editPage+"&pooled="+true;
     136  }
    126137  else if ("UpdateItem".equals(cmd))
    127138  {
  • trunk/www/biomaterials/samples/list_samples.jsp

    r2437 r2472  
    108108      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', 0, true);
    109109    }
     110    function newPooledItem()
     111    {
     112      Table.poolItems(submitPage, '<%=ID%>', formId, '<%=itemType.name()%>', 'NewPooledItem');
     113    }
    110114    function editItem(itemId)
    111115    {
     
    350354          title="New&hellip;"
    351355          tooltip="<%=createPermission ? "Create new sample" : "You do not have permission to create samples"%>"
     356        />
     357        <tbl:button
     358          disabled="<%=createPermission ? false : true%>"
     359          image="<%=createPermission ? "new_pooled.gif" : "new_pooled_disabled.gif"%>"
     360          onclick="newPooledItem()"
     361          title="Pool&hellip;"
     362          tooltip="<%=createPermission ? "Create new pooled sample" : "You do not have permission to create samples"%>"
    352363        />
    353364        <tbl:button
  • trunk/www/include/scripts/table.js

    r2368 r2472  
    189189    if (extraParameters) url += '&'+extraParameters;
    190190    Main.openPopup(url, 'Export'+tableId, 600, 460);
     191  }
     192 
     193  this.poolItems = function(submitPage, ID, tableId, itemType, cmd, regexp)
     194  {
     195    var frm = document.forms[tableId];
     196    if (Forms.numChecked(frm) < 2)
     197    {
     198      alert('Please select at least two items in the list');
     199      return;
     200    }
     201    var oldAction = frm.action;
     202    var oldCmd = frm.cmd.value;
     203    frm.action = submitPage;
     204    frm.cmd.value = cmd ? cmd : "NewPooledItem";
     205    frm.target = 'NewPooledItem'+tableId;
     206    Main.openPopup('', 'NewPooledItem'+tableId, 800, 500);
     207    frm.submit();
     208    frm.target = window.name;
     209    frm.action = oldAction;
     210    frm.cmd.value = oldCmd;
    191211  }
    192212 
Note: See TracChangeset for help on using the changeset viewer.