source: trunk/www/my_base/projects/edit_project.jsp @ 5908

Last change on this file since 5908 was 5908, checked in by Nicklas Nordborg, 10 years ago

References #1655: GUI improvements

  • File manager dialogs
  • File server edit dialog
  • Changed zoom.gif to png
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 29.0 KB
Line 
1<%-- $Id: edit_project.jsp 5908 2011-12-13 13:48:46Z 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<%!
74private static final int READ_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.READ));
75private static final int USE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.USE));
76private static final int WRITE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.WRITE));
77private static final int DELETE_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.DELETE));
78private static final int SET_OWNER_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.SET_OWNER));
79private static final int SET_PERMISSION_CODE = PermissionUtil.getPermissionCode(EnumSet.of(Permission.SET_PERMISSION));
80
81private 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<%
94final Item itemType = Item.PROJECT;
95final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
96final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
97final int itemId = cc.getId();
98final String ID = sc.getId();
99final float scale = Base.getScale(sc);
100final DbControl dc = sc.newDbControl();
101try
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', 1000, 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', 1000, 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', 1000, 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', 1000, 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', 1000, 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', 1000, 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', 1000, 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', 1000, 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', 1000, 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    <p>
572    <form action="index.jsp?ID=<%=ID%>" method="post" name="project" onsubmit="return false;">
573    <input type="hidden" name="cmd" value="UpdateItem">
574    <input type="hidden" name="autoPermissions" value="<%=PermissionUtil.getPermissionCode(project == null ? EnumSet.range(Permission.READ, Permission.DELETE): project.getAutoPermission())%>">
575
576    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
577    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*360)+"px;"%>" 
578      position="bottom" remember="<%=project != null%>"
579      extensions="<%=invoker%>">
580    <t:tab id="info" title="Project" validate="validateProject()" helpid="project.edit">
581      <table class="form" cellspacing=0>
582      <tr>
583        <td class="prompt">Name</td>
584        <td><input <%=requiredClazz%> type="text" name="name" 
585          value="<%=HTML.encodeTags(project == null ? Values.getString(cc.getPropertyValue("name"), "New project") : project.getName())%>" 
586          size="40" maxlength="<%=Project.MAX_NAME_LENGTH%>"></td>
587      </tr>
588      <tr>
589        <td class="prompt">Default permissions</td>
590        <td>
591          <base:select 
592            id="permissiontemplate_id"
593            clazz="selectionlist"
594            required="false"
595            current="<%=currentPermissionTemplate%>"
596            denied="<%=!readCurrentPermissionTemplate%>"
597            recent="<%=recentPermissionTemplates%>"
598            newitem="<%=project == null%>"
599            unselectedtext="- select a template or specify below -"
600            onselect="selectPermissionTemplateOnClick()"
601            onchange="permissionTemplateOnChange()"
602          />
603       
604          <input type="checkbox" id="autoRead" checked name="auto_read" 
605            onClick="autoPermissionsOnClick('auto_read')"><label for="autoRead">Read</label><br>
606          <input type="checkbox" id="autoUse" checked name="auto_use" 
607            onClick="autoPermissionsOnClick('auto_use')"><label for="autoUse">Use</label><br>
608          <input type="checkbox" id="autoWrite" name="auto_write" 
609            onClick="autoPermissionsOnClick('auto_write')"><label for="autoWrite">Write</label><br>
610          <input type="checkbox" id="autoDelete" name="auto_delete" 
611            onClick="autoPermissionsOnClick('auto_delete')"><label for="autoDelete">Delete</label><br>
612          <input type="checkbox" id="autoSetOwner" name="auto_set_owner" 
613            onClick="autoPermissionsOnClick('auto_set_owner')"><label for="autoSetOwner">Set owner</label><br>
614          <input type="checkbox" id="autoSetPermission" name="auto_set_permission" 
615            onClick="autoPermissionsOnClick('auto_set_permission')"><label for="autoSetPermission">Set permission</label><br>
616        </td>
617      </tr>
618      <tr >
619        <td class="prompt">Description</td>
620        <td nowrap>
621          <textarea <%=clazz%> rows="4" cols="40" name="description" 
622            ><%=HTML.encodeTags(project == null ? cc.getPropertyValue("description") : project.getDescription())%></textarea>
623          <a href="javascript:Main.zoom('Description', 'project', 'description')"
624            title="Edit in larger window"><base:icon image="zoom.png" /></a>
625        </td>
626      </tr>
627      </table>
628      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
629    </t:tab>
630
631    <t:tab id="members" title="Members" validate="validateMembers()" helpid="project.edit.members">
632
633    <table >
634    <tr >
635    <td>
636      <b>Members</b><br>
637      <select <%=clazz%> name="members" size="15" multiple onChange="membersOnChange()" 
638        style="width: 22em;">
639      </select>
640      <input type="hidden" name="modifiedUsers" value="">
641      <input type="hidden" name="modifiedGroups" value="">
642    </td>
643    <td>
644      <br>
645      <b>Permissions</b><br>
646      <input type="checkbox" id="read" checked name="read" onClick="permissionsOnClick('read')"><label for="read">Read</label><br>
647      <input type="checkbox" id="user" checked name="use" onClick="permissionsOnClick('use')"><label for="use">Use</label><br>
648      <input type="checkbox" id="write" name="write" onClick="permissionsOnClick('write')"><label for="write">Write</label><br>
649      <input type="checkbox" id="delete" name="delete" onClick="permissionsOnClick('delete')"><label for="delete">Delete</label><br>
650      <input type="checkbox" id="setOwner" name="set_owner" onClick="permissionsOnClick('set_owner')"><label for="setOwner">Set owner</label><br>
651      <input type="checkbox" id="setPermission" name="set_permission" onClick="permissionsOnClick('set_permission')"><label for="setPermission">Set permission</label><br>
652    </td>
653    <td>
654      <br>
655      <table width="150">
656      <tr><td><base:button 
657        clazz="leftaligned buttonclass"
658        onclick="addUsersOnClick()" 
659        title="Add&nbsp;users&hellip;" 
660        tooltip="Add users to this project"
661        /></td></tr>
662      <tr><td><base:button 
663        clazz="leftaligned buttonclass"
664        onclick="addGroupsOnClick()" 
665        title="Add&nbsp;groups&hellip;" 
666        tooltip="Add groups to this project"
667      /></td></tr>
668      <tr><td><base:button 
669        clazz="leftaligned buttonclass"
670        onclick="removeMemberOnClick()" 
671        title="Remove" 
672        tooltip="Remove the selected members from this project"
673      /></td></tr>
674      </table>
675    </td>
676    </tr>
677    </table>
678    </t:tab>
679   
680    <t:tab id="defaults" title="Default items"  helpid="project.edit.defaults">
681      <table class="form" cellspacing="2" border="0" cellpadding="0">
682      <tr>
683        <td class="prompt">Raw data type</td>
684        <td>
685          <select name="rawdatatype">
686          <option value="">- none -</option>
687          <%
688          for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator()))
689          {
690            if (rdt.isStoredInDb())
691            {
692              String selected = rdt.equals(currentRawDataType) ? "selected" : "";
693              %>
694              <option value="<%=rdt.getId()%>" <%=selected%>><%=HTML.encodeTags(rdt.getName())%>
695              <%
696            }
697          }
698          %>
699          </select>
700        </td>
701      </tr>
702      </table>
703
704      <table class="form" cellspacing="2" border="0" cellpadding="0" width="100%">       
705        <tr >
706          <td>
707            <b>Default items</b><br>
708            <select <%=clazz%> name="defaultItems" size="20" multiple style="width: 100%;">
709            </select>
710          </td>
711          <td>
712            <br>
713            <table width="200">
714            <tr><td><base:button 
715              clazz="leftaligned buttonclass"
716              onclick="addDefaultPlatformsOnClick()" 
717              title="Add&nbsp;platforms&hellip;" 
718              tooltip="Add default platforms to this project"
719              /></td></tr>
720            <tr><td><base:button 
721              clazz="leftaligned buttonclass"
722              onclick="addDefaultPlatformVariantsOnClick()" 
723              title="Add&nbsp;variants&hellip;" 
724              tooltip="Add default platform variants to this project"
725              /></td></tr>
726            <tr><td><base:button 
727              clazz="leftaligned buttonclass"
728              onclick="addDefaultProtocolsOnClick()" 
729              title="Add&nbsp;protocols&hellip;" 
730              tooltip="Add default protocols to this project"
731              /></td></tr>
732            <tr><td><base:button 
733              clazz="leftaligned buttonclass"
734              onclick="addDefaultHardwareOnClick()" 
735              title="Add&nbsp;hardware&hellip;" 
736              tooltip="Add default hardware to this project"
737            /></td></tr>
738            <tr><td><base:button 
739              clazz="leftaligned buttonclass"
740              onclick="addDefaultSoftwareOnClick()" 
741              title="Add&nbsp;software&hellip;" 
742              tooltip="Add default software to this project"
743            /></td></tr>
744            <tr><td><base:button 
745              clazz="leftaligned buttonclass"
746              onclick="addDefaultArrayDesignsOnClick()" 
747              title="Add&nbsp;array&nbsp;designs&hellip;" 
748              tooltip="Add default array designs to this project"
749            /></td></tr>
750            <tr><td><base:button 
751              clazz="leftaligned buttonclass"
752              onclick="removeDefaultItemsOnClick()" 
753              title="Remove" 
754              tooltip="Remove the selected items from this project"
755            /></td></tr>
756            </table>
757          </td>
758        </tr>
759      </table>
760    </t:tab>
761    </t:tabcontrol>
762
763    <table align="center">
764    <tr>
765      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
766      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
767    </tr>
768    </table>
769    </form>
770  </base:body>
771  </base:page>
772  <%
773}
774finally
775{
776  if (dc != null) dc.close();
777}
778%>
Note: See TracBrowser for help on using the repository browser.