1 | <%-- $Id: edit_project.jsp 5949 2012-02-08 14:35:29Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Häkkinen, 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 3 |
---|
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 BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | ------------------------------------------------------------------ |
---|
22 | |
---|
23 | |
---|
24 | @author Nicklas |
---|
25 | @version 2.0 |
---|
26 | --%> |
---|
27 | <%@ page pageEncoding="UTF-8" session="false" |
---|
28 | import="net.sf.basedb.core.ArrayDesign" |
---|
29 | import="net.sf.basedb.core.SessionControl" |
---|
30 | import="net.sf.basedb.core.BasicItem" |
---|
31 | import="net.sf.basedb.core.Nameable" |
---|
32 | import="net.sf.basedb.core.DbControl" |
---|
33 | import="net.sf.basedb.core.Hardware" |
---|
34 | import="net.sf.basedb.core.Item" |
---|
35 | import="net.sf.basedb.core.ItemContext" |
---|
36 | import="net.sf.basedb.core.Subtypable" |
---|
37 | import="net.sf.basedb.core.ItemSubtype" |
---|
38 | import="net.sf.basedb.core.SystemItems" |
---|
39 | import="net.sf.basedb.core.Permission" |
---|
40 | import="net.sf.basedb.core.Project" |
---|
41 | import="net.sf.basedb.core.Protocol" |
---|
42 | import="net.sf.basedb.core.Platform" |
---|
43 | import="net.sf.basedb.core.PlatformVariant" |
---|
44 | import="net.sf.basedb.core.Include" |
---|
45 | import="net.sf.basedb.core.PermissionTemplate" |
---|
46 | import="net.sf.basedb.core.User" |
---|
47 | import="net.sf.basedb.core.Group" |
---|
48 | import="net.sf.basedb.core.ItemQuery" |
---|
49 | import="net.sf.basedb.core.ItemResultList" |
---|
50 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
51 | import="net.sf.basedb.core.RawDataType" |
---|
52 | import="net.sf.basedb.core.RawDataTypes" |
---|
53 | import="net.sf.basedb.core.Software" |
---|
54 | import="net.sf.basedb.core.BaseException" |
---|
55 | import="net.sf.basedb.core.query.Orders" |
---|
56 | import="net.sf.basedb.core.query.Hql" |
---|
57 | import="net.sf.basedb.clients.web.Base" |
---|
58 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
59 | import="net.sf.basedb.clients.web.util.HTML" |
---|
60 | import="net.sf.basedb.util.Values" |
---|
61 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
62 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
63 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
64 | import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
---|
65 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
66 | import="java.util.List" |
---|
67 | import="java.util.Set" |
---|
68 | import="java.util.HashSet" |
---|
69 | import="java.util.EnumSet" |
---|
70 | %> |
---|
71 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
72 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
73 | <%! |
---|
74 | private static final int READ_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.READ)); |
---|
75 | private static final int USE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.USE)); |
---|
76 | private static final int WRITE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.WRITE)); |
---|
77 | private static final int DELETE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.DELETE)); |
---|
78 | private static final int SET_OWNER_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.SET_OWNER)); |
---|
79 | private static final int SET_PERMISSION_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.SET_PERMISSION)); |
---|
80 | |
---|
81 | private String getPermissionString(Set<Permission> permissions) |
---|
82 | { |
---|
83 | StringBuilder sb = new StringBuilder(); |
---|
84 | sb.append(permissions.contains(Permission.READ) ? "R" : "-"); |
---|
85 | sb.append(permissions.contains(Permission.USE) ? "U" : "-"); |
---|
86 | sb.append(permissions.contains(Permission.WRITE) ? "W" : "-"); |
---|
87 | sb.append(permissions.contains(Permission.DELETE) ? "D" : "-"); |
---|
88 | sb.append(permissions.contains(Permission.SET_OWNER) ? "O" : "-"); |
---|
89 | sb.append(permissions.contains(Permission.SET_PERMISSION) ? "P" : "-"); |
---|
90 | return sb.toString(); |
---|
91 | } |
---|
92 | %> |
---|
93 | <% |
---|
94 | final Item itemType = Item.PROJECT; |
---|
95 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
96 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
97 | final int itemId = cc.getId(); |
---|
98 | final String ID = sc.getId(); |
---|
99 | final float scale = Base.getScale(sc); |
---|
100 | final DbControl dc = sc.newDbControl(); |
---|
101 | try |
---|
102 | { |
---|
103 | String title = null; |
---|
104 | Project project = null; |
---|
105 | |
---|
106 | // Query to retrieve child groups |
---|
107 | ItemQuery<Group> groupQuery = null; |
---|
108 | // Query to retrieve user members |
---|
109 | ItemQuery<User> userQuery = null; |
---|
110 | |
---|
111 | RawDataType currentRawDataType = null; |
---|
112 | boolean readCurrentPermissionTemplate = true; |
---|
113 | PermissionTemplate currentPermissionTemplate = null; |
---|
114 | |
---|
115 | List<PermissionTemplate> recentPermissionTemplates = (List<PermissionTemplate>)cc.getRecent(dc, Item.PERMISSIONTEMPLATE); |
---|
116 | |
---|
117 | if (itemId == 0) |
---|
118 | { |
---|
119 | title = "Create project"; |
---|
120 | cc.removeObject("item"); |
---|
121 | currentPermissionTemplate = Base.getFirstMatching(dc, PermissionTemplate.getQuery(), "name", cc.getPropertyFilter("permissionTemplate.name")); |
---|
122 | } |
---|
123 | else |
---|
124 | { |
---|
125 | project = Project.getById(dc, itemId); |
---|
126 | project.checkPermission(Permission.WRITE); |
---|
127 | cc.setObject("item", project); |
---|
128 | title = "Edit project -- " + HTML.encodeTags(project.getName()); |
---|
129 | currentRawDataType = project.getDefaultRawDataType(); |
---|
130 | |
---|
131 | try |
---|
132 | { |
---|
133 | currentPermissionTemplate = project.getPermissionTemplate(); |
---|
134 | } |
---|
135 | catch (PermissionDeniedException ex) |
---|
136 | { |
---|
137 | readCurrentPermissionTemplate = false; |
---|
138 | } |
---|
139 | |
---|
140 | groupQuery = project.getGroups(); |
---|
141 | groupQuery.include(Include.ALL); |
---|
142 | groupQuery.order(Orders.asc(Hql.property("name"))); |
---|
143 | userQuery = project.getUsers(); |
---|
144 | userQuery.include(Include.ALL); |
---|
145 | userQuery.order(Orders.asc(Hql.property("name"))); |
---|
146 | } |
---|
147 | |
---|
148 | final String clazz = "class=\"text\""; |
---|
149 | final String requiredClazz = "class=\"text required\""; |
---|
150 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), project); |
---|
151 | ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext); |
---|
152 | %> |
---|
153 | <base:page type="popup" title="<%=title%>"> |
---|
154 | <base:head scripts="tabcontrol.js,linkitems.js,subtypes.js,ajax.js,json2.js" styles="tabcontrol.css"> |
---|
155 | <ext:scripts context="<%=jspContext%>" /> |
---|
156 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
157 | <script language="JavaScript"> |
---|
158 | // Validate the "Project" tab |
---|
159 | function validateProject() |
---|
160 | { |
---|
161 | var frm = document.forms['project']; |
---|
162 | if (Main.trimString(frm.name.value) == '') |
---|
163 | { |
---|
164 | alert("You must enter a name"); |
---|
165 | frm.name.focus(); |
---|
166 | return false; |
---|
167 | } |
---|
168 | return true; |
---|
169 | } |
---|
170 | // Validate the "Members" tab |
---|
171 | function validateMembers() |
---|
172 | { |
---|
173 | return true; |
---|
174 | } |
---|
175 | // Submit the form |
---|
176 | function saveSettings() |
---|
177 | { |
---|
178 | var frm = document.forms['project']; |
---|
179 | if (TabControl.validateActiveTab('settings')) |
---|
180 | { |
---|
181 | frm.modifiedUsers.value = Link.exportModified(frm, 'U').join(','); |
---|
182 | frm.modifiedGroups.value = Link.exportModified(frm, 'G').join(','); |
---|
183 | |
---|
184 | Forms.createHidden(frm, 'add:PLATFORM', Link.getActionIds(1, 'PLATFORM').join(',')); |
---|
185 | Forms.createHidden(frm, 'remove:PLATFORM', Link.getActionIds(-1, 'PLATFORM').join(',')); |
---|
186 | Forms.createHidden(frm, 'add:PLATFORMVARIANT', Link.getActionIds(1, 'PLATFORMVARIANT').join(',')); |
---|
187 | Forms.createHidden(frm, 'remove:PLATFORMVARIANT', Link.getActionIds(-1, 'PLATFORMVARIANT').join(',')); |
---|
188 | Forms.createHidden(frm, 'add:PROTOCOL', Link.getActionIds(1, 'PROTOCOL').join(',')); |
---|
189 | Forms.createHidden(frm, 'remove:PROTOCOL', Link.getActionIds(-1, 'PROTOCOL').join(',')); |
---|
190 | Forms.createHidden(frm, 'add:HARDWARE', Link.getActionIds(1, 'HARDWARE').join(',')); |
---|
191 | Forms.createHidden(frm, 'remove:HARDWARE', Link.getActionIds(-1, 'HARDWARE').join(',')); |
---|
192 | Forms.createHidden(frm, 'add:SOFTWARE', Link.getActionIds(1, 'SOFTWARE').join(',')); |
---|
193 | Forms.createHidden(frm, 'remove:SOFTWARE', Link.getActionIds(-1, 'SOFTWARE').join(',')); |
---|
194 | Forms.createHidden(frm, 'add:ARRAYDESIGN', Link.getActionIds(1, 'ARRAYDESIGN').join(',')); |
---|
195 | Forms.createHidden(frm, 'remove:ARRAYDESIGN', Link.getActionIds(-1, 'ARRAYDESIGN').join(',')); |
---|
196 | |
---|
197 | frm.submit(); |
---|
198 | } |
---|
199 | } |
---|
200 | |
---|
201 | function init() |
---|
202 | { |
---|
203 | var frm = document.forms['project']; |
---|
204 | <% |
---|
205 | if (project == null) |
---|
206 | { |
---|
207 | %> |
---|
208 | frm.name.focus(); |
---|
209 | frm.name.select(); |
---|
210 | <% |
---|
211 | } |
---|
212 | %> |
---|
213 | initMembers(); |
---|
214 | initDefaults(); |
---|
215 | permissionTemplateOnChange(); |
---|
216 | showPermissions(frm.autoPermissions.value, 'auto_'); |
---|
217 | } |
---|
218 | |
---|
219 | function initDefaults() |
---|
220 | { |
---|
221 | var frm = document.forms['project']; |
---|
222 | var defaultItems = frm.defaultItems; |
---|
223 | Link.addNewSection(defaultItems, new Section('PLATFORM', 'Platforms')); |
---|
224 | Link.addNewSection(defaultItems, new Section('PLATFORMVARIANT', 'Platform variants')); |
---|
225 | Link.addNewSection(defaultItems, new Section('ARRAYDESIGN', 'Array designs')); |
---|
226 | Link.addNewSection(defaultItems, new Section('PROTOCOL', 'Protocols')); |
---|
227 | Link.addNewSection(defaultItems, new Section('HARDWARE', 'Hardware')); |
---|
228 | Link.addNewSection(defaultItems, new Section('SOFTWARE', 'Software')); |
---|
229 | <% |
---|
230 | if (project != null) |
---|
231 | { |
---|
232 | for (BasicItem defaultItem : project.getDefaultItems(dc)) |
---|
233 | { |
---|
234 | String name = defaultItem instanceof Nameable ? ((Nameable)defaultItem).getName() : defaultItem.toString(); |
---|
235 | if (defaultItem instanceof Subtypable) |
---|
236 | { |
---|
237 | ItemSubtype subtype = ((Subtypable)defaultItem).getItemSubtype(); |
---|
238 | if (subtype != null) name += " (" + subtype.getName() + ")"; |
---|
239 | } |
---|
240 | %> |
---|
241 | Link.addNewItem(defaultItems, new Item('<%=defaultItem.getType().name()%>', <%=defaultItem.getId()%>, '<%=HTML.javaScriptEncode(name)%>'), true); |
---|
242 | <% |
---|
243 | } |
---|
244 | } |
---|
245 | %> |
---|
246 | } |
---|
247 | function initMembers() |
---|
248 | { |
---|
249 | var frm = document.forms['project']; |
---|
250 | var members = frm.members; |
---|
251 | Link.addNewSection(members, new Section('U', 'Users')); |
---|
252 | <% |
---|
253 | if (userQuery != null) |
---|
254 | { |
---|
255 | ItemResultList<User> users = userQuery.list(dc); |
---|
256 | for (User user : users) |
---|
257 | { |
---|
258 | Set<Permission> permissions = project.getPermissions(user); |
---|
259 | %> |
---|
260 | Link.addNewItem(members, new Item('U',<%=user.getId()%>, '<%=HTML.javaScriptEncode(user.getName())%> [<%=getPermissionString(permissions)%>]', <%=PermissionUtil.getPermissionCode(permissions)%>)); |
---|
261 | <% |
---|
262 | } |
---|
263 | } |
---|
264 | %> |
---|
265 | Link.addNewSection(members, new Section('G', 'Groups')); |
---|
266 | <% |
---|
267 | if (groupQuery != null) |
---|
268 | { |
---|
269 | ItemResultList<Group> groups = groupQuery.list(dc); |
---|
270 | for (Group group : groups) |
---|
271 | { |
---|
272 | Set<Permission> permissions = project.getPermissions(group); |
---|
273 | %> |
---|
274 | Link.addNewItem(members, new Item('G',<%=group.getId()%>, '<%=HTML.javaScriptEncode(group.getName())%> [<%=getPermissionString(permissions)%>]', <%=PermissionUtil.getPermissionCode(permissions)%>)); |
---|
275 | <% |
---|
276 | } |
---|
277 | } |
---|
278 | %> |
---|
279 | } |
---|
280 | function correctPermissions(checked, prefix) |
---|
281 | { |
---|
282 | if (!prefix) prefix = ''; |
---|
283 | var frm = document.forms['project']; |
---|
284 | if (checked) |
---|
285 | { |
---|
286 | frm[prefix+'set_permission'].checked = frm[prefix+'set_permission'].checked; |
---|
287 | frm[prefix+'set_owner'].checked = frm[prefix+'set_owner'].checked; |
---|
288 | frm[prefix+'delete'].checked = frm[prefix+'delete'].checked ; |
---|
289 | frm[prefix+'write'].checked = frm[prefix+'write'].checked || frm[prefix+'delete'].checked || frm[prefix+'set_owner'].checked || frm[prefix+'set_permission'].checked; |
---|
290 | frm[prefix+'use'].checked = frm[prefix+'use'].checked || frm[prefix+'write'].checked; |
---|
291 | frm[prefix+'read'].checked = frm[prefix+'read'].checked || frm[prefix+'use'].checked; |
---|
292 | } |
---|
293 | else |
---|
294 | { |
---|
295 | frm[prefix+'read'].checked = frm[prefix+'read'].checked; |
---|
296 | frm[prefix+'use'].checked = frm[prefix+'use'].checked && frm[prefix+'read'].checked; |
---|
297 | frm[prefix+'write'].checked = frm[prefix+'write'].checked && frm[prefix+'use'].checked; |
---|
298 | frm[prefix+'delete'].checked = frm[prefix+'delete'].checked && frm[prefix+'write'].checked; |
---|
299 | frm[prefix+'set_owner'].checked = frm[prefix+'set_owner'].checked && frm[prefix+'write'].checked; |
---|
300 | frm[prefix+'set_permission'].checked = frm[prefix+'set_permission'].checked && frm[prefix+'write'].checked; |
---|
301 | } |
---|
302 | } |
---|
303 | function getPermissionCode(prefix) |
---|
304 | { |
---|
305 | if (!prefix) prefix = ''; |
---|
306 | var permissionCode = 0; |
---|
307 | var frm = document.forms['project']; |
---|
308 | permissionCode += frm[prefix+'read'].checked ? <%=READ_CODE%>: 0; |
---|
309 | permissionCode += frm[prefix+'use'].checked ? <%=USE_CODE%>: 0; |
---|
310 | permissionCode += frm[prefix+'write'].checked ? <%=WRITE_CODE%>: 0; |
---|
311 | permissionCode += frm[prefix+'delete'].checked ? <%=DELETE_CODE%>: 0; |
---|
312 | permissionCode += frm[prefix+'set_owner'].checked ? <%=SET_OWNER_CODE%>: 0; |
---|
313 | permissionCode += frm[prefix+'set_permission'].checked ? <%=SET_PERMISSION_CODE%>: 0; |
---|
314 | return permissionCode; |
---|
315 | } |
---|
316 | function getPermissionString(permissionCode) |
---|
317 | { |
---|
318 | var s = ''; |
---|
319 | s += permissionCode & <%=READ_CODE%> ? "R" : "-"; |
---|
320 | s += permissionCode & <%=USE_CODE%> ? "U" : "-"; |
---|
321 | s += permissionCode & <%=WRITE_CODE%> ? "W" : "-"; |
---|
322 | s += permissionCode & <%=DELETE_CODE%> ? "D" : "-"; |
---|
323 | s += permissionCode & <%=SET_OWNER_CODE%> ? "O" : "-"; |
---|
324 | s += permissionCode & <%=SET_PERMISSION_CODE%> ? "P" : "-"; |
---|
325 | return s; |
---|
326 | } |
---|
327 | function showPermissions(permissionCode, prefix) |
---|
328 | { |
---|
329 | if (!prefix) prefix = ''; |
---|
330 | var frm = document.forms['project']; |
---|
331 | frm[prefix+'read'].checked = permissionCode & <%=READ_CODE%>; |
---|
332 | frm[prefix+'use'].checked = permissionCode & <%=USE_CODE%>; |
---|
333 | frm[prefix+'write'].checked = permissionCode & <%=WRITE_CODE%>; |
---|
334 | frm[prefix+'delete'].checked = permissionCode & <%=DELETE_CODE%>; |
---|
335 | frm[prefix+'set_owner'].checked = permissionCode & <%=SET_OWNER_CODE%>; |
---|
336 | frm[prefix+'set_permission'].checked = permissionCode & <%=SET_PERMISSION_CODE%>; |
---|
337 | } |
---|
338 | |
---|
339 | function permissionsOnClick(name) |
---|
340 | { |
---|
341 | var frm = document.forms['project']; |
---|
342 | var radio = frm[name]; |
---|
343 | correctPermissions(radio.checked); |
---|
344 | var permissionCode = getPermissionCode(); |
---|
345 | var permissionString = getPermissionString(permissionCode); |
---|
346 | for (var i = 0; i < frm.members.length; i++) // > |
---|
347 | { |
---|
348 | var option = frm.members[i]; |
---|
349 | if (option.selected && option.item.id) |
---|
350 | { |
---|
351 | option.item.value = permissionCode; |
---|
352 | var text = option.text.replace(/\[.*\]/, '['+permissionString+']'); |
---|
353 | option.text = text; |
---|
354 | } |
---|
355 | } |
---|
356 | } |
---|
357 | |
---|
358 | function autoPermissionsOnClick(name) |
---|
359 | { |
---|
360 | var frm = document.forms['project']; |
---|
361 | var radio = frm[name]; |
---|
362 | correctPermissions(radio.checked, 'auto_'); |
---|
363 | frm.autoPermissions.value = getPermissionCode('auto_'); |
---|
364 | } |
---|
365 | |
---|
366 | function selectPermissionTemplateOnClick() |
---|
367 | { |
---|
368 | var frm = document.forms['project']; |
---|
369 | var url = '../../views/permissiontemplates/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setPermissionTemplateCallback'; |
---|
370 | if (frm.permissiontemplate_id.length > 1) |
---|
371 | { |
---|
372 | var id = Math.abs(parseInt(frm.permissiontemplate_id[1].value)); |
---|
373 | url += '&item_id='+id; |
---|
374 | } |
---|
375 | Main.openPopup(url, 'SelectPermissionTemplate', 1050, 700); |
---|
376 | } |
---|
377 | function setPermissionTemplateCallback(id, name) |
---|
378 | { |
---|
379 | var frm = document.forms['project']; |
---|
380 | var list = frm.permissiontemplate_id; |
---|
381 | if (list.length < 2 || list[1].value == '0') // > |
---|
382 | { |
---|
383 | Forms.addListOption(list, 1, new Option()); |
---|
384 | } |
---|
385 | list[1].value = id; |
---|
386 | list[1].text = name; |
---|
387 | list.selectedIndex = 1; |
---|
388 | permissionTemplateOnChange(); |
---|
389 | } |
---|
390 | function permissionTemplateOnChange() |
---|
391 | { |
---|
392 | var frm = document.forms['project']; |
---|
393 | var hasTemplate = frm.permissiontemplate_id.selectedIndex > 0; |
---|
394 | frm.auto_read.disabled = hasTemplate; |
---|
395 | frm.auto_use.disabled = hasTemplate; |
---|
396 | frm.auto_write.disabled = hasTemplate; |
---|
397 | frm.auto_delete.disabled = hasTemplate; |
---|
398 | frm.auto_set_owner.disabled = hasTemplate; |
---|
399 | frm.auto_set_permission.disabled = hasTemplate; |
---|
400 | } |
---|
401 | function membersOnChange() |
---|
402 | { |
---|
403 | var frm = document.forms['project']; |
---|
404 | var item = frm.members[frm.members.selectedIndex].item; |
---|
405 | if (item && item.id) |
---|
406 | { |
---|
407 | showPermissions(item.value); |
---|
408 | } |
---|
409 | else |
---|
410 | { |
---|
411 | showPermissions(0); |
---|
412 | } |
---|
413 | } |
---|
414 | |
---|
415 | function addUsersOnClick() |
---|
416 | { |
---|
417 | var ids = Link.getListIds(document.forms['project'].members, 'U'); |
---|
418 | var excludes = ids.join(','); |
---|
419 | Main.openPopup('../../admin/users/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addUserCallback&permission=READ&exclude='+excludes, 'AddUsers', 1050, 700); |
---|
420 | } |
---|
421 | function addUserCallback(userId, name) |
---|
422 | { |
---|
423 | var permissionCode = getPermissionCode(); |
---|
424 | var permissionString = getPermissionString(permissionCode); |
---|
425 | var item = Link.getItem('U', userId); |
---|
426 | if (!item) item = new Item('U', userId, name+' ['+permissionString+']', permissionCode, 0); |
---|
427 | Link.addItem(document.forms['project'].members, item); |
---|
428 | } |
---|
429 | function addGroupsOnClick() |
---|
430 | { |
---|
431 | var ids = Link.getListIds(document.forms['project'].members, 'G'); |
---|
432 | <% |
---|
433 | if (!sc.hasSystemPermission(Permission.SHARE_TO_EVERYONE)) |
---|
434 | { |
---|
435 | %> |
---|
436 | ids[ids.length] = '<%=SystemItems.getId(Group.EVERYONE)%>'; |
---|
437 | <% |
---|
438 | } |
---|
439 | %> |
---|
440 | var excludes = ids.join(','); |
---|
441 | Main.openPopup('../../admin/groups/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addGroupCallback&permission=READ&exclude='+excludes, 'AddGroups', 1050, 700); |
---|
442 | } |
---|
443 | function addGroupCallback(groupId, name) |
---|
444 | { |
---|
445 | var permissionCode = getPermissionCode(); |
---|
446 | var permissionString = getPermissionString(permissionCode); |
---|
447 | var item = Link.getItem('G', groupId); |
---|
448 | if (!item) item = new Item('G', groupId, name+' ['+permissionString+']', permissionCode, 0); |
---|
449 | Link.addItem(document.forms['project'].members, item); |
---|
450 | } |
---|
451 | function removeMemberOnClick() |
---|
452 | { |
---|
453 | Link.removeSelected(document.forms['project'].members); |
---|
454 | } |
---|
455 | |
---|
456 | |
---|
457 | function addDefaultProtocolsOnClick() |
---|
458 | { |
---|
459 | var ids = Link.getListIds(document.forms['project'].defaultItems, 'PROTOCOL'); |
---|
460 | var excludes = ids.join(','); |
---|
461 | Main.openPopup('../../admin/protocols/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addDefaultProtocolCallback&exclude='+excludes, 'AddProtocols', 1050, 700); |
---|
462 | } |
---|
463 | function addDefaultProtocolCallback(protocolId, name) |
---|
464 | { |
---|
465 | var item = Link.getItem('PROTOCOL', protocolId); |
---|
466 | if (!item) |
---|
467 | { |
---|
468 | var subtype = ItemSubtype.getSubtype('PROTOCOL', protocolId); |
---|
469 | if (subtype) name += ' ('+subtype.name+')'; |
---|
470 | item = new Item('PROTOCOL', protocolId, name); |
---|
471 | } |
---|
472 | Link.addItem(document.forms['project'].defaultItems, item); |
---|
473 | } |
---|
474 | |
---|
475 | function addDefaultSoftwareOnClick() |
---|
476 | { |
---|
477 | var ids = Link.getListIds(document.forms['project'].defaultItems, 'SOFTWARE'); |
---|
478 | var excludes = ids.join(','); |
---|
479 | Main.openPopup('../../admin/software/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addDefaultSoftwareCallback&exclude='+excludes, 'AddSoftware', 1050, 700); |
---|
480 | } |
---|
481 | function addDefaultSoftwareCallback(softwareId, name) |
---|
482 | { |
---|
483 | var item = Link.getItem('SOFTWARE', softwareId); |
---|
484 | if (!item) |
---|
485 | { |
---|
486 | var subtype = ItemSubtype.getSubtype('SOFTWARE', softwareId); |
---|
487 | if (subtype) name += ' ('+subtype.name+')'; |
---|
488 | item = new Item('SOFTWARE', softwareId, name); |
---|
489 | } |
---|
490 | Link.addItem(document.forms['project'].defaultItems, item); |
---|
491 | } |
---|
492 | |
---|
493 | function addDefaultHardwareOnClick() |
---|
494 | { |
---|
495 | var ids = Link.getListIds(document.forms['project'].defaultItems, 'HARDWARE'); |
---|
496 | var excludes = ids.join(','); |
---|
497 | Main.openPopup('../../admin/hardware/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addDefaultHardwareCallback&exclude='+excludes, 'AddHardware', 1050, 700); |
---|
498 | } |
---|
499 | function addDefaultHardwareCallback(hardwareId, name) |
---|
500 | { |
---|
501 | var item = Link.getItem('HARDWARE', hardwareId); |
---|
502 | if (!item) |
---|
503 | { |
---|
504 | var subtype = ItemSubtype.getSubtype('HARDWARE', hardwareId); |
---|
505 | if (subtype) name += ' ('+subtype.name+')'; |
---|
506 | item = new Item('HARDWARE', hardwareId, name); |
---|
507 | } |
---|
508 | Link.addItem(document.forms['project'].defaultItems, item); |
---|
509 | } |
---|
510 | |
---|
511 | function addDefaultArrayDesignsOnClick() |
---|
512 | { |
---|
513 | var ids = Link.getListIds(document.forms['project'].defaultItems, 'ARRAYDESIGN'); |
---|
514 | var excludes = ids.join(','); |
---|
515 | Main.openPopup('../../lims/arraydesigns/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addDefaultArrayDesignCallback&exclude='+excludes, 'AddArrayDesign', 1050, 700); |
---|
516 | } |
---|
517 | function addDefaultArrayDesignCallback(designId, name) |
---|
518 | { |
---|
519 | var item = Link.getItem('ARRAYDESIGN', designId); |
---|
520 | if (!item) |
---|
521 | { |
---|
522 | item = new Item('ARRAYDESIGN', designId, name); |
---|
523 | } |
---|
524 | Link.addItem(document.forms['project'].defaultItems, item); |
---|
525 | } |
---|
526 | |
---|
527 | function addDefaultPlatformsOnClick() |
---|
528 | { |
---|
529 | var ids = Link.getListIds(document.forms['project'].defaultItems, 'PLATFORM'); |
---|
530 | var excludes = ids.join(','); |
---|
531 | Main.openPopup('../../admin/platforms/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addDefaultPlatformCallback&exclude='+excludes, 'AddPlatform', 1050, 700); |
---|
532 | } |
---|
533 | function addDefaultPlatformCallback(platformId, name) |
---|
534 | { |
---|
535 | var item = Link.getItem('PLATFORM', platformId); |
---|
536 | if (!item) |
---|
537 | { |
---|
538 | item = new Item('PLATFORM', platformId, name); |
---|
539 | } |
---|
540 | Link.addItem(document.forms['project'].defaultItems, item); |
---|
541 | } |
---|
542 | |
---|
543 | function addDefaultPlatformVariantsOnClick() |
---|
544 | { |
---|
545 | var frm = document.forms['project']; |
---|
546 | var selectedItem = frm.defaultItems[frm.defaultItems.selectedIndex]; |
---|
547 | var url = '../../admin/platforms/variants/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addDefaultPlatformVariantCallback'; |
---|
548 | var ids = Link.getListIds(frm.defaultItems, 'PLATFORMVARIANT'); |
---|
549 | url += '&exclude='+ids.join(','); |
---|
550 | Main.openPopup(url, 'AddPlatformVariant', 1050, 700); |
---|
551 | } |
---|
552 | function addDefaultPlatformVariantCallback(variantId, name) |
---|
553 | { |
---|
554 | var item = Link.getItem('PLATFORMVARIANT', variantId); |
---|
555 | if (!item) |
---|
556 | { |
---|
557 | item = new Item('PLATFORMVARIANT', variantId, name); |
---|
558 | } |
---|
559 | Link.addItem(document.forms['project'].defaultItems, item); |
---|
560 | } |
---|
561 | |
---|
562 | |
---|
563 | function removeDefaultItemsOnClick() |
---|
564 | { |
---|
565 | Link.removeSelected(document.forms['project'].defaultItems); |
---|
566 | } |
---|
567 | |
---|
568 | </script> |
---|
569 | </base:head> |
---|
570 | <base:body onload="init()"> |
---|
571 | <h1><%=title%> <base:help tabcontrol="settings" /></h1> |
---|
572 | |
---|
573 | <form action="index.jsp?ID=<%=ID%>" method="post" name="project" onsubmit="return false;"> |
---|
574 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
575 | <input type="hidden" name="autoPermissions" value="<%=PermissionUtil.getPermissionCode(project == null ? EnumSet.range(Permission.READ, Permission.DELETE): project.getAutoPermission())%>"> |
---|
576 | |
---|
577 | |
---|
578 | <t:tabcontrol id="settings" |
---|
579 | subclass="content dialogtabcontrol" |
---|
580 | position="bottom" remember="<%=project != null%>" |
---|
581 | extensions="<%=invoker%>"> |
---|
582 | <t:tab id="info" title="Project" validate="validateProject()" helpid="project.edit"> |
---|
583 | <table class="fullform input100"> |
---|
584 | <tr> |
---|
585 | <th>Name</th> |
---|
586 | <td><input <%=requiredClazz%> type="text" name="name" |
---|
587 | value="<%=HTML.encodeTags(project == null ? Values.getString(cc.getPropertyValue("name"), "New project") : project.getName())%>" |
---|
588 | maxlength="<%=Project.MAX_NAME_LENGTH%>"></td> |
---|
589 | <td></td> |
---|
590 | </tr> |
---|
591 | <tr class="big"> |
---|
592 | <th>Default permissions</th> |
---|
593 | <td> |
---|
594 | <base:select |
---|
595 | id="permissiontemplate_id" |
---|
596 | clazz="selectionlist" |
---|
597 | required="false" |
---|
598 | current="<%=currentPermissionTemplate%>" |
---|
599 | denied="<%=!readCurrentPermissionTemplate%>" |
---|
600 | recent="<%=recentPermissionTemplates%>" |
---|
601 | newitem="<%=project == null%>" |
---|
602 | unselectedtext="- select a template or specify below -" |
---|
603 | onselect="selectPermissionTemplateOnClick()" |
---|
604 | onchange="permissionTemplateOnChange()" |
---|
605 | /> |
---|
606 | |
---|
607 | <input type="checkbox" id="autoRead" checked name="auto_read" |
---|
608 | onClick="autoPermissionsOnClick('auto_read')"><label for="autoRead">Read</label><br> |
---|
609 | <input type="checkbox" id="autoUse" checked name="auto_use" |
---|
610 | onClick="autoPermissionsOnClick('auto_use')"><label for="autoUse">Use</label><br> |
---|
611 | <input type="checkbox" id="autoWrite" name="auto_write" |
---|
612 | onClick="autoPermissionsOnClick('auto_write')"><label for="autoWrite">Write</label><br> |
---|
613 | <input type="checkbox" id="autoDelete" name="auto_delete" |
---|
614 | onClick="autoPermissionsOnClick('auto_delete')"><label for="autoDelete">Delete</label><br> |
---|
615 | <input type="checkbox" id="autoSetOwner" name="auto_set_owner" |
---|
616 | onClick="autoPermissionsOnClick('auto_set_owner')"><label for="autoSetOwner">Set owner</label><br> |
---|
617 | <input type="checkbox" id="autoSetPermission" name="auto_set_permission" |
---|
618 | onClick="autoPermissionsOnClick('auto_set_permission')"><label for="autoSetPermission">Set permission</label><br> |
---|
619 | </td> |
---|
620 | <td></td> |
---|
621 | </tr> |
---|
622 | <tr class="dynamic"> |
---|
623 | <th>Description</th> |
---|
624 | <td> |
---|
625 | <textarea <%=clazz%> rows="4" cols="40" name="description" |
---|
626 | ><%=HTML.encodeTags(project == null ? cc.getPropertyValue("description") : project.getDescription())%></textarea> |
---|
627 | </td> |
---|
628 | <td style="width: 20px;"> |
---|
629 | <base:icon image="zoom.png" |
---|
630 | onclick="Main.zoom('Description', 'project', 'description')" |
---|
631 | tooltip="Edit in larger window" |
---|
632 | /> |
---|
633 | </td> |
---|
634 | </tr> |
---|
635 | </table> |
---|
636 | </t:tab> |
---|
637 | |
---|
638 | <t:tab id="members" title="Members" validate="validateMembers()" helpid="project.edit.members"> |
---|
639 | |
---|
640 | <table style="width: 100%;" class="filled"> |
---|
641 | <tr> |
---|
642 | <td class="padded" style="width: 50%;"><b>Members</b></td> |
---|
643 | <td class="padded" style="width: 20%;"><b>Permissions</b></td> |
---|
644 | <td></td> |
---|
645 | </tr> |
---|
646 | <tr style="vertical-align: top;"> |
---|
647 | <td style="padding-left: 5px; padding-right: 5px;"> |
---|
648 | <select name="members" size=16 multiple onChange="membersOnChange()" |
---|
649 | style="width: 100%;"> |
---|
650 | </select> |
---|
651 | <input type="hidden" name="modifiedUsers" value=""> |
---|
652 | <input type="hidden" name="modifiedGroups" value=""> |
---|
653 | </td> |
---|
654 | <td> |
---|
655 | <input type="checkbox" id="read" checked name="read" onClick="permissionsOnClick('read')"><label for="read">Read</label><br> |
---|
656 | <input type="checkbox" id="user" checked name="use" onClick="permissionsOnClick('use')"><label for="use">Use</label><br> |
---|
657 | <input type="checkbox" id="write" name="write" onClick="permissionsOnClick('write')"><label for="write">Write</label><br> |
---|
658 | <input type="checkbox" id="delete" name="delete" onClick="permissionsOnClick('delete')"><label for="delete">Delete</label><br> |
---|
659 | <input type="checkbox" id="setOwner" name="set_owner" onClick="permissionsOnClick('set_owner')"><label for="setOwner">Set owner</label><br> |
---|
660 | <input type="checkbox" id="setPermission" name="set_permission" onClick="permissionsOnClick('set_permission')"><label for="setPermission">Set permission</label><br> |
---|
661 | </td> |
---|
662 | <td> |
---|
663 | <base:buttongroup vertical="true" style="width: 12em;"> |
---|
664 | <base:button |
---|
665 | subclass="leftaligned" |
---|
666 | onclick="addUsersOnClick()" |
---|
667 | title="Add users…" |
---|
668 | tooltip="Add users to this project" |
---|
669 | /> |
---|
670 | <base:button |
---|
671 | subclass="leftaligned" |
---|
672 | onclick="addGroupsOnClick()" |
---|
673 | title="Add groups…" |
---|
674 | tooltip="Add groups to this project" |
---|
675 | /> |
---|
676 | <base:button |
---|
677 | subclass="leftaligned" |
---|
678 | onclick="removeMemberOnClick()" |
---|
679 | title="Remove" |
---|
680 | tooltip="Remove the selected members from this project" |
---|
681 | /> |
---|
682 | </base:buttongroup> |
---|
683 | </td> |
---|
684 | </tr> |
---|
685 | </table> |
---|
686 | </t:tab> |
---|
687 | |
---|
688 | <t:tab id="defaults" title="Default items" helpid="project.edit.defaults"> |
---|
689 | <table class="fullform input100"> |
---|
690 | <tr> |
---|
691 | <th>Raw data type</th> |
---|
692 | <td> |
---|
693 | <select name="rawdatatype"> |
---|
694 | <option value="">- none -</option> |
---|
695 | <% |
---|
696 | for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator())) |
---|
697 | { |
---|
698 | if (rdt.isStoredInDb()) |
---|
699 | { |
---|
700 | String selected = rdt.equals(currentRawDataType) ? "selected" : ""; |
---|
701 | %> |
---|
702 | <option value="<%=rdt.getId()%>" <%=selected%>><%=HTML.encodeTags(rdt.getName())%> |
---|
703 | <% |
---|
704 | } |
---|
705 | } |
---|
706 | %> |
---|
707 | </select> |
---|
708 | </td> |
---|
709 | <td></td> |
---|
710 | </tr> |
---|
711 | <tr class="dynamic"> |
---|
712 | <th>Default items</th> |
---|
713 | <td> |
---|
714 | <select <%=clazz%> name="defaultItems" size="16" multiple style="width: 100%;"> |
---|
715 | </select> |
---|
716 | </td> |
---|
717 | <td style="width: 13em;"> |
---|
718 | <base:buttongroup vertical="true" style="width: 12em;"> |
---|
719 | <base:button |
---|
720 | subclass="leftaligned" |
---|
721 | onclick="addDefaultPlatformsOnClick()" |
---|
722 | title="Add platforms…" |
---|
723 | tooltip="Add default platforms to this project" |
---|
724 | /> |
---|
725 | <base:button |
---|
726 | subclass="leftaligned" |
---|
727 | onclick="addDefaultPlatformVariantsOnClick()" |
---|
728 | title="Add variants…" |
---|
729 | tooltip="Add default platform variants to this project" |
---|
730 | /> |
---|
731 | <base:button |
---|
732 | subclass="leftaligned" |
---|
733 | onclick="addDefaultProtocolsOnClick()" |
---|
734 | title="Add protocols…" |
---|
735 | tooltip="Add default protocols to this project" |
---|
736 | /> |
---|
737 | <base:button |
---|
738 | subclass="leftaligned" |
---|
739 | onclick="addDefaultHardwareOnClick()" |
---|
740 | title="Add hardware…" |
---|
741 | tooltip="Add default hardware to this project" |
---|
742 | /> |
---|
743 | <base:button |
---|
744 | subclass="leftaligned" |
---|
745 | onclick="addDefaultSoftwareOnClick()" |
---|
746 | title="Add software…" |
---|
747 | tooltip="Add default software to this project" |
---|
748 | /> |
---|
749 | <base:button |
---|
750 | subclass="leftaligned" |
---|
751 | onclick="addDefaultArrayDesignsOnClick()" |
---|
752 | title="Add array designs…" |
---|
753 | tooltip="Add default array designs to this project" |
---|
754 | /> |
---|
755 | <base:button |
---|
756 | subclass="leftaligned" |
---|
757 | onclick="removeDefaultItemsOnClick()" |
---|
758 | title="Remove" |
---|
759 | tooltip="Remove the selected items from this project" |
---|
760 | /> |
---|
761 | </base:buttongroup> |
---|
762 | </td> |
---|
763 | </tr> |
---|
764 | </table> |
---|
765 | </t:tab> |
---|
766 | </t:tabcontrol> |
---|
767 | </form> |
---|
768 | |
---|
769 | <div class="legend"> |
---|
770 | <base:icon image="required.png" />= required information |
---|
771 | </div> |
---|
772 | |
---|
773 | <base:buttongroup subclass="dialogbuttons"> |
---|
774 | <base:button onclick="saveSettings()" title="Save" /> |
---|
775 | <base:button onclick="window.close()" title="Cancel" /> |
---|
776 | </base:buttongroup> |
---|
777 | </base:body> |
---|
778 | </base:page> |
---|
779 | <% |
---|
780 | } |
---|
781 | finally |
---|
782 | { |
---|
783 | if (dc != null) dc.close(); |
---|
784 | } |
---|
785 | %> |
---|