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