6991 |
02 Nov 15 |
nicklas |
1 |
<%-- $Id $ |
6991 |
02 Nov 15 |
nicklas |
2 |
------------------------------------------------------------------ |
6991 |
02 Nov 15 |
nicklas |
Copyright (C) 2015 Nicklas Nordborg |
6991 |
02 Nov 15 |
nicklas |
4 |
|
6991 |
02 Nov 15 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
6991 |
02 Nov 15 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
6991 |
02 Nov 15 |
nicklas |
7 |
|
6991 |
02 Nov 15 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
6991 |
02 Nov 15 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
6991 |
02 Nov 15 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
6991 |
02 Nov 15 |
nicklas |
11 |
of the License, or (at your option) any later version. |
6991 |
02 Nov 15 |
nicklas |
12 |
|
6991 |
02 Nov 15 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
6991 |
02 Nov 15 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
6991 |
02 Nov 15 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6991 |
02 Nov 15 |
nicklas |
16 |
GNU General Public License for more details. |
6991 |
02 Nov 15 |
nicklas |
17 |
|
6991 |
02 Nov 15 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
6991 |
02 Nov 15 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
6991 |
02 Nov 15 |
nicklas |
20 |
------------------------------------------------------------------ |
6991 |
02 Nov 15 |
nicklas |
21 |
|
6991 |
02 Nov 15 |
nicklas |
22 |
@author Nicklas |
6991 |
02 Nov 15 |
nicklas |
23 |
--%> |
6991 |
02 Nov 15 |
nicklas |
24 |
<%@ page pageEncoding="UTF-8" session="false" |
6991 |
02 Nov 15 |
nicklas |
25 |
import="net.sf.basedb.core.SessionControl" |
6991 |
02 Nov 15 |
nicklas |
26 |
import="net.sf.basedb.core.DbControl" |
6991 |
02 Nov 15 |
nicklas |
27 |
import="net.sf.basedb.core.Item" |
6991 |
02 Nov 15 |
nicklas |
28 |
import="net.sf.basedb.core.ItemContext" |
6991 |
02 Nov 15 |
nicklas |
29 |
import="net.sf.basedb.core.Permission" |
6991 |
02 Nov 15 |
nicklas |
30 |
import="net.sf.basedb.core.Kit" |
6991 |
02 Nov 15 |
nicklas |
31 |
import="net.sf.basedb.core.ItemSubtype" |
6991 |
02 Nov 15 |
nicklas |
32 |
import="net.sf.basedb.core.AnnotationType" |
6991 |
02 Nov 15 |
nicklas |
33 |
import="net.sf.basedb.core.SystemItems" |
6991 |
02 Nov 15 |
nicklas |
34 |
import="net.sf.basedb.core.ItemQuery" |
6991 |
02 Nov 15 |
nicklas |
35 |
import="net.sf.basedb.core.ItemResultList" |
6991 |
02 Nov 15 |
nicklas |
36 |
import="net.sf.basedb.core.Include" |
6991 |
02 Nov 15 |
nicklas |
37 |
import="net.sf.basedb.core.PermissionDeniedException" |
6991 |
02 Nov 15 |
nicklas |
38 |
import="net.sf.basedb.core.query.Orders" |
6991 |
02 Nov 15 |
nicklas |
39 |
import="net.sf.basedb.core.query.Hql" |
6991 |
02 Nov 15 |
nicklas |
40 |
import="net.sf.basedb.clients.web.Base" |
6991 |
02 Nov 15 |
nicklas |
41 |
import="net.sf.basedb.clients.web.util.HTML" |
6991 |
02 Nov 15 |
nicklas |
42 |
import="net.sf.basedb.util.Values" |
6991 |
02 Nov 15 |
nicklas |
43 |
import="net.sf.basedb.util.formatter.Formatter" |
6991 |
02 Nov 15 |
nicklas |
44 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
6991 |
02 Nov 15 |
nicklas |
45 |
import="net.sf.basedb.clients.web.formatter.FormatterSettings" |
6991 |
02 Nov 15 |
nicklas |
46 |
import="net.sf.basedb.util.json.JsonUtil" |
6991 |
02 Nov 15 |
nicklas |
47 |
import="net.sf.basedb.util.json.NameableConverter" |
6991 |
02 Nov 15 |
nicklas |
48 |
import="net.sf.basedb.core.plugin.GuiContext" |
6991 |
02 Nov 15 |
nicklas |
49 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
6991 |
02 Nov 15 |
nicklas |
50 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
6991 |
02 Nov 15 |
nicklas |
51 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
52 |
import="net.sf.basedb.clients.web.extensions.tabcontrol.TabAction" |
6991 |
02 Nov 15 |
nicklas |
53 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
6991 |
02 Nov 15 |
nicklas |
54 |
import="java.util.List" |
6991 |
02 Nov 15 |
nicklas |
55 |
import="java.util.Date" |
6991 |
02 Nov 15 |
nicklas |
56 |
%> |
6991 |
02 Nov 15 |
nicklas |
57 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
6991 |
02 Nov 15 |
nicklas |
58 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
6991 |
02 Nov 15 |
nicklas |
59 |
<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
6991 |
02 Nov 15 |
nicklas |
60 |
<% |
6991 |
02 Nov 15 |
nicklas |
61 |
final Item itemType = Item.KIT; |
6991 |
02 Nov 15 |
nicklas |
62 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
6991 |
02 Nov 15 |
nicklas |
63 |
final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
6991 |
02 Nov 15 |
nicklas |
64 |
final int itemId = cc.getId(); |
6991 |
02 Nov 15 |
nicklas |
65 |
final String ID = sc.getId(); |
6991 |
02 Nov 15 |
nicklas |
66 |
final float scale = Base.getScale(sc); |
7954 |
12 May 21 |
nicklas |
67 |
final DbControl dc = sc.newDbControl(":Edit "+itemType); |
6991 |
02 Nov 15 |
nicklas |
68 |
try |
6991 |
02 Nov 15 |
nicklas |
69 |
{ |
6991 |
02 Nov 15 |
nicklas |
70 |
String title = null; |
6991 |
02 Nov 15 |
nicklas |
71 |
Kit kit = null; |
6991 |
02 Nov 15 |
nicklas |
72 |
boolean inactive = false; |
6991 |
02 Nov 15 |
nicklas |
73 |
Date expirationDate = null; |
6991 |
02 Nov 15 |
nicklas |
74 |
boolean readCurrentSubtype = true; |
6991 |
02 Nov 15 |
nicklas |
75 |
int currentSubtypeId = 0; |
6991 |
02 Nov 15 |
nicklas |
76 |
|
6991 |
02 Nov 15 |
nicklas |
77 |
if (itemId == 0) |
6991 |
02 Nov 15 |
nicklas |
78 |
{ |
6991 |
02 Nov 15 |
nicklas |
79 |
title = "Create kit"; |
6991 |
02 Nov 15 |
nicklas |
80 |
|
6991 |
02 Nov 15 |
nicklas |
81 |
currentSubtypeId = Values.getInt(request.getParameter("subtype_id")); |
6991 |
02 Nov 15 |
nicklas |
82 |
if (currentSubtypeId == 0) |
6991 |
02 Nov 15 |
nicklas |
83 |
{ |
6991 |
02 Nov 15 |
nicklas |
84 |
int recentSubtypeId = Values.getInt(cc.getRecent(Item.ITEMSUBTYPE.name(), 0)); |
6991 |
02 Nov 15 |
nicklas |
85 |
currentSubtypeId = Values.getInt(cc.getPropertyValue("itemSubtype"), recentSubtypeId); |
6991 |
02 Nov 15 |
nicklas |
86 |
} |
6991 |
02 Nov 15 |
nicklas |
87 |
cc.removeObject("item"); |
7605 |
26 Feb 19 |
nicklas |
88 |
expirationDate = cc.getPropertyObject("expirationDate"); |
6991 |
02 Nov 15 |
nicklas |
89 |
inactive = Values.getBoolean(cc.getPropertyValue("inactive")); |
6991 |
02 Nov 15 |
nicklas |
90 |
} |
6991 |
02 Nov 15 |
nicklas |
91 |
else |
6991 |
02 Nov 15 |
nicklas |
92 |
{ |
6991 |
02 Nov 15 |
nicklas |
93 |
kit = Kit.getById(dc, itemId); |
6991 |
02 Nov 15 |
nicklas |
94 |
kit.checkPermission(Permission.WRITE); |
6991 |
02 Nov 15 |
nicklas |
95 |
inactive = kit.isInactive(); |
6991 |
02 Nov 15 |
nicklas |
96 |
|
6991 |
02 Nov 15 |
nicklas |
97 |
cc.setObject("item", kit); |
6991 |
02 Nov 15 |
nicklas |
98 |
title = "Edit kit -- " + HTML.encodeTags(kit.getName()); |
6991 |
02 Nov 15 |
nicklas |
99 |
expirationDate = kit.getExpirationDate(); |
6991 |
02 Nov 15 |
nicklas |
100 |
try |
6991 |
02 Nov 15 |
nicklas |
101 |
{ |
6991 |
02 Nov 15 |
nicklas |
102 |
ItemSubtype subtype = kit.getItemSubtype(); |
6991 |
02 Nov 15 |
nicklas |
103 |
if (subtype != null) currentSubtypeId = subtype.getId(); |
6991 |
02 Nov 15 |
nicklas |
104 |
} |
6991 |
02 Nov 15 |
nicklas |
105 |
catch (PermissionDeniedException ex) |
6991 |
02 Nov 15 |
nicklas |
106 |
{ |
6991 |
02 Nov 15 |
nicklas |
107 |
readCurrentSubtype = false; |
6991 |
02 Nov 15 |
nicklas |
108 |
} |
6991 |
02 Nov 15 |
nicklas |
109 |
} |
6991 |
02 Nov 15 |
nicklas |
110 |
|
6991 |
02 Nov 15 |
nicklas |
111 |
// Query to retrieve kit types |
6991 |
02 Nov 15 |
nicklas |
112 |
final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType); |
6991 |
02 Nov 15 |
nicklas |
113 |
subtypesQuery.include(Include.ALL); |
6991 |
02 Nov 15 |
nicklas |
114 |
|
6991 |
02 Nov 15 |
nicklas |
115 |
Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
6991 |
02 Nov 15 |
nicklas |
116 |
String dateFormat = FormatterSettings.getDateFormat(sc); |
6991 |
02 Nov 15 |
nicklas |
117 |
String htmlDateFormat = HTML.encodeTags(dateFormat); |
6991 |
02 Nov 15 |
nicklas |
118 |
|
6991 |
02 Nov 15 |
nicklas |
119 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), kit); |
7604 |
25 Feb 19 |
nicklas |
120 |
ExtensionsInvoker<TabAction> invoker = EditUtil.useEditExtensions(jspContext); |
6991 |
02 Nov 15 |
nicklas |
121 |
%> |
6991 |
02 Nov 15 |
nicklas |
122 |
<base:page type="popup" title="<%=title%>" id="edit-page"> |
6991 |
02 Nov 15 |
nicklas |
123 |
<base:head scripts="tabcontrol-2.js,linkitems-2.js,subtypes.js,~kits.js" styles="tabcontrol.css"> |
6991 |
02 Nov 15 |
nicklas |
124 |
<ext:scripts context="<%=jspContext%>" /> |
6991 |
02 Nov 15 |
nicklas |
125 |
<ext:stylesheets context="<%=jspContext%>" /> |
6991 |
02 Nov 15 |
nicklas |
126 |
</base:head> |
6991 |
02 Nov 15 |
nicklas |
127 |
<base:body> |
6991 |
02 Nov 15 |
nicklas |
128 |
<h1><%=title%> <base:help tabcontrol="settings" /></h1> |
6991 |
02 Nov 15 |
nicklas |
129 |
<form action="index.jsp?ID=<%=ID%>" method="post" name="kit"> |
6991 |
02 Nov 15 |
nicklas |
130 |
<input type="hidden" name="cmd" value="UpdateItem"> |
6991 |
02 Nov 15 |
nicklas |
131 |
|
6991 |
02 Nov 15 |
nicklas |
132 |
<t:tabcontrol id="settings" |
6991 |
02 Nov 15 |
nicklas |
133 |
subclass="content dialogtabcontrol" |
6991 |
02 Nov 15 |
nicklas |
134 |
position="bottom" remember="<%=kit != null%>" |
6991 |
02 Nov 15 |
nicklas |
135 |
extensions="<%=invoker%>"> |
6991 |
02 Nov 15 |
nicklas |
136 |
<t:tab id="info" title="Kit" helpid="kit.edit"> |
6991 |
02 Nov 15 |
nicklas |
137 |
<table class="fullform input100 "> |
6991 |
02 Nov 15 |
nicklas |
138 |
<tr> |
6991 |
02 Nov 15 |
nicklas |
139 |
<th>Name</th> |
6991 |
02 Nov 15 |
nicklas |
140 |
<td><input class="text required auto-init" data-auto-init="<%=kit == null ? "focus-select" : "focus" %>" |
6991 |
02 Nov 15 |
nicklas |
141 |
type="text" name="name" |
6991 |
02 Nov 15 |
nicklas |
142 |
value="<%=HTML.encodeTags(kit == null ? Values.getString(cc.getPropertyValue("name"), "New kit") : kit.getName())%>" |
6991 |
02 Nov 15 |
nicklas |
143 |
maxlength="<%=Kit.MAX_NAME_LENGTH%>"></td> |
6991 |
02 Nov 15 |
nicklas |
144 |
<td></td> |
6991 |
02 Nov 15 |
nicklas |
145 |
</tr> |
6991 |
02 Nov 15 |
nicklas |
146 |
<tr> |
6991 |
02 Nov 15 |
nicklas |
147 |
<th>Type</th> |
6991 |
02 Nov 15 |
nicklas |
148 |
<td> |
6991 |
02 Nov 15 |
nicklas |
149 |
<select name="subtype_id" id="subtype_id" |
6991 |
02 Nov 15 |
nicklas |
150 |
<%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%> |
6991 |
02 Nov 15 |
nicklas |
151 |
> |
6991 |
02 Nov 15 |
nicklas |
152 |
<% |
6991 |
02 Nov 15 |
nicklas |
153 |
if (!readCurrentSubtype) |
6991 |
02 Nov 15 |
nicklas |
154 |
{ |
6991 |
02 Nov 15 |
nicklas |
155 |
%> |
6991 |
02 Nov 15 |
nicklas |
156 |
<option value="-1">- denied - |
6991 |
02 Nov 15 |
nicklas |
157 |
<% |
6991 |
02 Nov 15 |
nicklas |
158 |
} |
6991 |
02 Nov 15 |
nicklas |
159 |
else |
6991 |
02 Nov 15 |
nicklas |
160 |
{ |
6991 |
02 Nov 15 |
nicklas |
161 |
%> |
6991 |
02 Nov 15 |
nicklas |
162 |
<option value="0">-none- |
6991 |
02 Nov 15 |
nicklas |
163 |
<% |
6991 |
02 Nov 15 |
nicklas |
164 |
for (ItemSubtype subtype : subtypesQuery.list(dc)) |
6991 |
02 Nov 15 |
nicklas |
165 |
{ |
6991 |
02 Nov 15 |
nicklas |
166 |
int id = subtype.getId(); |
6991 |
02 Nov 15 |
nicklas |
167 |
if (id != currentSubtypeId && subtype.isRemoved()) continue; |
6991 |
02 Nov 15 |
nicklas |
168 |
%> |
6991 |
02 Nov 15 |
nicklas |
169 |
<option value="<%=id == currentSubtypeId && kit != null ? -id : id%>" |
6991 |
02 Nov 15 |
nicklas |
170 |
<%=id == currentSubtypeId ? "selected" : ""%> |
6991 |
02 Nov 15 |
nicklas |
171 |
title="<%=HTML.encodeTags(subtype.getDescription()) %>" |
6991 |
02 Nov 15 |
nicklas |
172 |
><%=HTML.encodeTags(subtype.getName())%> |
6991 |
02 Nov 15 |
nicklas |
173 |
<% |
6991 |
02 Nov 15 |
nicklas |
174 |
} |
6991 |
02 Nov 15 |
nicklas |
175 |
} |
6991 |
02 Nov 15 |
nicklas |
176 |
%> |
6991 |
02 Nov 15 |
nicklas |
177 |
</select> |
6991 |
02 Nov 15 |
nicklas |
178 |
</td> |
6991 |
02 Nov 15 |
nicklas |
179 |
<td></td> |
6991 |
02 Nov 15 |
nicklas |
180 |
</tr> |
6991 |
02 Nov 15 |
nicklas |
181 |
<tr> |
6991 |
02 Nov 15 |
nicklas |
182 |
<th>Expiration date</th> |
6991 |
02 Nov 15 |
nicklas |
183 |
<td> |
6991 |
02 Nov 15 |
nicklas |
184 |
<table> |
6991 |
02 Nov 15 |
nicklas |
185 |
<tr> |
6991 |
02 Nov 15 |
nicklas |
186 |
<td> |
6991 |
02 Nov 15 |
nicklas |
187 |
<input class="text" style="width: 15em;" type="text" name="expiration_date" id="expiration_date" |
6991 |
02 Nov 15 |
nicklas |
188 |
value="<%=HTML.encodeTags(dateFormatter.format(expirationDate))%>" |
6991 |
02 Nov 15 |
nicklas |
189 |
maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> |
6991 |
02 Nov 15 |
nicklas |
190 |
</td> |
6991 |
02 Nov 15 |
nicklas |
191 |
<td> |
6991 |
02 Nov 15 |
nicklas |
192 |
<base:calendar textarea="expiration_date" title="Expiration date" /> |
6991 |
02 Nov 15 |
nicklas |
193 |
</td> |
6991 |
02 Nov 15 |
nicklas |
194 |
</tr> |
6991 |
02 Nov 15 |
nicklas |
195 |
</table> |
6991 |
02 Nov 15 |
nicklas |
196 |
</td> |
6991 |
02 Nov 15 |
nicklas |
197 |
<td></td> |
6991 |
02 Nov 15 |
nicklas |
198 |
</tr> |
6991 |
02 Nov 15 |
nicklas |
199 |
<tr> |
6991 |
02 Nov 15 |
nicklas |
200 |
<th class="prompt"><label for="inactive">Inactive</label></th> |
6991 |
02 Nov 15 |
nicklas |
201 |
<td> |
6991 |
02 Nov 15 |
nicklas |
202 |
<input type="checkbox" name="inactive" id="inactive" value="1" <%=inactive ? "checked" : "" %>> |
6991 |
02 Nov 15 |
nicklas |
203 |
</td> |
6991 |
02 Nov 15 |
nicklas |
204 |
<td></td> |
6991 |
02 Nov 15 |
nicklas |
205 |
</tr> |
6991 |
02 Nov 15 |
nicklas |
206 |
<tr class="dynamic"> |
6991 |
02 Nov 15 |
nicklas |
207 |
<th>Description</th> |
6991 |
02 Nov 15 |
nicklas |
208 |
<td> |
6991 |
02 Nov 15 |
nicklas |
209 |
<textarea class="text" rows="6" name="description" id="description" |
6991 |
02 Nov 15 |
nicklas |
210 |
><%=HTML.encodeTags(kit == null ? cc.getPropertyValue("description") : kit.getDescription())%></textarea> |
6991 |
02 Nov 15 |
nicklas |
211 |
</td> |
6991 |
02 Nov 15 |
nicklas |
212 |
<td style="width: 20px;"> |
6991 |
02 Nov 15 |
nicklas |
213 |
<base:zoom textarea="description" title="Description" /> |
6991 |
02 Nov 15 |
nicklas |
214 |
</td> |
6991 |
02 Nov 15 |
nicklas |
215 |
</tr> |
6991 |
02 Nov 15 |
nicklas |
216 |
</table> |
6991 |
02 Nov 15 |
nicklas |
217 |
</t:tab> |
6991 |
02 Nov 15 |
nicklas |
218 |
|
6991 |
02 Nov 15 |
nicklas |
219 |
<t:tab id="annotations" title="Annotations" helpid="annotations.edit"> |
6991 |
02 Nov 15 |
nicklas |
220 |
<jsp:include page="../../common/annotations/annotate_frameset.jsp"> |
6991 |
02 Nov 15 |
nicklas |
221 |
<jsp:param name="item_type" value="<%=itemType.name()%>" /> |
6991 |
02 Nov 15 |
nicklas |
222 |
<jsp:param name="item_id" value="<%=itemId%>" /> |
6991 |
02 Nov 15 |
nicklas |
223 |
<jsp:param name="ID" value="<%=ID%>" /> |
6991 |
02 Nov 15 |
nicklas |
224 |
</jsp:include> |
6991 |
02 Nov 15 |
nicklas |
225 |
</t:tab> |
6991 |
02 Nov 15 |
nicklas |
226 |
</t:tabcontrol> |
6991 |
02 Nov 15 |
nicklas |
227 |
</form> |
6991 |
02 Nov 15 |
nicklas |
228 |
|
6991 |
02 Nov 15 |
nicklas |
229 |
<div class="legend"> |
6991 |
02 Nov 15 |
nicklas |
230 |
<base:icon image="required.png" />= required information |
6991 |
02 Nov 15 |
nicklas |
231 |
</div> |
6991 |
02 Nov 15 |
nicklas |
232 |
|
6991 |
02 Nov 15 |
nicklas |
233 |
<base:buttongroup subclass="dialogbuttons"> |
6991 |
02 Nov 15 |
nicklas |
234 |
<base:button id="btnSave" title="Save" /> |
6991 |
02 Nov 15 |
nicklas |
235 |
<base:button id="close" title="Cancel" /> |
6991 |
02 Nov 15 |
nicklas |
236 |
</base:buttongroup> |
6991 |
02 Nov 15 |
nicklas |
237 |
</base:body> |
6991 |
02 Nov 15 |
nicklas |
238 |
</base:page> |
6991 |
02 Nov 15 |
nicklas |
239 |
<% |
6991 |
02 Nov 15 |
nicklas |
240 |
} |
6991 |
02 Nov 15 |
nicklas |
241 |
finally |
6991 |
02 Nov 15 |
nicklas |
242 |
{ |
6991 |
02 Nov 15 |
nicklas |
243 |
if (dc != null) dc.close(); |
6991 |
02 Nov 15 |
nicklas |
244 |
} |
6991 |
02 Nov 15 |
nicklas |
245 |
%> |