Changeset 2486


Ignore:
Timestamp:
Aug 3, 2006, 5:20:10 PM (17 years ago)
Author:
Martin Svensson
Message:

References #173. Possible to attach a hardware to a PlateEvent? in the GUI

Location:
trunk/www/lims/plates/events
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/lims/plates/events/edit_event.jsp

    r2456 r2486  
    3333  import="net.sf.basedb.core.SystemItems"
    3434  import="net.sf.basedb.core.Permission"
     35  import="net.sf.basedb.core.Hardware"
     36  import="net.sf.basedb.core.HardwareType"
    3537  import="net.sf.basedb.core.Include"
    3638  import="net.sf.basedb.core.Plate"
     
    7981  ProtocolType currentProtocolType = null;
    8082  boolean readCurrentProtocolType = true;
     83  Hardware currentHardware = null;
     84  boolean readCurrentHardware = true;
    8185
    8286  ItemResultList<PlateEventType> eventTypes = null;
     
    97101      throw new WebException("popup", "No more event types can be created",
    98102        "One event of each event type has already been created for this plate.");
    99     }
    100    
     103    }   
    101104   
    102105    if (cc.getPropertyFilter("protocolType.name") != null)
     
    126129    {
    127130      readCurrentProtocolType = false;
     131    }
     132    try
     133    {
     134      currentHardware = event.getHardware();
     135    }
     136    catch(PermissionDeniedException ex)
     137    {
     138      readCurrentHardware = false;
    128139    }
    129140  }
     
    157168    }
    158169   
    159     var protocolTypeFilter = <%=currentProtocolType != null ? currentProtocolType.getId() : 0%>;
     170    var protocolTypeFilter = <%=currentProtocolType != null ? currentProtocolType.getId() : 0%>;   
    160171    function selectProtocolOnClick()
    161172    {
     
    183194      frm.protocol_id[1].text = name;
    184195      frm.protocol_id.selectedIndex = 1;
     196    }
     197    function selectHardwareOnClick()
     198    {
     199      var frm = document.forms['event'];
     200      var url = '../../../admin/hardware/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setHardwareCallback';
     201      if (frm.hardware_id.length > 1)
     202      {
     203        var id = Math.abs(parseInt(frm.hardware_id[1].value));
     204        url += '&item_id='+id;
     205      }
     206      Main.openPopup(url, 'SelectHardware', 1000, 700);
     207    }
     208    function setHardwareCallback(hardwareId, name)
     209    {
     210      var frm = document.forms['event'];
     211      if (frm.hardware_id.length < 2)
     212      {
     213        frm.hardware_id[frm.hardware_id.length] = new Option();
     214      }
     215      frm.hardware_id[1].value = hardwareId;
     216      frm.hardware_id[1].text = name;
     217      frm.hardware_id.selectedIndex = 1;
    185218    }
    186219
     
    329362        </td>
    330363      </tr>
     364      <tr>
     365        <td class="prompt">Hardware</td>
     366        <td>
     367          <table border="0" cellspacing="0" cellpadding="0">
     368          <tr>
     369          <td>
     370            <select name="hardware_id" size="1"
     371              <%=!readCurrentHardware ? "disabled readonly class=\"disabled\"" : ""%>
     372              style="width: 20em;">
     373            <%
     374            if (!readCurrentHardware)
     375            {
     376              %>
     377              <option value="-1">- denied -
     378              <%
     379            }
     380            else
     381            {
     382              %>
     383              <option value="0">- none -
     384              <%
     385              if (currentHardware != null)
     386              {
     387                %>
     388                <option value="<%=event == null ? currentHardware.getId() : -currentHardware.getId()%>"
     389                  selected><%=HTML.encodeTags(currentHardware.getName())%>
     390                <%               
     391              }
     392            }
     393            %>
     394            </select>
     395            &nbsp;
     396          </td>
     397          <td><base:button onclick="selectHardwareOnClick()"
     398            title="Select&hellip;" disabled="<%=!readCurrentHardware%>"/></td>
     399          </tr>
     400          </table>
     401        </td>
     402      </tr>
    331403      <tr valign=top>
    332404        <td class="prompt">Comment</td>
  • trunk/www/lims/plates/events/index.jsp

    r2446 r2486  
    2828  import="net.sf.basedb.core.SessionControl"
    2929  import="net.sf.basedb.core.DbControl"
     30  import="net.sf.basedb.core.Hardware"
    3031  import="net.sf.basedb.core.Item"
    3132  import="net.sf.basedb.core.ItemContext"
     
    146147      event.setProtocol(pt);
    147148    }
     149    int hardwareId = Values.getInt(request.getParameter("hardware_id"), -1);
     150    if (hardwareId >= 0) // < 0 = denied or unchanged
     151    {
     152      Hardware hw = hardwareId == 0 ? null : Hardware.getById(dc, hardwareId);
     153      event.setHardware(hw);
     154    }
    148155    dc.commit();
    149156    cc.removeObject("item");
  • trunk/www/lims/plates/events/list_events.jsp

    r2446 r2486  
    260260        title="Protocol"
    261261        sortable="true"
     262        filterable="true"
     263        exportable="true"
     264      />
     265      <tbl:columndef
     266        id="hardware"
     267        property="hardware.name"
     268        datatype="string"
     269        title="Hardware"
     270        sortable="true"
    262271        filterable="true"
    263272        exportable="true"
     
    419428                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
    420429                  /></tbl:cell>
     430                <tbl:cell column="hardware"
     431                  ><base:propertyvalue
     432                    item="<%=item%>"
     433                    property="hardware"
     434                    enableEditLink="<%=mode.hasEditLink()%>"
     435                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
     436                  /></tbl:cell>
    421437                <tbl:cell column="entryDate"><%=Values.formatDate(item.getEntryDate())%></tbl:cell>
    422438                <tbl:cell column="eventDate"><%=Values.formatDate(item.getEventDate())%></tbl:cell>
  • trunk/www/lims/plates/events/view_event.jsp

    r2446 r2486  
    8282    readCurrentEventType = false;
    8383  }
    84   Protocol currentProtocol = null;
    85   boolean readCurrentProtocol = true;
    86   try
    87   {
    88     currentProtocol = event.getProtocol();
    89   }
    90   catch (PermissionDeniedException ex)
    91   {
    92     readCurrentProtocol = false;
    93   }
    9484 
    9585  final boolean writePermission = event.hasPermission(Permission.WRITE);
     
    202192      </tr>
    203193      <tr>
     194        <td class="prompt">Hardware</td>
     195        <td><base:propertyvalue item="<%=event%>" property="hardware" /></td>
     196      </tr>
     197      <tr>
    204198        <td class="prompt">Comment</td>
    205199        <td><%=HTML.niceFormat(event.getComment())%></td>
Note: See TracChangeset for help on using the changeset viewer.