1 | <%-- $Id: edit_project.jsp 3679 2007-08-17 07:18:29Z jari $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg, Martin Svensson |
---|
5 | |
---|
6 | This file is part of BASE - BioArray Software Environment. |
---|
7 | Available at http://base.thep.lu.se/ |
---|
8 | |
---|
9 | BASE is free software; you can redistribute it and/or |
---|
10 | modify it under the terms of the GNU General Public License |
---|
11 | as published by the Free Software Foundation; either version 2 |
---|
12 | of the License, or (at your option) any later version. |
---|
13 | |
---|
14 | BASE is distributed in the hope that it will be useful, |
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with this program; if not, write to the Free Software |
---|
21 | Foundation, Inc., 59 Temple Place - Suite 330, |
---|
22 | Boston, MA 02111-1307, USA. |
---|
23 | ------------------------------------------------------------------ |
---|
24 | |
---|
25 | |
---|
26 | @author Nicklas |
---|
27 | @version 2.0 |
---|
28 | --%> |
---|
29 | <%@ page session="false" |
---|
30 | import="net.sf.basedb.core.ArrayDesign" |
---|
31 | import="net.sf.basedb.core.SessionControl" |
---|
32 | import="net.sf.basedb.core.BasicItem" |
---|
33 | import="net.sf.basedb.core.DbControl" |
---|
34 | import="net.sf.basedb.core.Hardware" |
---|
35 | import="net.sf.basedb.core.Item" |
---|
36 | import="net.sf.basedb.core.ItemContext" |
---|
37 | import="net.sf.basedb.core.SystemItems" |
---|
38 | import="net.sf.basedb.core.Permission" |
---|
39 | import="net.sf.basedb.core.Project" |
---|
40 | import="net.sf.basedb.core.Protocol" |
---|
41 | import="net.sf.basedb.core.User" |
---|
42 | import="net.sf.basedb.core.Group" |
---|
43 | import="net.sf.basedb.core.ItemQuery" |
---|
44 | import="net.sf.basedb.core.ItemResultList" |
---|
45 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
46 | import="net.sf.basedb.core.RawDataType" |
---|
47 | import="net.sf.basedb.core.RawDataTypes" |
---|
48 | import="net.sf.basedb.core.Software" |
---|
49 | import="net.sf.basedb.core.BaseException" |
---|
50 | import="net.sf.basedb.core.query.Orders" |
---|
51 | import="net.sf.basedb.core.query.Hql" |
---|
52 | import="net.sf.basedb.clients.web.Base" |
---|
53 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
54 | import="net.sf.basedb.clients.web.util.HTML" |
---|
55 | import="net.sf.basedb.util.Values" |
---|
56 | import="java.util.List" |
---|
57 | import="java.util.Set" |
---|
58 | import="java.util.HashSet" |
---|
59 | import="java.util.EnumSet" |
---|
60 | %> |
---|
61 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
62 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
63 | <%! |
---|
64 | private static final int READ_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.READ)); |
---|
65 | private static final int USE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.USE)); |
---|
66 | private static final int WRITE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.WRITE)); |
---|
67 | private static final int DELETE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.DELETE)); |
---|
68 | private static final int SET_OWNER_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.SET_OWNER)); |
---|
69 | private static final int SET_PERMISSION_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.SET_PERMISSION)); |
---|
70 | |
---|
71 | private String getPermissionString(Set<Permission> permissions) |
---|
72 | { |
---|
73 | StringBuilder sb = new StringBuilder(); |
---|
74 | sb.append(permissions.contains(Permission.READ) ? "R" : "-"); |
---|
75 | sb.append(permissions.contains(Permission.USE) ? "U" : "-"); |
---|
76 | sb.append(permissions.contains(Permission.WRITE) ? "W" : "-"); |
---|
77 | sb.append(permissions.contains(Permission.DELETE) ? "D" : "-"); |
---|
78 | sb.append(permissions.contains(Permission.SET_OWNER) ? "O" : "-"); |
---|
79 | sb.append(permissions.contains(Permission.SET_PERMISSION) ? "P" : "-"); |
---|
80 | return sb.toString(); |
---|
81 | } |
---|
82 | %> |
---|
83 | <% |
---|
84 | final Item itemType = Item.PROJECT; |
---|
85 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
86 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
87 | final int itemId = cc.getId(); |
---|
88 | final String ID = sc.getId(); |
---|
89 | final float scale = Base.getScale(sc); |
---|
90 | final DbControl dc = sc.newDbControl(); |
---|
91 | try |
---|
92 | { |
---|
93 | String title = null; |
---|
94 | Project project = null; |
---|
95 | |
---|
96 | // Query to retrieve child groups |
---|
97 | ItemQuery<Group> groupQuery = null; |
---|
98 | // Query to retrieve user members |
---|
99 | ItemQuery<User> userQuery = null; |
---|
100 | |
---|
101 | // Load recently used items |
---|
102 | List<Protocol> recentProtocol = (List<Protocol>)cc.getRecent(dc, Item.PROTOCOL); |
---|
103 | List<Software> recentSoftware = (List<Software>)cc.getRecent(dc, Item.SOFTWARE); |
---|
104 | List<Hardware> recentHardware = (List<Hardware>)cc.getRecent(dc, Item.HARDWARE); |
---|
105 | List<ArrayDesign> recentArrayDesign = (List<ArrayDesign>)cc.getRecent(dc, Item.ARRAYDESIGN); |
---|
106 | |
---|
107 | |
---|
108 | if (itemId == 0) |
---|
109 | { |
---|
110 | title = "Create project"; |
---|
111 | cc.removeObject("item"); |
---|
112 | } |
---|
113 | else |
---|
114 | { |
---|
115 | project = Project.getById(dc, itemId); |
---|
116 | cc.setObject("item", project); |
---|
117 | title = "Edit project -- " + HTML.encodeTags(project.getName()); |
---|
118 | |
---|
119 | groupQuery = project.getGroups(); |
---|
120 | groupQuery.order(Orders.asc(Hql.property("name"))); |
---|
121 | userQuery = project.getUsers(); |
---|
122 | userQuery.order(Orders.asc(Hql.property("name"))); |
---|
123 | } |
---|
124 | if (project != null && !project.hasPermission(Permission.WRITE)) |
---|
125 | { |
---|
126 | throw new PermissionDeniedException(Permission.WRITE, itemType.toString()); |
---|
127 | } |
---|
128 | final StringBuilder sb = new StringBuilder(); |
---|
129 | |
---|
130 | final String clazz = "class=\"text\""; |
---|
131 | final String requiredClazz = "class=\"text required\""; |
---|
132 | %> |
---|
133 | |
---|
134 | <base:page type="popup" title="<%=title%>"> |
---|
135 | <base:head scripts="tabcontrol.js,linkitems.js,parameters.js" styles="tabcontrol.css,parameters.css"> |
---|
136 | <script language="JavaScript"> |
---|
137 | // Validate the "Project" tab |
---|
138 | function validateProject() |
---|
139 | { |
---|
140 | var frm = document.forms['project']; |
---|
141 | if (Main.trimString(frm.name.value) == '') |
---|
142 | { |
---|
143 | alert("You must enter a name"); |
---|
144 | frm.name.focus(); |
---|
145 | return false; |
---|
146 | } |
---|
147 | return true; |
---|
148 | } |
---|
149 | // Validate the "Members" tab |
---|
150 | function validateMembers() |
---|
151 | { |
---|
152 | return true; |
---|
153 | } |
---|
154 | // Submit the form |
---|
155 | function saveSettings() |
---|
156 | { |
---|
157 | var frm = document.forms['project']; |
---|
158 | if (TabControl.validateActiveTab('settings')) |
---|
159 | { |
---|
160 | frm.modifiedUsers.value = Link.exportModified(frm, 'U').join(','); |
---|
161 | frm.modifiedGroups.value = Link.exportModified(frm, 'G').join(','); |
---|
162 | frm.submit(); |
---|
163 | } |
---|
164 | } |
---|
165 | |
---|
166 | function init() |
---|
167 | { |
---|
168 | <% |
---|
169 | if (project == null) |
---|
170 | { |
---|
171 | %> |
---|
172 | var frm = document.forms['project']; |
---|
173 | frm.name.focus(); |
---|
174 | frm.name.select(); |
---|
175 | <% |
---|
176 | } |
---|
177 | %> |
---|
178 | initMembers(); |
---|
179 | initDefaults(); |
---|
180 | } |
---|
181 | function initDefaults() |
---|
182 | { |
---|
183 | <% |
---|
184 | for (Project.Default d : Project.Default.values()) |
---|
185 | { |
---|
186 | %> |
---|
187 | var values = new Array(); |
---|
188 | <% |
---|
189 | String icon = ""; |
---|
190 | if (project != null) |
---|
191 | { |
---|
192 | if (d.getItemType() != null) |
---|
193 | { |
---|
194 | BasicItem defaultValue = project.getDefaultItem(dc, d); |
---|
195 | int valueId = 0; |
---|
196 | if (defaultValue != null) |
---|
197 | { |
---|
198 | valueId = defaultValue.getId(); |
---|
199 | icon = "notrequired_values.gif"; |
---|
200 | } |
---|
201 | else |
---|
202 | { |
---|
203 | icon = "notrequired_novalues.gif"; |
---|
204 | } |
---|
205 | %> |
---|
206 | values[values.length] = <%=valueId%>; |
---|
207 | <% |
---|
208 | } |
---|
209 | else if (d == Project.Default.RAW_DATA_TYPE) |
---|
210 | { |
---|
211 | RawDataType rdt = project.getDefaultRawDataType(); |
---|
212 | String strValueId = "0"; |
---|
213 | if (rdt != null) |
---|
214 | { |
---|
215 | strValueId = rdt.getId(); |
---|
216 | icon = "notrequired_values.gif"; |
---|
217 | } |
---|
218 | else |
---|
219 | { |
---|
220 | icon = "notrequired_novalues.gif"; |
---|
221 | } |
---|
222 | %> |
---|
223 | values[values.length] = '<%=strValueId%>'; |
---|
224 | <% |
---|
225 | } |
---|
226 | } |
---|
227 | else |
---|
228 | { |
---|
229 | icon = "notrequired_novalues.gif"; |
---|
230 | } |
---|
231 | icon = "<span class=\"icon\"><img id=\"icon_"+d.getName()+"\" src=\"../../images/"+icon+"\"></span>"; |
---|
232 | sb.append("<div class=\"param\" id=\"prompt_"+d.getName()+"\" onclick=\"defaultItemOnClick('"+d.getName()+"')\""); |
---|
233 | sb.append(" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\" title=\""+d.getShortName()+"\">"); |
---|
234 | sb.append(icon+"<span class=\"label\">"+d.getShortName()+"</span></div>\n"); |
---|
235 | %> |
---|
236 | var di = new Parameter('<%=d.getName()%>', '<%=HTML.javaScriptEncode(d.getShortName())%>', 1, false, false, values); |
---|
237 | <% |
---|
238 | } |
---|
239 | %> |
---|
240 | } |
---|
241 | function initMembers() |
---|
242 | { |
---|
243 | var frm = document.forms['project']; |
---|
244 | var members = frm.members; |
---|
245 | Link.addNewSection(members, new Section('U', 'Users')); |
---|
246 | <% |
---|
247 | if (userQuery != null) |
---|
248 | { |
---|
249 | ItemResultList<User> users = userQuery.list(dc); |
---|
250 | for (User user : users) |
---|
251 | { |
---|
252 | Set<Permission> permissions = project.getPermissions(user); |
---|
253 | %> |
---|
254 | Link.addNewItem(members, new Item('U',<%=user.getId()%>, '<%=HTML.javaScriptEncode(user.getName())%> [<%=getPermissionString(permissions)%>]', <%=PermissionUtil.getPermissionCode(permissions)%>)); |
---|
255 | <% |
---|
256 | } |
---|
257 | } |
---|
258 | %> |
---|
259 | Link.addNewSection(members, new Section('G', 'Groups')); |
---|
260 | <% |
---|
261 | if (groupQuery != null) |
---|
262 | { |
---|
263 | ItemResultList<Group> groups = groupQuery.list(dc); |
---|
264 | for (Group group : groups) |
---|
265 | { |
---|
266 | Set<Permission> permissions = project.getPermissions(group); |
---|
267 | %> |
---|
268 | Link.addNewItem(members, new Item('G',<%=group.getId()%>, '<%=HTML.javaScriptEncode(group.getName())%> [<%=getPermissionString(permissions)%>]', <%=PermissionUtil.getPermissionCode(permissions)%>)); |
---|
269 | <% |
---|
270 | } |
---|
271 | } |
---|
272 | %> |
---|
273 | } |
---|
274 | function correctPermissions(checked) |
---|
275 | { |
---|
276 | var frm = document.forms['project']; |
---|
277 | if (checked) |
---|
278 | { |
---|
279 | frm['set_permission'].checked = frm['set_permission'].checked; |
---|
280 | frm['set_owner'].checked = frm['set_owner'].checked; |
---|
281 | frm['delete'].checked = frm['delete'].checked ; |
---|
282 | frm['write'].checked = frm['write'].checked || frm['delete'].checked || frm['set_owner'].checked || frm['set_permission'].checked; |
---|
283 | frm['use'].checked = frm['use'].checked || frm['write'].checked; |
---|
284 | frm['read'].checked = frm['read'].checked || frm['use'].checked; |
---|
285 | } |
---|
286 | else |
---|
287 | { |
---|
288 | frm['read'].checked = frm['read'].checked; |
---|
289 | frm['use'].checked = frm['use'].checked && frm['read'].checked; |
---|
290 | frm['write'].checked = frm['write'].checked && frm['use'].checked; |
---|
291 | frm['delete'].checked = frm['delete'].checked && frm['write'].checked; |
---|
292 | frm['set_owner'].checked = frm['set_owner'].checked && frm['write'].checked; |
---|
293 | frm['set_permission'].checked = frm['set_permission'].checked && frm['write'].checked; |
---|
294 | } |
---|
295 | } |
---|
296 | function getPermissionCode() |
---|
297 | { |
---|
298 | var permissionCode = 0; |
---|
299 | var frm = document.forms['project']; |
---|
300 | permissionCode += frm['read'].checked ? <%=READ_CODE%>: 0; |
---|
301 | permissionCode += frm['use'].checked ? <%=USE_CODE%>: 0; |
---|
302 | permissionCode += frm['write'].checked ? <%=WRITE_CODE%>: 0; |
---|
303 | permissionCode += frm['delete'].checked ? <%=DELETE_CODE%>: 0; |
---|
304 | permissionCode += frm['set_owner'].checked ? <%=SET_OWNER_CODE%>: 0; |
---|
305 | permissionCode += frm['set_permission'].checked ? <%=SET_PERMISSION_CODE%>: 0; |
---|
306 | return permissionCode; |
---|
307 | } |
---|
308 | function getPermissionString(permissionCode) |
---|
309 | { |
---|
310 | var s = ''; |
---|
311 | s += permissionCode & <%=READ_CODE%> ? "R" : "-"; |
---|
312 | s += permissionCode & <%=USE_CODE%> ? "U" : "-"; |
---|
313 | s += permissionCode & <%=WRITE_CODE%> ? "W" : "-"; |
---|
314 | s += permissionCode & <%=DELETE_CODE%> ? "D" : "-"; |
---|
315 | s += permissionCode & <%=SET_OWNER_CODE%> ? "O" : "-"; |
---|
316 | s += permissionCode & <%=SET_PERMISSION_CODE%> ? "P" : "-"; |
---|
317 | return s; |
---|
318 | } |
---|
319 | function showPermissions(permissionCode) |
---|
320 | { |
---|
321 | var frm = document.forms['project']; |
---|
322 | frm['read'].checked = permissionCode & <%=READ_CODE%>; |
---|
323 | frm['use'].checked = permissionCode & <%=USE_CODE%>; |
---|
324 | frm['write'].checked = permissionCode & <%=WRITE_CODE%>; |
---|
325 | frm['delete'].checked = permissionCode & <%=DELETE_CODE%>; |
---|
326 | frm['set_owner'].checked = permissionCode & <%=SET_OWNER_CODE%>; |
---|
327 | frm['set_permission'].checked = permissionCode & <%=SET_PERMISSION_CODE%>; |
---|
328 | } |
---|
329 | |
---|
330 | function permissionsOnClick(name) |
---|
331 | { |
---|
332 | var frm = document.forms['project']; |
---|
333 | var radio = frm[name]; |
---|
334 | correctPermissions(radio.checked); |
---|
335 | var permissionCode = getPermissionCode(); |
---|
336 | var permissionString = getPermissionString(permissionCode); |
---|
337 | for (var i = 0; i < frm.members.length; i++) // > |
---|
338 | { |
---|
339 | var option = frm.members[i]; |
---|
340 | if (option.selected && option.item.id) |
---|
341 | { |
---|
342 | option.item.value = permissionCode; |
---|
343 | var text = option.text.replace(/\[.*\]/, '['+permissionString+']'); |
---|
344 | option.text = text; |
---|
345 | } |
---|
346 | } |
---|
347 | } |
---|
348 | |
---|
349 | function membersOnChange() |
---|
350 | { |
---|
351 | var frm = document.forms['project']; |
---|
352 | var item = frm.members[frm.members.selectedIndex].item; |
---|
353 | if (item && item.id) |
---|
354 | { |
---|
355 | showPermissions(item.value); |
---|
356 | } |
---|
357 | else |
---|
358 | { |
---|
359 | showPermissions(0); |
---|
360 | } |
---|
361 | } |
---|
362 | |
---|
363 | function addUsersOnClick() |
---|
364 | { |
---|
365 | var ids = Link.getListIds(document.forms['project'].members, 'U'); |
---|
366 | var excludes = ids.join(','); |
---|
367 | Main.openPopup('../../admin/users/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addUserCallback&permission=READ&exclude='+excludes, 'AddUsers', 1000, 700); |
---|
368 | } |
---|
369 | function addUserCallback(userId, name) |
---|
370 | { |
---|
371 | var permissionCode = getPermissionCode(); |
---|
372 | var permissionString = getPermissionString(permissionCode); |
---|
373 | var item = Link.getItem('U', userId); |
---|
374 | if (!item) item = new Item('U', userId, name+' ['+permissionString+']', permissionCode, 0); |
---|
375 | Link.addItem(document.forms['project'].members, item); |
---|
376 | } |
---|
377 | function addGroupsOnClick() |
---|
378 | { |
---|
379 | var ids = Link.getListIds(document.forms['project'].members, 'G'); |
---|
380 | <% |
---|
381 | if (!sc.hasSystemPermission(Permission.SHARE_TO_EVERYONE)) |
---|
382 | { |
---|
383 | %> |
---|
384 | ids[ids.length] = '<%=SystemItems.getId(Group.EVERYONE)%>'; |
---|
385 | <% |
---|
386 | } |
---|
387 | %> |
---|
388 | var excludes = ids.join(','); |
---|
389 | Main.openPopup('../../admin/groups/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addGroupCallback&permission=READ&exclude='+excludes, 'AddGroups', 1000, 700); |
---|
390 | } |
---|
391 | function addGroupCallback(groupId, name) |
---|
392 | { |
---|
393 | var permissionCode = getPermissionCode(); |
---|
394 | var permissionString = getPermissionString(permissionCode); |
---|
395 | var item = Link.getItem('G', groupId); |
---|
396 | if (!item) item = new Item('G', groupId, name+' ['+permissionString+']', permissionCode, 0); |
---|
397 | Link.addItem(document.forms['project'].members, item); |
---|
398 | } |
---|
399 | var oldValueDiv; |
---|
400 | function defaultItemOnClick(defaultName) |
---|
401 | { |
---|
402 | var frm = document.forms['project']; |
---|
403 | if (oldValueDiv) Main.hide(oldValueDiv); |
---|
404 | |
---|
405 | var pp = Parameters.allParameters['ID'+defaultName]; |
---|
406 | setSelectedParameter(pp, defaultName); |
---|
407 | oldValueDiv = 'value_'+pp.name+'_div'; |
---|
408 | Main.show(oldValueDiv); |
---|
409 | |
---|
410 | var valueElement = frm['value_'+pp.name]; |
---|
411 | if (valueElement.focus) valueElement.focus(); |
---|
412 | |
---|
413 | |
---|
414 | } |
---|
415 | var selectedParameter = null; |
---|
416 | var selectedParameterName = null; |
---|
417 | function getSelectedParameter() |
---|
418 | { |
---|
419 | return selectedParameter; |
---|
420 | } |
---|
421 | function setSelectedParameter(parameter, name) |
---|
422 | { |
---|
423 | if (selectedParameter != null) |
---|
424 | { |
---|
425 | Main.removeClass(document.getElementById('prompt_'+selectedParameter.name), 'selected'); |
---|
426 | } |
---|
427 | selectedParameter = parameter; |
---|
428 | selectedParameterName = name; |
---|
429 | if (selectedParameter != null) |
---|
430 | { |
---|
431 | Main.addClass(document.getElementById('prompt_'+selectedParameter.name), 'selected'); |
---|
432 | } |
---|
433 | } |
---|
434 | function updateSelectedStyle() |
---|
435 | { |
---|
436 | var pp = getSelectedParameter(); |
---|
437 | var icon = document.getElementById('icon_'+pp.name); |
---|
438 | var gif = getRoot()+'images/'; |
---|
439 | if (pp.values[0] == 0) |
---|
440 | { |
---|
441 | gif += 'notrequired_novalues.gif'; |
---|
442 | } |
---|
443 | else |
---|
444 | { |
---|
445 | gif += 'notrequired_values.gif'; |
---|
446 | } |
---|
447 | icon.src = gif; |
---|
448 | } |
---|
449 | function defaultValueOnChange(value) |
---|
450 | { |
---|
451 | var pp = getSelectedParameter(); |
---|
452 | if (value == null || value == '') |
---|
453 | { |
---|
454 | pp.removeValue(0); |
---|
455 | } |
---|
456 | else |
---|
457 | { |
---|
458 | pp.updateValue(0, value); |
---|
459 | } |
---|
460 | updateSelectedStyle(); |
---|
461 | } |
---|
462 | function selectDefaultItemOnClick(url) |
---|
463 | { |
---|
464 | var frm = document.forms['project']; |
---|
465 | var select_id = 'value_' + getSelectedParameter().name; |
---|
466 | var selectlist = frm[select_id]; |
---|
467 | if (selectlist.length > 1) |
---|
468 | { |
---|
469 | var id = Math.abs(parseInt(selectlist[1].value)); |
---|
470 | url += '&item_id='+id; |
---|
471 | } |
---|
472 | Main.openPopup(url, 'SelectDefaultItem', 1000, 700); |
---|
473 | } |
---|
474 | function setDefaultItemCallback(id, name) |
---|
475 | { |
---|
476 | var frm = document.forms['project']; |
---|
477 | var select_id = 'value_' + getSelectedParameter().name; |
---|
478 | var selectlist = frm[select_id]; |
---|
479 | if (selectlist.length < 2) |
---|
480 | { |
---|
481 | Forms.addListOption(selectlist, 1, new Option()); |
---|
482 | } |
---|
483 | selectlist[1].value = id; |
---|
484 | selectlist[1].text = name; |
---|
485 | selectlist.selectedIndex = 1; |
---|
486 | defaultValueOnChange(selectlist[1].value); |
---|
487 | } |
---|
488 | function removeOnClick() |
---|
489 | { |
---|
490 | Link.removeSelected(document.forms['project'].members); |
---|
491 | } |
---|
492 | |
---|
493 | </script> |
---|
494 | </base:head> |
---|
495 | <base:body onload="init()"> |
---|
496 | <p> |
---|
497 | <form action="index.jsp?ID=<%=ID%>" method="post" name="project" onsubmit="return false;"> |
---|
498 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
499 | |
---|
500 | <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3> |
---|
501 | <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*280)+"px;"%>" |
---|
502 | position="bottom" remember="<%=project != null%>"> |
---|
503 | <t:tab id="info" title="Project" validate="validateProject()" helpid="project.edit"> |
---|
504 | <table class="form" cellspacing=0> |
---|
505 | <tr> |
---|
506 | <td class="prompt">Name</td> |
---|
507 | <td><input <%=requiredClazz%> type="text" name="name" |
---|
508 | value="<%=HTML.encodeTags(project == null ? Values.getString(cc.getPropertyValue("name"), "New project") : project.getName())%>" |
---|
509 | size="40" maxlength="<%=Project.MAX_NAME_LENGTH%>"></td> |
---|
510 | </tr> |
---|
511 | <tr valign=top> |
---|
512 | <td class="prompt">Description</td> |
---|
513 | <td nowrap> |
---|
514 | <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual" |
---|
515 | ><%=HTML.encodeTags(project == null ? cc.getPropertyValue("description") : project.getDescription())%></textarea> |
---|
516 | <a href="javascript:Main.zoom('Description', 'project', 'description')" |
---|
517 | title="Edit in larger window"><base:icon image="zoom.gif" /></a> |
---|
518 | </td> |
---|
519 | </tr> |
---|
520 | </table> |
---|
521 | <div align=right> <i><base:icon image="required.gif" /> = required information</i></div> |
---|
522 | </t:tab> |
---|
523 | |
---|
524 | <t:tab id="members" title="Members" validate="validateMembers()" helpid="project.edit.members"> |
---|
525 | |
---|
526 | <table > |
---|
527 | <tr valign="top"> |
---|
528 | <td> |
---|
529 | <b>Members</b><br> |
---|
530 | <select <%=clazz%> name="members" size="15" multiple onChange="membersOnChange()" style="width: 15em;"> |
---|
531 | </select> |
---|
532 | <input type="hidden" name="modifiedUsers" value=""> |
---|
533 | <input type="hidden" name="modifiedGroups" value=""> |
---|
534 | </td> |
---|
535 | <td> |
---|
536 | <br> |
---|
537 | <b>Permissions</b><br> |
---|
538 | <input type="checkbox" checked name="read" onClick="permissionsOnClick('read')">Read<br> |
---|
539 | <input type="checkbox" checked name="use" onClick="permissionsOnClick('use')">Use<br> |
---|
540 | <input type="checkbox" name="write" onClick="permissionsOnClick('write')">Write<br> |
---|
541 | <input type="checkbox" name="delete" onClick="permissionsOnClick('delete')">Delete<br> |
---|
542 | <input type="checkbox" name="set_owner" onClick="permissionsOnClick('set_owner')">Take ownership<br> |
---|
543 | <input type="checkbox" name="set_permission" onClick="permissionsOnClick('set_permission')">Set permission<br> |
---|
544 | </td> |
---|
545 | <td> |
---|
546 | <br> |
---|
547 | <table width="150"> |
---|
548 | <tr><td><base:button |
---|
549 | onclick="addUsersOnClick()" |
---|
550 | title="Add users…" |
---|
551 | tooltip="Add users to this project" |
---|
552 | /></td></tr> |
---|
553 | <tr><td><base:button |
---|
554 | onclick="addGroupsOnClick()" |
---|
555 | title="Add groups…" |
---|
556 | tooltip="Add groups to this project" |
---|
557 | /></td></tr> |
---|
558 | <tr><td><base:button |
---|
559 | onclick="removeOnClick()" |
---|
560 | title="Remove" |
---|
561 | tooltip="Remove the selected items from this group" |
---|
562 | /></td></tr> |
---|
563 | </table> |
---|
564 | </td> |
---|
565 | </tr> |
---|
566 | </table> |
---|
567 | </t:tab> |
---|
568 | |
---|
569 | <t:tab id="defaults" title="Defaults" helpid="project.edit.defaults"> |
---|
570 | <table class="form" cellspacing="2" border="0" cellpadding="0" width="100%"> |
---|
571 | <tr valign="top"> |
---|
572 | <td width="40%"> |
---|
573 | <b>Project defaults</b><br> |
---|
574 | <div class="parameterlist" style="height: <%=(int)(scale*230)%>px; width:<%=(int)(scale*200)%>px; margin-top: 4px;"> |
---|
575 | <%=sb.toString()%> |
---|
576 | </div> |
---|
577 | <base:icon image="hasvalues.gif" /> = Has value |
---|
578 | </td> |
---|
579 | <td width="60%"> |
---|
580 | <br> |
---|
581 | <% |
---|
582 | for (Project.Default d : Project.Default.values()) |
---|
583 | { |
---|
584 | String inputName = "value_" + d.getName(); |
---|
585 | %> |
---|
586 | <div id="<%=inputName%>_div" style="display: none;"> |
---|
587 | <table> |
---|
588 | <tr> |
---|
589 | <td class="prompt"><%=d.getShortName()%></td> |
---|
590 | </tr> |
---|
591 | <% |
---|
592 | if (d.getItemType() != null) |
---|
593 | { |
---|
594 | String selectDefaultItemOnClick = ""; |
---|
595 | String defaultItemOnChange = ""; |
---|
596 | List recentItems = null; |
---|
597 | boolean readCurrentItem = true; |
---|
598 | BasicItem currentItem = null; |
---|
599 | try |
---|
600 | { |
---|
601 | currentItem = project != null ? project.getDefaultItem(dc, d) : null; |
---|
602 | } |
---|
603 | catch (PermissionDeniedException ex) |
---|
604 | { |
---|
605 | readCurrentItem = false; |
---|
606 | } |
---|
607 | |
---|
608 | if (d.getItemType() == Item.PROTOCOL) |
---|
609 | { |
---|
610 | int typeId = SystemItems.getId(d.getType()); |
---|
611 | String url = "'../../admin/protocols/index.jsp?ID=" + ID + |
---|
612 | "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:protocolType=" + typeId + "'"; |
---|
613 | selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; |
---|
614 | recentItems = recentProtocol; |
---|
615 | } |
---|
616 | else if (d.getItemType() == Item.HARDWARE) |
---|
617 | { |
---|
618 | int typeId = SystemItems.getId(d.getType()); |
---|
619 | String url = "'../../admin/hardware/index.jsp?ID=" + ID + |
---|
620 | "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:hardwareType=" + typeId + "'"; |
---|
621 | selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; |
---|
622 | recentItems = recentHardware; |
---|
623 | } |
---|
624 | else if (d.getItemType() == Item.SOFTWARE) |
---|
625 | { |
---|
626 | String url = "'../../admin/software/index.jsp?ID=" + ID + |
---|
627 | "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback'"; |
---|
628 | selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; |
---|
629 | recentItems = recentSoftware; |
---|
630 | } |
---|
631 | else if (d.getItemType() == Item.ARRAYDESIGN) |
---|
632 | { |
---|
633 | String url = "'../../lims/arraydesigns/index.jsp?ID=" + ID + |
---|
634 | "&mode=selectone&callback=setDefaultItemCallback'"; |
---|
635 | selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; |
---|
636 | recentItems = recentArrayDesign; |
---|
637 | } |
---|
638 | %> |
---|
639 | <tr> |
---|
640 | <td> |
---|
641 | <base:select |
---|
642 | id="<%=inputName%>" |
---|
643 | clazz="selectionlist" |
---|
644 | required="false" |
---|
645 | current="<%=currentItem%>" |
---|
646 | denied="<%=!readCurrentItem%>" |
---|
647 | recent="<%=recentItems%>" |
---|
648 | newitem="<%=project == null%>" |
---|
649 | onselect="<%=selectDefaultItemOnClick%>" |
---|
650 | onchange = 'defaultValueOnChange(this[this.selectedIndex].value)' |
---|
651 | /> |
---|
652 | </td> |
---|
653 | </tr> |
---|
654 | <% |
---|
655 | } |
---|
656 | else if (d == Project.Default.RAW_DATA_TYPE) |
---|
657 | { |
---|
658 | RawDataType currentDefaultRawDataType = project != null ? project.getDefaultRawDataType() : null; |
---|
659 | %> |
---|
660 | <tr> |
---|
661 | <td> |
---|
662 | <div id="<%=inputName%>" class="selectionlist"> |
---|
663 | <table border="0" cellspacing="0" cellpadding="0"> |
---|
664 | <tr><td> |
---|
665 | <select name="<%=inputName%>" onchange="defaultValueOnChange(this[this.selectedIndex].value)"> |
---|
666 | <option value="0">- none -</option> |
---|
667 | <% |
---|
668 | for (RawDataType rdt : RawDataTypes.getRawDataTypes()) |
---|
669 | { |
---|
670 | String selected = rdt.equals(currentDefaultRawDataType) ? "selected" : ""; |
---|
671 | %> |
---|
672 | <option value="<%=rdt.getId()%>" <%=selected%>><%=rdt.getName()%></option> |
---|
673 | <% |
---|
674 | } |
---|
675 | %> |
---|
676 | </select> |
---|
677 | </td></tr> |
---|
678 | </table> |
---|
679 | </div> |
---|
680 | </td> |
---|
681 | </tr> |
---|
682 | <% |
---|
683 | } |
---|
684 | %> |
---|
685 | </table> |
---|
686 | </div> |
---|
687 | <% |
---|
688 | } |
---|
689 | %> |
---|
690 | </td> |
---|
691 | </tr> |
---|
692 | </table> |
---|
693 | </t:tab> |
---|
694 | </t:tabcontrol> |
---|
695 | |
---|
696 | <table align="center"> |
---|
697 | <tr> |
---|
698 | <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td> |
---|
699 | <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td> |
---|
700 | </tr> |
---|
701 | </table> |
---|
702 | </form> |
---|
703 | </base:body> |
---|
704 | </base:page> |
---|
705 | <% |
---|
706 | } |
---|
707 | finally |
---|
708 | { |
---|
709 | if (dc != null) dc.close(); |
---|
710 | } |
---|
711 | %> |
---|