source: trunk/www/admin/reportertypes/list_reportertypes.jsp @ 7943

Last change on this file since 7943 was 7943, checked in by Nicklas Nordborg, 23 months ago

Merged BASE 3.18.1 to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 13.1 KB
Line 
1<%-- $Id: list_reportertypes.jsp 7943 2021-05-04 12:23:19Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Johan Enell
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  @author Nicklas
24  @version 2.0
25--%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.Item"
30  import="net.sf.basedb.core.ReporterType"
31  import="net.sf.basedb.core.ItemQuery"
32  import="net.sf.basedb.core.Include"
33  import="net.sf.basedb.core.ItemResultIterator"
34  import="net.sf.basedb.core.ItemResultList"
35  import="net.sf.basedb.core.ItemContext"
36  import="net.sf.basedb.core.Permission"
37  import="net.sf.basedb.core.PluginDefinition"
38  import="net.sf.basedb.core.query.Orders"
39  import="net.sf.basedb.core.query.Hql"
40  import="net.sf.basedb.core.plugin.GuiContext"
41  import="net.sf.basedb.core.plugin.Plugin"
42  import="net.sf.basedb.util.Enumeration"
43  import="net.sf.basedb.clients.web.Base"
44  import="net.sf.basedb.clients.web.ModeInfo"
45  import="net.sf.basedb.clients.web.PermissionUtil"
46  import="net.sf.basedb.clients.web.util.HTML"
47  import="net.sf.basedb.util.Values"
48  import="net.sf.basedb.util.formatter.Formatter"
49  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
50  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
51  import="net.sf.basedb.clients.web.extensions.JspContext"
52  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
53  import="net.sf.basedb.clients.web.extensions.toolbar.ButtonAction" 
54  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
55  import="net.sf.basedb.clients.web.extensions.list.ListColumnAction"
56  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
57  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
58  import="java.util.Date"
59  import="java.util.List"
60  import="java.util.Map"
61%>
62<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
63<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
64<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
65<%!
66  private static final Item itemType = Item.REPORTERTYPE;
67  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
68%>
69<%
70final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
71final String ID = sc.getId();
72final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
73final boolean writePermission = sc.hasPermission(Permission.WRITE, itemType);
74final boolean deletePermission = sc.hasPermission(Permission.DELETE, itemType);
75final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
76
77final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
78final String callback = request.getParameter("callback");
79final String title = mode.generateTitle("reporter type", "reporter types");
80final DbControl dc = sc.newDbControl();
81ItemResultIterator<ReporterType> reporterTypes = null;
82try
83{
84  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
85
86  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
87  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
88  try
89  {
90    final ItemQuery<ReporterType> query = Base.getConfiguredQuery(dc, cc, jspContext, true, ReporterType.getQuery(), mode);
91    reporterTypes = query.iterate(dc);
92  }
93  catch (Throwable t)
94  {
95    cc.setMessage(t.getMessage());
96  }
97  int numListed = 0;
98  ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext);
99  ExtensionsInvoker<ListColumnAction<ReporterType,?>> columnsInvoker = ListColumnUtil.useExtensions(jspContext);
100  %>
101  <base:page title="<%=title==null ? "Reporter types" : title%>" type="<%=mode.getPageType()%>" id="list-page">
102  <base:head scripts="table.js,~reportertypes.js" styles="table.css,toolbar.css">
103    <ext:scripts context="<%=jspContext%>" />
104    <ext:stylesheets context="<%=jspContext%>" />
105  </base:head>
106 
107  <base:body>
108    <h1><%=title==null ? "Reporter types" : title%></h1>
109    <div class="content">
110    <tbl:table 
111      id="reporterTypes" 
112      columns="<%=cc.getSetting("columns")%>"
113      sortby="<%=cc.getSortProperty()%>" 
114      direction="<%=cc.getSortDirection()%>"
115      action="index.jsp"
116      sc="<%=sc%>"
117      item="<%=itemType%>"
118      filterrows="<%=cc.getFilterRows()%>"
119      subclass="fulltable"
120      stickyheaders="name"
121      >
122      <tbl:hidden 
123        name="mode" 
124        value="<%=mode.getName()%>" 
125      />
126      <tbl:hidden 
127        name="callback" 
128        value="<%=callback%>" 
129        skip="<%=callback == null%>" 
130      />
131      <tbl:columndef 
132        id="name"
133        property="name"
134        datatype="string"
135        title="Name"
136        sortable="true" 
137        filterable="true"
138        exportable="true"
139        show="always" 
140      />
141      <tbl:columndef 
142        id="id"
143        clazz="uniquecol"
144        property="id"
145        datatype="int"
146        title="ID"
147        sortable="true"
148        filterable="true"
149        exportable="true"
150      />
151      <tbl:columndef 
152        id="entryDate"
153        property="entryDate"
154        datatype="date"
155        title="Registered"
156        sortable="true" 
157        filterable="true"
158        exportable="true"
159        formatter="<%=dateFormatter%>"
160      />
161      <tbl:columndef 
162        id="description"
163        property="description"
164        datatype="string"
165        title="Description" 
166        sortable="true" 
167        filterable="true" 
168        exportable="true"
169      />
170      <tbl:columndef 
171        id="xt-columns" 
172        extensions="<%=columnsInvoker%>" 
173        jspcontext="<%=jspContext%>" 
174      />
175      <div class="panelgroup bg-filled-50 bottomborder">
176        <tbl:toolbar
177          subclass="bottomborder"
178          visible="<%=mode.hasToolbar()%>"
179          >
180          <tbl:button 
181            id="btnNewItem"
182            disabled="<%=!createPermission%>" 
183            image="new.png" 
184            title="New&hellip;" 
185            tooltip="<%=createPermission ? "Create new reporter type" : "You do not have permission to create reporter types"%>" 
186          />
187          <tbl:button 
188            id="btnDeleteItems"
189            disabled="<%=!deletePermission%>" 
190            image="delete.png" 
191            title="Delete" 
192            tooltip="<%=deletePermission ? "Delete the selected items" : "You do not have permission to delete reporter types" %>" 
193          />
194          <tbl:button 
195            id="btnRestoreItems"
196            disabled="<%=!writePermission%>" 
197            image="restore.png" 
198            title="Restore" 
199            tooltip="<%=writePermission ? "Restore the selected (deleted) items" : "You do not have permission to edit reporter types" %>" 
200          />
201          <tbl:button 
202            id="btnColumns"
203            image="columns.png" 
204            title="Columns&hellip;" 
205            tooltip="Show, hide and re-order columns" 
206          />
207          <tbl:button 
208            id="btnImport"
209            data-plugin-type="IMPORT"
210            image="import.png" 
211            title="Import&hellip;" 
212            tooltip="Import data" 
213            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
214          />
215          <tbl:button 
216            id="btnExport"
217            data-plugin-type="EXPORT"
218            image="export.png" 
219            title="Export&hellip;" 
220            tooltip="Export data" 
221            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
222          />
223          <tbl:button 
224            id="btnRunPlugin"
225            data-plugin-type="OTHER"
226            image="runplugin.png" 
227            title="Run plugin&hellip;" 
228            tooltip="Run a plugin" 
229            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
230          />
231          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
232            wrapper="<%=new PrefixSuffixRenderer<ButtonAction>(jspContext, "<td>", "</td>") %>"/>
233        </tbl:toolbar>
234        <tbl:panel>
235          <tbl:presetselector />
236          <tbl:navigator
237            page="<%=cc.getPage()%>" 
238            rowsperpage="<%=cc.getRowsPerPage()%>" 
239            totalrows="<%=reporterTypes == null ? 0 : reporterTypes.getTotalCount()%>" 
240            visible="<%=mode.hasNavigator()%>"
241          />
242        </tbl:panel>
243      </div>
244      <tbl:data>
245        <tbl:headers>
246          <tbl:headerrow>
247            <tbl:header clazz="row-index bg-filled-100" />
248            <tbl:columnheaders />
249          </tbl:headerrow>
250          <%
251          int numFilters = cc.getNumPropertyFilters();
252          int numRows = cc.getFilterRows();
253          for (int filterNo = 0; filterNo < numRows; filterNo++)
254          {
255            boolean lastRow = filterNo == numRows-1;
256            %>
257            <tbl:headerrow>
258              <tbl:header subclass="row-index bg-filled-100">
259                <div class="index-<%=mode.getName()%>">
260                  <div class="index"></div>
261                  <div class="check">
262                    <base:icon 
263                      subclass="link table-check"
264                      image="check_uncheck.png" 
265                      tooltip="Toggle all (use CTRL, ALT or SHIFT to check/uncheck)" 
266                      visible="<%=lastRow && mode.hasCheck()%>"
267                    />
268                  </div>
269                  <div class="icons">
270                    <base:icon
271                      subclass="link table-filter-row-action"
272                      image="add.png"
273                      tooltip="Add extra filter row"
274                      visible="<%=lastRow%>"
275                    /><base:icon
276                      subclass="link table-filter-row-action"
277                      image="remove.png"
278                      tooltip="Remove this filter row"
279                      visible="<%=numRows > 1 || numFilters > 0 %>"
280                      data-remove-row="<%=filterNo%>"
281                    />
282                  </div>
283                </div>
284              </tbl:header>
285              <tbl:propertyfilter row="<%=filterNo%>" />
286            </tbl:headerrow>
287            <%
288          }
289          %>
290          <tbl:columnsubtitles />
291        </tbl:headers>
292        <tbl:rows>
293          <%
294          if (cc.getMessage() != null)
295          {
296            %>
297            <tbl:panel subclass="bg-filled-50">
298              <div class="messagecontainer error"><%=cc.getMessage()%></div>
299            </tbl:panel>
300            <%
301            cc.setMessage(null);
302          }
303          int index = cc.getPage()*cc.getRowsPerPage();
304          int selectedItemId = cc.getId();
305          if (reporterTypes != null)
306          {           
307            while (reporterTypes.hasNext())
308            {
309              ReporterType item = reporterTypes.next();
310              int itemId = item.getId();
311              String name = HTML.encodeTags(item.getName());
312              String tooltip = mode.isSelectionMode() ? 
313                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
314             
315              index++;
316              numListed++;
317              %>
318              <tbl:row>
319                <tbl:header clazz="row-index bg-filled-100">
320                  <div class="index-<%=mode.getName()%>">
321                    <div class="index <%=index>999?"index-smaller":""%>"><%=index%></div>
322                    <div class="check">
323                      <base:input
324                        type="checkbox" 
325                        name="<%=itemId%>" 
326                        value="<%=itemId%>" 
327                        title="<%=name%>" 
328                        checked="<%=cc.getSelected().contains(itemId)%>"
329                        visible="<%=mode.hasCheck()%>"
330                      />
331                      <base:input 
332                        type="radio" 
333                        name="item_id" 
334                        value="<%=itemId%>" 
335                        title="<%=name%>" 
336                        checked="<%=selectedItemId == itemId%>"
337                        visible="<%=mode.hasRadio()%>"
338                      />
339                    </div>
340                    <div class="icons">
341                      <base:icon 
342                        image="deleted.png"
343                        id="<%="delete."+itemId %>"
344                        subclass="<%=deletePermission ? "table-delete-item" : "disabled" %>"
345                        data-item-id="<%=itemId%>"
346                        tooltip="This item has been scheduled for deletion" 
347                        visible="<%=item.isRemoved()%>"
348                      />
349                    </div>
350                  </div>
351                </tbl:header>
352                <tbl:cell column="name"><div 
353                  class="link table-item"
354                  data-item-id="<%=itemId%>"
355                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
356                  tabindex="0"
357                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
358                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
359                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
360                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
361                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
362                  <tbl:cell column="xt-columns" />
363                </tbl:xt-cells>
364              </tbl:row>
365              <%
366              }
367            }
368          if (numListed == 0)
369          {
370            %>
371            <tbl:panel subclass="bg-filled-50">
372              <div class="messagecontainer note">
373              <%=reporterTypes == null || reporterTypes.getTotalCount() == 0 ? "No reporter types were found" : "No reporter types on this page. Please select another page!" %>
374              </div>
375            </tbl:panel>
376            <%
377          }
378          %>
379        </tbl:rows>
380      </tbl:data>
381    </tbl:table>
382    </div>
383   
384    <base:buttongroup subclass="dialogbuttons">
385      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
386      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
387      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
388    </base:buttongroup>
389   
390  </base:body>
391  </base:page>
392  <%
393}
394finally
395{
396  if (reporterTypes != null) reporterTypes.close();
397  if (dc != null) dc.close();
398}
399%>
Note: See TracBrowser for help on using the repository browser.