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