source: branches/3.16-stable/www/views/itemlists/add_items.jsp @ 7801

Last change on this file since 7801 was 7801, checked in by Nicklas Nordborg, 2 years ago

References #2209: Add items to existing item list from list page

Implemented a popup dialog for selecting an item list and which items to add from the current list. As usual there are three options: selected items, current page, or all items.

A button and supporting functionality for using the new feature has been added to the Biosource list page.

File size: 4.8 KB
Line 
1<%-- $Id$
2  ------------------------------------------------------------------
3  Copyright (C) 2015 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  @author Nicklas
23--%>
24<%@ page pageEncoding="UTF-8" session="false"
25  import="net.sf.basedb.core.SessionControl"
26  import="net.sf.basedb.core.DbControl"
27  import="net.sf.basedb.core.Item"
28  import="net.sf.basedb.core.ItemContext"
29  import="net.sf.basedb.core.Permission"
30  import="net.sf.basedb.core.ItemList"
31  import="net.sf.basedb.core.ItemQuery"
32  import="net.sf.basedb.core.RawDataType"
33  import="net.sf.basedb.core.RawDataTypes"
34  import="net.sf.basedb.core.query.Orders"
35  import="net.sf.basedb.core.query.Hql"
36  import="net.sf.basedb.core.query.Expressions"
37  import="net.sf.basedb.core.query.Restrictions"
38  import="net.sf.basedb.clients.web.Base"
39  import="net.sf.basedb.clients.web.util.HTML"
40  import="net.sf.basedb.util.Values"
41  import="java.util.List"
42%>
43<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
44<%
45final Item itemType = Item.ITEMLIST;
46final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
47final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
48final String ID = sc.getId();
49final float scale = Base.getScale(sc);
50final DbControl dc = sc.newDbControl();
51try
52{
53  Item memberType = Item.valueOf(request.getParameter("memberType"));
54  String formId = Values.getStringOrNull(request.getParameter("formId"));
55  String subContext = Values.getString(request.getParameter("subContext"), "");
56 
57  ItemContext memberContext = sc.getCurrentContext(memberType, subContext);
58  boolean hasSourceFilter = memberContext.getNumPropertyFilters() > 0;
59  ItemList recentlyUsed = memberContext.getRecent(dc, Item.ITEMLIST, "AddMembers", 0);
60 
61  ItemQuery<ItemList> query = ItemList.getQuery();
62  query.restrict(Restrictions.eq(
63      Hql.property("memberType"), 
64      Expressions.integer(memberType.getValue())
65    ));
66  query.restrict(Restrictions.eq(Hql.property("disableManualMembers"), Expressions.bool(false)));
67  query.setItemPermission(Permission.USE);
68  query.order(Orders.asc(Hql.property("name")));
69  List<ItemList> itemLists = query.list(dc);
70  %>
71  <base:page type="popup" title="Add items to existing list">
72  <base:head scripts="~add_items.js">
73  </base:head>
74  <base:body>
75    <h1>Add items to existing list</h1>
76    <form action="index.jsp?ID=<%=ID%>" method="post" name="additems">
77    <input type="hidden" name="cmd" value="AddMembers">
78    <%
79    if (subContext != null)
80    {
81      %>
82      <input type="hidden" name="subContext" value="<%=subContext%>">
83      <%
84    }
85    %>
86    <div class="content bottomborder">
87      <table class="fullform input100">
88      <tr>
89        <th>Which list?</th>
90        <td>
91          <select name="item_id" class="required selectionlist">
92          <%
93          for (ItemList list : itemLists)
94          {
95            String selected = list.equals(recentlyUsed) ? "selected" : "";
96            %>
97            <option value="<%=list.getId()%>" <%=selected%>><%=HTML.encodeTags(list.getName()) %> (<%=list.getSize()%> members)
98            <%
99          }
100          %>
101          </select>
102        </td>
103        <td></td>
104      </tr>
105      <tr class="big">
106        <th>Which items?</th>
107        <td>
108          <input type="radio" name="source" id="sourceSelected" value="selected"
109            data-parent-form="<%=formId%>"
110            ><label for="sourceSelected" id="lblSelected">Selected items</label><br>
111          <input type="radio" name="source" id="sourcePage" value="page"
112            ><label for="sourcePage">Current page</label><br>
113          <input type="radio" name="source" id="sourceAll" value="all" checked
114            ><label for="sourceAll">All pages</label><br>
115          <%
116          if (itemLists.size() == 0)
117          {
118            %>
119            <div class="messagecontainer error">
120            Could not find any item lists.
121            </div>
122            <%
123          }
124          %>
125        </td>
126        <td></td>
127      </tr>
128      </table>
129    </div>
130    </form>
131
132    <base:buttongroup subclass="dialogbuttons">
133      <base:button id="btnAdd" title="Add" />
134      <base:button id="close" title="Cancel" />
135    </base:buttongroup>
136  </base:body>
137  </base:page>
138  <%
139}
140finally
141{
142  if (dc != null) dc.close();
143}
144%>
Note: See TracBrowser for help on using the repository browser.