source: trunk/www/common/ownership/ownership.jsp @ 5907

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

References #1655: GUI improvements

New design on some more pages:

  • Impersonate
  • Switch user
  • Calendar
  • Close popup message
  • Configure columns
  • Manage lists contexts
  • View help
  • Set owner
  • Share items
  • About
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.8 KB
Line 
1<%-- $Id: ownership.jsp 5907 2011-12-13 08:36:28Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2008 Martin Svensson
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  Configure the order and visibility of columns in a table of items.
23  This page will use the TableColumn.getTableColumns(item) to retreive the
24  list of all available columns for that item type and
25  getSession().getSetting(item+".columns") to retreive a comma-separated
26  list of the current order of visible columns.
27
28  @author Martin
29  @version 2.9
30--%>
31<%@ page pageEncoding="UTF-8" session="false"
32  import="net.sf.basedb.core.DbControl"
33  import="net.sf.basedb.core.Item"
34  import="net.sf.basedb.core.ItemContext"
35  import="net.sf.basedb.core.Nameable"
36  import="net.sf.basedb.core.OwnedItem"
37  import="net.sf.basedb.core.SessionControl"
38  import="net.sf.basedb.core.User"
39  import="net.sf.basedb.clients.web.Base"
40  import="net.sf.basedb.clients.web.WebException"
41  import="net.sf.basedb.util.Values"
42  import="net.sf.basedb.clients.web.util.HTML"
43  import="java.util.Collections"
44  import="java.util.List"
45  import="java.util.Set"
46%>
47<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
48<%
49final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
50final String ID = sc.getId();
51final Item itemType = Item.valueOf(request.getParameter("item_type"));
52final String subContext = Values.getString(request.getParameter("subcontext"), "");
53final ItemContext cc = sc.getCurrentContext(itemType, subContext);
54
55final DbControl dc = sc.newDbControl();
56
57try
58{
59  Set<OwnedItem> items = (Set<OwnedItem>)cc.getObject("OwnedItems");
60  User defaultOwner = User.getById(dc, sc.getLoggedInUserId()); 
61  List<User> recentUsers = (List<User>)cc.getRecent(dc, Item.USER);
62 
63  // Headline on the web page.
64  String headLine = null;
65  if (items.size() == 1)
66  {
67    OwnedItem ownedItem = items.iterator().next();
68    if (ownedItem instanceof Nameable)
69    {
70      headLine = "Set owner of -- " + HTML.encodeTags(((Nameable)ownedItem).getName());
71    }
72    else
73    {
74      headLine = "Set owner of -- " + HTML.encodeTags(ownedItem.toString()); 
75    }   
76  }
77  else 
78  {
79    headLine = "Set owner of -- Multiple items ("+items.size()+")";
80  }
81     
82  %>
83  <base:page type="popup" title="Set owner">
84  <base:head scripts="" >
85    <script language="JavaScript">
86    function saveSettings()
87    {
88      var frm = document.forms['ownership'];
89      frm.submit();
90    }
91    function selectOwnerOnClick()
92    {
93      var frm = document.forms['ownership'];
94      var url = '../../admin/users/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setOwnerCallback';
95      if (frm.owner_id.length > 1)
96      {
97        var id = Math.abs(parseInt(frm.owner_id[1].value));       
98        url += '&item_id='+id;
99      }
100      Main.openPopup(url, 'SelectOwner', 1000, 700);
101    }
102    function setOwnerCallback(id, name)
103    {
104      var frm = document.forms['ownership'];
105      var list = frm.owner_id;
106      if (list.length < 2 || list[1].value == '0') // >
107      {
108        Forms.addListOption(list, 1, new Option());
109      }
110      list[1].value = id;
111      list[1].text = name;
112      list.selectedIndex = 1;
113    }
114    </script>
115  </base:head>
116  <base:body onload="">
117    <h1><%=headLine%> <base:help helpid="ownership.configure" /></h1>
118    <form name="ownership" action="submit_ownership.jsp" onsubmit="return false;">
119      <input type="hidden" name="ID" value="<%=ID%>">
120      <input type="hidden" name="cmd" value="Save">
121      <input type="hidden" name="item_type" value="<%=itemType.name()%>">
122      <input type="hidden" name="subcontext" value="<%=subContext%>">
123     
124      <div class="content" >
125        <table class="fullform input100 bottomborder smaller">
126          <tr>
127            <th>New owner</th>
128            <td>
129              <base:select 
130                id="owner_id"
131                clazz="selectionlist"
132                required="true"
133                current="<%=defaultOwner%>"
134                recent="<%=recentUsers%>"
135                newitem="true"
136                onselect="selectOwnerOnClick()"
137              />
138            </td>
139          </tr>
140          <tr class="dynamic">
141            <th></th>
142            <td></td>
143          </tr>
144        </table>
145      </div>     
146    </form>
147   
148    <base:buttongroup subclass="dialogbuttons">
149      <base:button onclick="saveSettings();" title="Ok" />
150      <base:button onclick="window.close();" title="Cancel" />
151    </base:buttongroup>
152  </base:body>
153  </base:page>
154  <%
155}
156finally
157{
158  if (dc != null) dc.close();
159}
160%>
Note: See TracBrowser for help on using the repository browser.