source: trunk/www/views/reporterlists/list_reporterlists.jsp @ 6699

Last change on this file since 6699 was 6699, checked in by Nicklas Nordborg, 9 years ago

References #1912: Add more filter rows in list pages

Fixes a problem with using non-unique id for the 'Add filter row' icon when used on pages that has multiple lists. This caused the icon to not work or add rows to the incorrect list.

The add/remove icons are now based on class names instead which means we can target each icon within the table context it is defined in.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 15.4 KB
Line 
1<%-- $Id: list_reporterlists.jsp 6699 2015-01-30 10:32:48Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Johan Enell, 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  @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.ReporterList"
31  import="net.sf.basedb.core.ItemQuery"
32  import="net.sf.basedb.core.ItemResultIterator"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.Nameable"
35  import="net.sf.basedb.core.Permission"
36  import="net.sf.basedb.core.RawDataTypes"
37  import="net.sf.basedb.core.RawDataType"
38  import="net.sf.basedb.core.PluginDefinition"
39  import="net.sf.basedb.core.plugin.GuiContext"
40  import="net.sf.basedb.core.plugin.Plugin"
41  import="net.sf.basedb.util.Enumeration"
42  import="net.sf.basedb.util.ShareableUtil"
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.ToolbarUtil"
54  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
55  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
56  import="java.util.Date"
57  import="java.util.Iterator"
58  import="java.util.List"
59  import="java.util.Map"
60%>
61<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
62<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
63<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
64<%!
65  private static final Item itemType = Item.REPORTERLIST;
66  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
67%>
68<%
69final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
70final String ID = sc.getId();
71final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
72final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
73
74final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
75final String callback = request.getParameter("callback");
76final String title = mode.generateTitle("reporter list", "reporter lists");
77final DbControl dc = sc.newDbControl();
78ItemResultIterator<ReporterList> reporterLists = null;
79try
80{
81  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
82  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
83  try
84  {
85    final ItemQuery<ReporterList> query = Base.getConfiguredQuery(dc, cc, true, ReporterList.getQuery(), mode);
86    reporterLists = query.iterate(dc);
87  }
88  catch (Throwable t)
89  {
90    cc.setMessage(t.getMessage());
91  }
92  int numListed = 0;
93  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
94  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
95  ExtensionsInvoker columnsInvoker = ListColumnUtil.useExtensions(jspContext);
96  %>
97  <base:page title="<%=title==null ? "Reporter lists" : title%>" type="<%=mode.getPageType()%>" id="list-page">
98  <base:head scripts="table.js,~reporterlists.js" styles="table.css,toolbar.css">
99    <ext:scripts context="<%=jspContext%>" />
100    <ext:stylesheets context="<%=jspContext%>" />
101  </base:head>
102 
103  <base:body>
104    <h1><%=title==null ? "Reporter lists" : title%></h1>
105    <div class="content">
106    <tbl:table 
107      id="reporterLists" 
108      columns="<%=cc.getSetting("columns")%>"
109      sortby="<%=cc.getSortProperty()%>" 
110      direction="<%=cc.getSortDirection()%>"
111      action="index.jsp"
112      sc="<%=sc%>"
113      item="<%=itemType%>"
114      filterrows="<%=cc.getFilterRows()%>"
115      subclass="fulltable"
116      >
117      <tbl:hidden 
118        name="mode" 
119        value="<%=mode.getName()%>" 
120      />
121      <tbl:hidden 
122        name="callback" 
123        value="<%=callback%>" 
124        skip="<%=callback == null%>" 
125      />
126      <tbl:columndef 
127        id="name"
128        property="name"
129        datatype="string"
130        title="Name"
131        sortable="true" 
132        filterable="true"
133        exportable="true"
134        show="always" 
135      />
136      <tbl:columndef 
137        id="id"
138        clazz="uniquecol"
139        property="id"
140        datatype="int"
141        title="ID"
142        sortable="true"
143        filterable="true"
144        exportable="true"
145      />
146      <tbl:columndef 
147        id="entryDate"
148        property="entryDate"
149        datatype="date"
150        title="Registered"
151        sortable="true" 
152        filterable="true"
153        exportable="true"
154        formatter="<%=dateFormatter%>"
155      />
156      <tbl:columndef 
157        id="externalId"
158        property="externalId"
159        datatype="string"
160        title="External ID"
161        sortable="true" 
162        filterable="true"
163        exportable="true"
164      />
165      <tbl:columndef 
166        id="numReporters"
167        property="size"
168        datatype="int"
169        title="Size"
170        sortable="true" 
171        filterable="true"
172        exportable="true"
173      />
174      <tbl:columndef 
175        id="owner"
176        property="owner.name"
177        datatype="string"
178        title="Owner"
179        sortable="true" 
180        filterable="true"
181        exportable="true"
182      />
183      <tbl:columndef 
184        id="experiment"
185        property="experiment"
186        datatype="string"
187        title="Experiment"
188        sortable="true" 
189        filterable="true"
190        exportable="true"
191      />
192      <tbl:columndef 
193        id="description"
194        property="description"
195        datatype="string"
196        title="Description" 
197        sortable="true" 
198        filterable="true" 
199        exportable="true"
200      />
201      <tbl:columndef
202        id="permission"
203        title="Permission"
204      />
205      <tbl:columndef
206        id="sharedTo"
207        title="Shared to"
208        filterable="true"
209        filterproperty="!sharedTo.name"
210        datatype="string"
211      />
212      <tbl:columndef 
213        id="xt-columns" 
214        extensions="<%=columnsInvoker%>" 
215        jspcontext="<%=jspContext%>" 
216      />
217      <div class="panelgroup bg-filled-50 bottomborder">
218        <tbl:toolbar
219          subclass="bottomborder"
220          visible="<%=mode.hasToolbar()%>"
221          >
222          <tbl:button 
223            id="btnNewItem"
224            disabled="<%=!createPermission%>" 
225            image="new.png" 
226            title="New&hellip;" 
227            tooltip="<%=createPermission ? "Create new reporter list" : "You do not have permission to create reporter lists"%>" 
228          />
229          <tbl:button 
230            id="btnDeleteItems"
231            image="delete.png"
232            title="Delete" 
233            tooltip="Delete the selected items" 
234          />
235          <tbl:button 
236            id="btnRestoreItems"
237            image="restore.png"
238            title="Restore" 
239            tooltip="Restore the selected (deleted) items"
240          />
241          <tbl:button 
242            id="btnShareItems"
243            image="share.png"
244            title="Share&hellip;" 
245            tooltip="Share the selected items"
246          />
247          <tbl:button 
248            id="btnSetOwner"
249            image="take_ownership.png"
250            title="Set owner&hellip;"
251            tooltip="Change owner of the selected items"
252          />
253          <tbl:button 
254            id="btnColumns"
255            image="columns.png" 
256            title="Columns&hellip;" 
257            tooltip="Show, hide and re-order columns" 
258          />
259          <tbl:button 
260            id="btnImport"
261            data-plugin-type="IMPORT"
262            image="import.png" 
263            title="Import&hellip;" 
264            tooltip="Import data" 
265            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
266          />
267          <tbl:button 
268            id="btnExport"
269            data-plugin-type="EXPORT"
270            image="export.png" 
271            title="Export&hellip;" 
272            tooltip="Export data" 
273            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
274          />
275          <tbl:button 
276            id="btnRunPlugin"
277            data-plugin-type="OTHER"
278            image="runplugin.png" 
279            title="Run plugin&hellip;" 
280            tooltip="Run a plugin" 
281            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
282          />
283          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
284            wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
285        </tbl:toolbar>
286        <tbl:panel>
287          <tbl:presetselector />
288          <tbl:navigator
289            page="<%=cc.getPage()%>" 
290            rowsperpage="<%=cc.getRowsPerPage()%>" 
291            totalrows="<%=reporterLists == null ? 0 : reporterLists.getTotalCount()%>" 
292            visible="<%=mode.hasNavigator()%>"
293          />
294        </tbl:panel>
295      </div>
296      <tbl:data>
297        <tbl:headers>
298          <tbl:headerrow>
299            <tbl:header colspan="3" />
300            <tbl:columnheaders />
301          </tbl:headerrow>
302          <%
303          int numFilters = cc.getNumPropertyFilters();
304          int numRows = cc.getFilterRows();
305          for (int filterNo = 0; filterNo < numRows; filterNo++)
306          {
307            boolean lastRow = filterNo == numRows-1;
308            %>
309            <tbl:headerrow>
310              <tbl:header subclass="index" />
311              <tbl:header 
312                subclass="check" 
313                visible="<%=mode.hasCheck()%>"
314                ><base:icon 
315                  id="check.uncheck"
316                  image="check_uncheck.png" 
317                  tooltip="Check/uncheck all" 
318                  visible="<%=lastRow%>"
319                /></tbl:header>
320              <tbl:header 
321                subclass="check" 
322                visible="<%=mode.hasRadio()%>"
323                />
324              <tbl:header 
325                subclass="icons" 
326                visible="<%=mode.hasIcons()%>"
327                >
328                <base:icon
329                  subclass="link table-filter-row-action"
330                  image="add.png"
331                  tooltip="Add extra filter row"
332                  visible="<%=lastRow%>"
333                /><base:icon
334                  subclass="link table-filter-row-action"
335                  image="remove.png"
336                  tooltip="Remove this filter row"
337                  visible="<%=numRows > 1 || numFilters > 0 %>"
338                  data-remove-row="<%=filterNo%>"
339                />
340              </tbl:header>
341              <tbl:propertyfilter row="<%=filterNo%>" />
342            </tbl:headerrow>
343            <%
344          }
345          %>
346        </tbl:headers>
347        <tbl:rows>
348          <%
349          if (cc.getMessage() != null)
350          {
351            %>
352            <tbl:panel subclass="bg-filled-50">
353              <div class="messagecontainer error"><%=cc.getMessage()%></div>
354            </tbl:panel>
355            <%
356            cc.setMessage(null);
357          }
358          int index = cc.getPage()*cc.getRowsPerPage();
359          int selectedItemId = cc.getId();
360          if (reporterLists != null)
361          {           
362            while (reporterLists.hasNext())
363            {
364              ReporterList item = reporterLists.next();
365              int itemId = item.getId();
366             
367             
368              boolean deletePermission = item.hasPermission(Permission.DELETE);
369              boolean sharePermission = item.hasPermission(Permission.SET_PERMISSION);
370              boolean writePermission = item.hasPermission(Permission.WRITE);
371              String tooltip = mode.isSelectionMode() ?
372                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
373              String name = HTML.encodeTags(item.getName());
374              index++;
375              numListed++;
376              %>
377              <tbl:row>
378                <tbl:header 
379                  clazz="index"
380                  ><%=index%></tbl:header>
381                <tbl:header 
382                  clazz="check" 
383                  visible="<%=mode.hasCheck()%>"
384                  ><input 
385                    type="checkbox" 
386                    name="<%=itemId%>" 
387                    value="<%=itemId%>" 
388                    title="<%=name%>" 
389                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
390                  ></tbl:header>
391                <tbl:header 
392                  clazz="check" 
393                  visible="<%=mode.hasRadio()%>"
394                  ><input 
395                    type="radio" 
396                    name="item_id" 
397                    value="<%=itemId%>" 
398                    title="<%=name%>" 
399                    <%=selectedItemId == itemId ? "checked" : ""%>
400                  ></tbl:header>
401                <tbl:header 
402                  clazz="icons" 
403                  visible="<%=mode.hasIcons()%>"
404                  ><base:icon 
405                    image="deleted.png"
406                    id="<%="delete."+itemId %>"
407                    subclass="<%=deletePermission ? "table-delete-item" : null %>"
408                    data-item-id="<%=itemId%>"
409                    tooltip="This item has been scheduled for deletion" 
410                    visible="<%=item.isRemoved()%>"
411                  /><base:icon 
412                    image="shared.png" 
413                    id="<%="share."+itemId %>"
414                    subclass="<%=sharePermission ? "table-share-item" : null %>"
415                    data-item-id="<%=itemId%>"
416                    tooltip="This item is shared to other users, groups and/or projects" 
417                    visible="<%=item.isShared()%>"
418                  />&nbsp;</tbl:header>
419                <tbl:cell column="name"><div
420                  class="link table-item"
421                  data-item-id="<%=itemId%>"
422                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
423                  tabindex="0"
424                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
425                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
426                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
427                <tbl:cell column="owner"
428                  ><base:propertyvalue 
429                    item="<%=item%>" 
430                    property="owner"
431                    enableEditLink="<%=mode.hasEditLink()%>" 
432                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
433                  /></tbl:cell>
434                <tbl:cell column="experiment"
435                  ><base:propertyvalue 
436                    item="<%=item%>" 
437                    property="experiment"
438                    enableEditLink="<%=mode.hasEditLink()%>" 
439                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
440                  /></tbl:cell>
441                <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>
442                <tbl:cell column="numReporters"><%=item.getSize()%></tbl:cell>
443                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
444                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
445                <tbl:cell column="sharedTo">
446                  <%
447                  Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
448                  while(sharees.hasNext())
449                  {
450                    Nameable n = sharees.next();
451                    if (mode.hasPropertyLink())
452                    {
453                      out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
454                    }
455                    else
456                    {
457                      out.write(HTML.encodeTags(n.getName()));
458                    }
459                    out.write(sharees.hasNext() ? ", " : "");
460                  }
461                  %>
462                </tbl:cell>
463                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
464                  <tbl:cell column="xt-columns" />
465                </tbl:xt-cells>
466              </tbl:row>
467              <%
468              }
469            }
470          if (numListed == 0)
471          {
472            %>
473            <tbl:panel subclass="bg-filled-50">
474              <div class="messagecontainer note">
475              <%=reporterLists == null || reporterLists.getTotalCount() == 0 ? "No reporter lists were found" : "No reporter lists on this page. Please select another page!" %>
476              </div>
477            </tbl:panel>
478            <%
479          }
480          %>
481          </tbl:rows>
482      </tbl:data>
483    </tbl:table>
484    </div>
485   
486    <base:buttongroup subclass="dialogbuttons">
487      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
488      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
489      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
490    </base:buttongroup>
491   
492  </base:body>
493  </base:page>
494  <%
495}
496finally
497{
498  if (reporterLists != null) reporterLists.close();
499  if (dc != null) dc.close();
500}
501%>
Note: See TracBrowser for help on using the repository browser.