Wiki-Quellcode von ApplicationsPanelConfiguration Sheet
Zuletzt geändert von admin am 2025/02/23 10:22
Zeige letzte Bearbeiter
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{velocity}} | ||
| 2 | ########################## | ||
| 3 | ## JAVASCRIPT/CSS | ||
| 4 | ########################## | ||
| 5 | #set($discard = $xwiki.jsx.use('PanelsCode.ApplicationsPanelConfigurationSheet')) | ||
| 6 | #set($discard = $xwiki.ssx.use('PanelsCode.ApplicationsPanelConfigurationSheet')) | ||
| 7 | ########################## | ||
| 8 | ## First, we split the applications in 2 categories (white listed/black listed) | ||
| 9 | ########################## | ||
| 10 | #set($displayedApps = []) | ||
| 11 | #set($blacklistedApps = []) | ||
| 12 | #if($doc.fullName == 'XWiki.XWikiPreferences') | ||
| 13 | #set($configDoc = $xwiki.getDocument($services.model.createDocumentReference('', 'PanelsCode', 'ApplicationsPanelConfiguration'))) | ||
| 14 | #else | ||
| 15 | #set($configDoc = $doc) | ||
| 16 | #end | ||
| 17 | #foreach($uix in $services.uix.getExtensions('org.xwiki.platform.panels.Applications', {'sortByParameter' : 'label'})) | ||
| 18 | #if("$!configDoc.getObject('PanelsCode.ApplicationsPanelBlackListClass', 'applicationId', $uix.id)" != '') | ||
| 19 | #set($discard = $blacklistedApps.add({'uix': $uix})) | ||
| 20 | #else | ||
| 21 | #set ($app = {'uix': $uix}) | ||
| 22 | #set ($orderObj = $configDoc.getObject('PanelsCode.ApplicationsPanelOrderClass', 'applicationId', $uix.id)) | ||
| 23 | #if ($orderObj) | ||
| 24 | #set ($discard = $app.put('order', $orderObj.getValue('order'))) | ||
| 25 | #else | ||
| 26 | ## if order is not set, set MAX_INTEGER | ||
| 27 | #set ($discard = $app.put('order', 2147483647)) | ||
| 28 | #end | ||
| 29 | #set ($discard = $displayedApps.add($app)) | ||
| 30 | #end | ||
| 31 | #end | ||
| 32 | ## Sort the displayedApp | ||
| 33 | #set ($displayedApps = $collectiontool.sort($displayedApps, 'order')) | ||
| 34 | ########################## | ||
| 35 | ## Macro to display an application panel | ||
| 36 | ########################## | ||
| 37 | #macro(showAppPanel $id $title $class $apps) | ||
| 38 | |||
| 39 | {{html}} | ||
| 40 | <div class="col-xs-12 col-md-6"> | ||
| 41 | <div class="panel-width-Small panel $!class appsPanel" id="$id"> | ||
| 42 | <div class="panel-heading"> | ||
| 43 | <h2>$title</h2> | ||
| 44 | </div> | ||
| 45 | <div class="panel-body"> | ||
| 46 | <ul class="nav nav-pills applicationsPanel"> | ||
| 47 | #foreach($app in $apps) | ||
| 48 | #set($params = $app.uix.getParameters()) | ||
| 49 | #set($normalizedIcon = $stringtool.substringBefore($!params.icon, ' ')) | ||
| 50 | #if("$!normalizedIcon" != '' && "$!params.label" != '' && "$!params.target" != '' && $xwiki.hasAccessLevel('view', $xcontext.user, $params.target)) | ||
| 51 | #if ($normalizedIcon.startsWith('icon:')) | ||
| 52 | #set($icon = $services.icon.renderHTML($normalizedIcon.substring(5))) | ||
| 53 | #else | ||
| 54 | #set($icon = $services.rendering.render($services.rendering.parse("image:${normalizedIcon}", 'xwiki/2.1'), 'xhtml/1.0')) | ||
| 55 | #end | ||
| 56 | <li class="draggableApp" id="$escapetool.xml($app.uix.id)"> | ||
| 57 | <a><span class="application-img">$icon </span> <span class="application-label">$escapetool.xml($params.label)</a> | ||
| 58 | </li> | ||
| 59 | #end | ||
| 60 | #end | ||
| 61 | </ul> | ||
| 62 | </div> | ||
| 63 | </div> | ||
| 64 | </div> | ||
| 65 | {{/html}} | ||
| 66 | #end | ||
| 67 | ########################## | ||
| 68 | ## Display the information message | ||
| 69 | ########################## | ||
| 70 | (% class="noitems" %) | ||
| 71 | {{translation key="platform.panels.applications.helper" /}} | ||
| 72 | ########################## | ||
| 73 | ## Display the 2 panels | ||
| 74 | ########################## | ||
| 75 | (% class="row appLists" %) | ||
| 76 | ((( | ||
| 77 | #showAppPanel('displayedPanels', $services.localization.render('platform.panels.applications.displayedapps'), 'panel-primary', $displayedApps) | ||
| 78 | #showAppPanel('blacklistedPanels', $services.localization.render('platform.panels.applications.blacklistedapps'), 'panel-info', $blacklistedApps) | ||
| 79 | ))) | ||
| 80 | ########################## | ||
| 81 | ## Display the buttons | ||
| 82 | ########################## | ||
| 83 | {{html}} | ||
| 84 | <button class="btn btn-primary" id="bt-save">$services.localization.render('platform.panels.applications.save')</button> <button class="btn btn-default" id="bt-revert">$services.localization.render('platform.panels.applications.revert')</button> | ||
| 85 | {{/html}} | ||
| 86 | {{/velocity}} |