source: trunk/www/biomaterials/lists/edit_list.jsp @ 4705

Last change on this file since 4705 was 4705, checked in by Nicklas Nordborg, 14 years ago

Fixes #1191: Biomaterial lists manager API and interface

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 7.2 KB
Line 
1<%-- $Id: edit_list.jsp 4705 2008-12-16 13:29:12Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2008 Nicklas Nordborg
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23  @version 2.10
24--%>
25<%@ page session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.Item"
29  import="net.sf.basedb.core.ItemContext"
30  import="net.sf.basedb.core.Permission"
31  import="net.sf.basedb.core.BioMaterialList"
32  import="net.sf.basedb.core.PermissionDeniedException"
33  import="net.sf.basedb.clients.web.Base"
34  import="net.sf.basedb.clients.web.util.HTML"
35  import="net.sf.basedb.util.Values"
36%>
37<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
38<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
39<%
40final Item itemType = Item.BIOMATERIALLIST;
41final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
42final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
43final int itemId = cc.getId();
44final String ID = sc.getId();
45final float scale = Base.getScale(sc);
46final DbControl dc = sc.newDbControl();
47try
48{
49  String title = null;
50  BioMaterialList list = null;
51  Item memberType = null;
52  boolean mergeLists = false;
53  int numSelectedLists = cc.getSelected().size();
54 
55  if (itemId == 0)
56  {
57    title = "Create biomaterial list";
58    cc.removeObject("item");
59    memberType = Item.fromValue(Values.getInt(cc.getPropertyValue("memberType")));
60    mergeLists = numSelectedLists > 0;
61  }
62  else
63  {
64    list = BioMaterialList.getById(dc, itemId);
65    memberType = list.getMemberType();
66    cc.setObject("item", list);
67    title = "Edit biomaterial list -- " + HTML.encodeTags(list.getName());
68    list.checkPermission(Permission.WRITE);
69  }
70 
71  final String clazz = "class=\"text\"";
72  final String requiredClazz = "class=\"text required\"";
73  %>
74
75  <base:page type="popup" title="<%=title%>">
76  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
77    <script language="JavaScript">
78    // Validate the "Biomaterial list" tab
79    function validateList()
80    {
81      var frm = document.forms['list'];
82      if (Main.trimString(frm.name.value) == '')
83      {
84        alert("You must enter a name");
85        frm.name.focus();
86        return false;
87      }
88      return true;
89    }
90
91    // Submit the form
92    function saveSettings()
93    {
94      var frm = document.forms['list'];
95      if (TabControl.validateActiveTab('settings'))
96      {
97        frm.submit();
98      }
99    }
100   
101    function init()
102    {
103      <%
104      if (list == null)
105      {
106        %>
107        var frm = document.forms['list'];
108        frm.name.focus();
109        frm.name.select();
110        <%
111      }
112      %>
113    }
114    function checkRadio(radio, name)
115    {
116      Forms.checkRadio(radio, name);
117    }
118    </script>
119  </base:head>
120  <base:body onload="init()">
121    <p>
122    <form action="index.jsp?ID=<%=ID%>" method="post" name="list" onsubmit="return false;">
123    <input type="hidden" name="cmd" value="UpdateItem">
124    <h3 class="docked"><%=title%> <base:help tabcontrol="settings"/></h3>
125    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" 
126      position="bottom"  remember="<%=list != null%>">
127    <t:tab id="info" title="Biomaterial list" validate="validateList()" helpid="biomateriallist.edit">
128      <table class="form" cellspacing=0>
129      <tr>
130        <td class="prompt">Name</td>
131        <td><input <%=requiredClazz%> type="text" name="name" 
132          value="<%=HTML.encodeTags(list == null ? Values.getString(cc.getPropertyValue("name"), "New list") : list.getName())%>" 
133          size="40" maxlength="<%=BioMaterialList.MAX_NAME_LENGTH%>"></td>
134      </tr>
135      <tr>
136        <td class="prompt">Member type</td>
137        <td>
138          <select name="memberType">
139            <option value="BIOSOURCE" <%=memberType == Item.BIOSOURCE ? "selected" : ""%>>Biosource
140            <option value="SAMPLE" <%=memberType == Item.SAMPLE ? "selected" : ""%>>Sample
141            <option value="EXTRACT" <%=memberType == Item.EXTRACT ? "selected" : ""%>>Extract
142            <option value="LABELEDEXTRACT" <%=memberType == Item.LABELEDEXTRACT ? "selected" : ""%>>Labeled extract
143          </select>
144        </td>
145      </tr>
146      <%
147      if (mergeLists)
148      {
149        %>
150        <tr valign="top">
151          <td class="prompt">Add members?</td>
152          <td>
153            <input type="radio" name="create" value=""><a
154              href="javascript:checkRadio(document.forms['list'].create, '');"
155              title="The new list will be empty"
156              >No</a><br>
157            <input type="radio" name="create" value="union" checked><a
158              href="javascript:checkRadio(document.forms['list'].create, 'union');"
159              title="The new list contains all items from the selected lists"
160              >Union of selected lists</a> <base:icon image="set_operations/union_small.png" /><br>
161            <input type="radio" name="create" value="intersection"><a
162              href="javascript:checkRadio(document.forms['list'].create, 'intersection');"
163              title="The new list contains only items that are present in ALL selected lists"
164              >Intersection of selected lists</a> <base:icon image="set_operations/intersection_small.png" /><br>
165            <input type="radio" name="create" value="count"><a
166              href="javascript:checkRadio(document.forms['list'].create, 'count');"
167              title="The new list contains only items that are present in some of selected lists"
168              >Present in at least</a>
169              <input type="text" class="text" name="minCount" size="2" maxlength="2"
170                value="1"
171                onkeypress="return Numbers.integerOnly(event)"
172                onfocus="checkRadio(document.forms['list'].create, 'count');">
173              of the selected lists (1-<%=numSelectedLists%>).
174              <br>
175           
176          </td>
177        </tr>
178        <%
179      }
180      %>
181      <tr>
182        <td class="prompt">External ID</td>
183        <td><input <%=clazz%> type="text" name="external_id" 
184          value="<%=HTML.encodeTags(list == null ? Values.getString(cc.getPropertyValue("externalId"), "") : list.getExternalId())%>" 
185          size="40" maxlength="<%=BioMaterialList.MAX_EXTERNAL_ID_LENGTH%>"></td>
186      </tr>
187      <tr valign=top>
188        <td class="prompt">Description</td>
189        <td nowrap>
190          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
191            ><%=HTML.encodeTags(list == null ? cc.getPropertyValue("description") : list.getDescription())%></textarea>
192          <a href="javascript:Main.zoom('Description', 'list', 'description')"
193            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
194        </td>
195      </tr>
196      </table>
197      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
198    </t:tab>
199    </t:tabcontrol>
200
201    <table align="center">
202    <tr>
203      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
204      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
205    </tr>
206    </table>
207    </form>
208  </base:body>
209  </base:page>
210  <%
211}
212finally
213{
214  if (dc != null) dc.close();
215}
216%>
Note: See TracBrowser for help on using the repository browser.