source: trunk/www/common/columns/add_linkeditem_column.jsp @ 7874

Last change on this file since 7874 was 7874, checked in by Nicklas Nordborg, 11 months ago

Merged pre-3.17-changes to the trunk.

File size: 4.9 KB
Line 
1<%-- $Id: save_preset.jsp 6607 2014-11-19 14:52:20Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2020 Nicklas Nordborg
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--%>
23<%@ page pageEncoding="UTF-8" session="false"
24  import="net.sf.basedb.core.AnyToAny"
25  import="net.sf.basedb.core.DbControl"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.Item"
28  import="net.sf.basedb.core.ItemQuery"
29  import="net.sf.basedb.core.ItemContext"
30  import="net.sf.basedb.core.Metadata"
31  import="net.sf.basedb.util.AnyToAnyLinkStatistics"
32  import="net.sf.basedb.clients.web.Base"
33  import="net.sf.basedb.clients.web.util.HTML"
34  import="net.sf.basedb.util.Values"
35  import="java.util.Arrays"
36  import="java.util.List"
37%>
38<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
39<%
40final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
41final String ID = sc.getId();
42final Item itemType = Item.valueOf(request.getParameter("item_type"));
43final String subContext = Values.getString(request.getParameter("subcontext"), "");
44final ItemContext cc = Base.getAndSetCurrentContext(sc, Item.ANYTOANY, null, null);
45final DbControl dc = sc.newDbControl();
46try
47{
48  ItemQuery<?> statQuery = itemType.getQuery();
49  ItemContext ccList = Base.getAndSetCurrentContext(sc, itemType, subContext, null, null);
50  ccList.configureQuery(dc, statQuery, true);
51  statQuery.setMaxResults(-1);
52  statQuery.setFirstResult(0);
53  final List<AnyToAnyLinkStatistics> stats = AnyToAny.getExistingLinkStatistics(dc, statQuery, new AnyToAnyLinkStatistics.Options());
54  %>
55  <base:page type="popup" title="Add linked item column">
56  <base:head scripts="~add_linkeditem_column.js" />
57  <base:body>
58    <h1>Add linked item column <base:help helpid="columns.configure.add_linkeditem_column" /></h1>
59 
60    <form name="linkedItems" method="post">
61    <input type="hidden" name="ID" value="<%=ID%>">
62    <input type="hidden" name="item_type" value="<%=itemType.name()%>">
63   
64    <div class="content">
65      <table class="fullform input100 bottomborder">
66      <%
67      if (stats.size() > 0)
68      {
69        %>
70        <tr>
71          <th></th>
72          <td>
73            <select name="presets" id="presets" style="width: 25em;">
74            <option value="">- presets -
75            <%
76            for (AnyToAnyLinkStatistics stat : stats)
77            {
78              String name = HTML.encodeTags(stat.getLinkName());
79              String targetType = stat.getTargetType().name();
80              %>
81              <option data-linkname="<%=name%>" data-targettype="<%=targetType%>"><%=name%> [<%=targetType%>]
82              <%
83            }
84            %>
85            </select>
86          </td>
87        </tr>
88        <%
89      }
90      %>
91      <tr>
92        <th style="border-top-width: 0;">Link name</th>
93        <td>
94          <input class="text required auto-init" data-auto-init="focus" 
95            type="text" name="linkName" id="linkName" style="width: 25em;">
96        </td>
97      </tr>
98      <tr>
99        <th>Target item type</th>
100        <td>
101          <select name="targetItemType" id="targetItemType" style="min-width: 25em;">
102          <option value="">- any -
103          <%
104          List<String> recentTypes = cc.getRecent("toTypes");
105          if (recentTypes.size() == 0)
106          {
107            recentTypes = Arrays.asList("FILE");
108          }
109          %>
110          <option value="0" disabled class="recentheader">- recently used -
111          <%
112          for (String r : recentTypes)
113          {
114            %>
115            <option value="<%=r%>"><%=r%>
116            <%
117          }
118          %>
119          <option value="0" disabled class="recentheader">- all -
120          <%
121          for (Item targetItem : Metadata.getNameableItems())
122          {
123            if (targetItem.getDefinedPermissions() != null)
124            {
125              %>
126              <option value="<%=targetItem.name() %>"><%=targetItem.name() %>
127              <%
128            }
129          }
130          %>
131          </select>
132        </td>
133      </tr>
134      <tr class="dynamic">
135        <th></th>
136        <td><div id="added-column-msg" class="messagecontainer note" style="display:none; margin: 0.5em 0;"></div></td>
137      </tr>
138      </table>
139    </div>
140    </form>
141 
142    <base:buttongroup subclass="dialogbuttons">
143      <base:button id="btnAdd" title="Add" />
144      <base:button id="close" title="Close" />
145    </base:buttongroup>
146 
147  </base:body>
148  </base:page>
149  <%
150}
151finally
152{
153  if (dc != null) dc.close();
154}
155%>
156
157
Note: See TracBrowser for help on using the repository browser.