Wiki source code of AppsLiveTableResults
Last modified by superadmin on 2022/05/03 16:55
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | {{include reference="XWiki.LiveTableResultsMacros" /}} |
2 | |||
3 | {{velocity wiki="false"}} | ||
4 | #if($xcontext.action == 'get' && "$!{request.outputSyntax}" == 'plain') | ||
5 | $response.setContentType('application/json') | ||
6 | #set($map = {}) | ||
7 | #gridresult_buildJSON("$!request.classname" $request.collist.split(',') $map) | ||
8 | ## Change the URL and permission for the edit and delete actions: | ||
9 | ## * edit action must trigger the AppWithinMinutes wizard. | ||
10 | ## * delete action must delete the application space. | ||
11 | #foreach($row in $map.get('rows')) | ||
12 | #set($rowDocRef = $services.model.resolveDocument($row.get('doc_fullName'))) | ||
13 | #set($rowDoc = $xwiki.getDocument($rowDocRef)) | ||
14 | #set($classFullName = $rowDoc.getObject('AppWithinMinutes.LiveTableClass').getProperty('class').value) | ||
15 | #set($classRef = $services.model.resolveDocument($classFullName)) | ||
16 | ## Edit action | ||
17 | #if($row.get('doc_hasedit')) | ||
18 | ## Make sure to test edit rights on the application's class and not its homepage. | ||
19 | #set($discard = $row.put('doc_hasedit', $services.security.authorization.hasAccess('edit', $classRef))) | ||
20 | #end | ||
21 | #set($appQueryString = "appName=$escapetool.url($row.get('doc_space'))&resolve=true") | ||
22 | #set($discard = $row.put('doc_edit_url', $xwiki.getURL('AppWithinMinutes.CreateApplication', 'view', | ||
23 | $appQueryString))) | ||
24 | ## Delete action | ||
25 | #if($row.get('doc_hasdelete')) | ||
26 | ## Deleting an application requires space administration rights on both data and code spaces. | ||
27 | #set($hasDeleteData = $services.security.authorization.hasAccess('admin', $rowDocRef.lastSpaceReference)) | ||
28 | #set($hasDeleteCode = $services.security.authorization.hasAccess('admin', $classRef.lastSpaceReference)) | ||
29 | #set($hasDeleteApplication = $hasDeleteData && $hasDeleteCode) | ||
30 | #set($discard = $row.put('doc_hasdelete', $hasDeleteApplication)) | ||
31 | #end | ||
32 | #set($discard = $row.put('doc_delete_url', $xwiki.getURL('AppWithinMinutes.DeleteApplication', 'view', | ||
33 | $appQueryString))) | ||
34 | #end | ||
35 | $jsontool.serialize($map) | ||
36 | #end | ||
37 | {{/velocity}} |