Wiki source code of Apps

Version 2.1 by superadmin on 2021/03/02 16:49

Hide last authors
hbpadmin 1.1 1 {{include reference="Collaboratory.Apps.Apps.Code.AppsMacros"/}}
2
3 {{velocity output="no"}}
4 $xwiki.ssx.use('Collaboratory.UX.SSX.noheader')
5 #set($displayDocExtra = false)
6
7 ## Get filter parameters from Query String, build the query and get applications that match
8 #set($searchTerm = $request.getParameter('text'))
9 #if(!$searchTerm) #set($searchTerm = '') #end
10 #set($categoryTerm = $request.getParameter('category'))
11 #if(!$categoryTerm) #set($categoryTerm = '') #end
12 #set($displayInDevApps = 0)
13 #if($request.getParameter('development') == '1')
14 #set($displayInDevApps = 1)
15 #end
16
17 #set($query = "select doc from Document doc, doc.object(Collaboratory.Apps.Apps.Catalogue.Code.CatalogueClass) as app where (app.description like :search or app.name like :search) and (:category = '' or app.category = :category) and app.development = :indev")
18 #set($applications = $services.query.xwql($query).bindValue('search', "%$searchTerm%").bindValue('category', $categoryTerm).bindValue('indev', $displayInDevApps).addFilter('hidden').execute())
19 #set($totalApplications = $applications.size()) ## Get how many applications match. Used to custom view if none or more than 0.
20
21 ## Get categories list for Category filter
22 #set($categories = $xwiki.getClass('Collaboratory.Apps.Apps.Catalogue.Code.CatalogueClass').category.getValue('values').split('[|]'))
23
24 ## Has current user permission to create an App?
25 #set($createAppGroup = $services.user.group.getMembers('xwiki:XWiki.feature:create_app', false))
26 #set($isUserAppCreator = $createAppGroup.contains($xcontext.userReference))
27 {{/velocity}}
28 {{velocity}}
29 {{html clean="false"}}
30 ## we need to import the javascript like taht so we have the `module` type
31 <script type="module" src="$services.webjars.url('eu.hbp.wiki:xwiki-webapp-collaboratory', 'collab.esm.js')"></script>
32 <div class="row external-apps-header">
33 <div class="col-md-8">
34 <h1>Community Apps</h1>
35 </div>
36 <div class="col-md-4">
37 #if($isUserAppCreator)
38 <a class="btn btn-primary pull-right" href="$doc.getURL('create')"><span class="fa fa-plus"></span> Create App</a>
39 #end
40 </div>
41 </div> ## /.row.externap-apps-header
42
43 <div class="row">
44 <div class="col-md-3">
45 ## Filter form
46 <form action="$doc.getURL('view')" method="get">
47 <div class="form-group">
48 <label for="application-text-filter">Filter by text</label>
49 <input type="text" name="text" id="application-text-filter" value="$searchTerm">
50 </div>
51 <div class="form-group">
52 <label for="application-category-filter">Filter by category</label>
53 <select name="category">
54 <option value="">All</option>
55 #foreach($category in $categories)
56 <option value="$category" #if($categoryTerm == $category)selected#end>$category</option>
57 #end
58 </select>
59 </div>
60
61 <div class="checkbox">
62 <label>
63 <input type="checkbox" name="development" value="1"#if($displayInDevApps == 1) checked#end> Show In Development Apps
64 </label>
65 </div>
66 <button class="btn btn-primary" type="submit">Filter</button>
67 <a class="btn btn-primary-inverted" href="$doc.getURL('view')">Reset</a>
68 </form>
69 </div> ## /.col-md-3
70 <div class="col-md-9">
71 ## Applications list
72 #if($totalApplications > 0)
73 ## There are applications that match, display them.
74 <div class="applications-count">
75 <strong>$totalApplications</strong> application#if($totalApplications > 1)s#end found
76 #if($searchTerm != '') for <strong>$escapetool.html($searchTerm)</strong>#end
77 #if($categoryTerm != '') in <strong>$escapetool.html($categoryTerm)</strong> category#end
78 </div>
79 #applications($applications false)
80 #else
81 ## No Application corresponds to filter, display a message to inform the user
82 <div class="applications-no-results">
83 <h3>
84 No Application Found
85 #if($searchTerm != '') for <i>'$escapetool.html($searchTerm)'</i>#end
86 #if($categoryTerm != '') in <i>'$escapetool.html($categoryTerm)'</i> category#end
87 </h3>
88 <a class="btn btn-primary-inverted" href="$doc.getURL('view')">Reset Filters</a>
89 #end
90 </div> ## /.col-md-9
91 </div> ## /.row
92 {{/html}}
93 {{/velocity}}