Wiki source code of $services.localization.render('platform.appwithinminutes.appNamePageTitle')
Version 7.1 by Ludovic Dubost on 2019/05/20 19:03
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
7.1 | 1 | {{include reference="AppWithinMinutes.VelocityMacros"/}} |
![]() |
1.1 | 2 | |
![]() |
7.1 | 3 | {{velocity}} |
4 | #if ($request.wizard == 'true') | ||
5 | {{include reference="AppWithinMinutes.WizardStep"/}} | ||
6 | #end | ||
7 | {{/velocity}} | ||
8 | |||
![]() |
5.1 | 9 | {{template name="locationPicker_macros.vm" /}} |
10 | |||
![]() |
1.1 | 11 | {{velocity output="false"}} |
![]() |
7.1 | 12 | #macro (showStep) |
![]() |
6.1 | 13 | #appWizardHeader('name') |
![]() |
7.1 | 14 | <div class="wizard-help"> |
15 | <p> | ||
16 | <strong>$services.localization.render('platform.appwithinminutes.wizardStepHelpTitle')</strong> | ||
17 | $services.localization.render('platform.appwithinminutes.wizardStepHelpDescription') | ||
18 | </p> | ||
19 | <ul class="steps vertical"> | ||
20 | #foreach($step in $awmSteps) | ||
21 | <li> | ||
22 | <span class="number">$mathtool.add($foreach.index, 1)</span> | ||
23 | <span class="name">$services.localization.render("appWithinMinutes.wizardStep.${step}.name")</span> | ||
24 | <span class="description">$services.localization.render("appWithinMinutes.wizardStep.${step}.description")</span> | ||
25 | </li> | ||
26 | #end | ||
27 | </ul> | ||
28 | </div> | ||
![]() |
4.1 | 29 | <form action="$doc.getURL()" method="post" class="xform wizard-body"> |
![]() |
5.1 | 30 | #locationPicker({ |
31 | 'id': 'app', | ||
32 | 'title': { | ||
33 | 'label': 'platform.appwithinminutes.appNameLabel', | ||
34 | 'hint': 'platform.appwithinminutes.appNameHint', | ||
35 | 'name': 'appName' | ||
36 | }, | ||
37 | 'preview': { | ||
38 | 'label': 'appWithinMinutes.createApp.location.label', | ||
39 | 'hint': 'appWithinMinutes.createApp.location.hint' | ||
40 | }, | ||
41 | 'parent': { | ||
42 | 'label': 'appWithinMinutes.createApp.parent.label', | ||
43 | 'hint': 'appWithinMinutes.createApp.parent.hint', | ||
44 | 'name': 'appParentReference', | ||
45 | 'reference': $doc.documentReference.wikiReference, | ||
46 | 'placeholder': 'appWithinMinutes.createApp.parent.placeholder' | ||
47 | } | ||
48 | }) | ||
49 | <div class="appName-preview"></div> | ||
![]() |
1.1 | 50 | #appWizardFooter(1) |
51 | </form> | ||
52 | #end | ||
53 | |||
![]() |
5.1 | 54 | #macro (processStep) |
![]() |
1.1 | 55 | ## Check if the application already exists. |
![]() |
5.1 | 56 | #getAppReference |
57 | #getAppDescriptor($appReference) | ||
58 | #if ($appDescriptor) | ||
![]() |
7.1 | 59 | ## Edit an existing application. |
60 | #getAppClassReference($appDescriptor) | ||
61 | #set ($appClassRef = $classReference) | ||
![]() |
1.1 | 62 | #else |
63 | ## Create a new application. Use the default class name. | ||
![]() |
5.1 | 64 | #set ($appCodeRef = $services.model.createSpaceReference('Code', $appReference)) |
65 | #set ($appClassRef = $services.model.createDocumentReference("$!{appReference.name}Class", $appCodeRef)) | ||
![]() |
1.1 | 66 | #end |
![]() |
5.1 | 67 | #set ($queryString = {'wizard': true}) |
68 | #if (!$xwiki.exists($appClassRef)) | ||
69 | #set ($appHomeRef = $services.model.resolveDocument('', 'default', $appReference)) | ||
70 | #set ($discard = $queryString.putAll({ | ||
71 | 'template': 'AppWithinMinutes.ClassTemplate', | ||
72 | 'parent': $services.model.serialize($appHomeRef), | ||
73 | 'title': "$appReference.name Class" | ||
74 | })) | ||
![]() |
1.1 | 75 | #end |
![]() |
5.1 | 76 | $response.sendRedirect($xwiki.getURL($appClassRef, 'edit', $escapetool.url($queryString))) |
![]() |
1.1 | 77 | #end |
78 | |||
![]() |
5.1 | 79 | #macro (validateAppName) |
80 | #getAppReference | ||
81 | #if (!$appReference) | ||
![]() |
7.1 | 82 | <span class="xErrorMsg">$services.localization.render('platform.appwithinminutes.appNameEmptyError')</span> |
![]() |
1.1 | 83 | #else |
![]() |
5.1 | 84 | #getAppDescriptor($appReference) |
85 | #if ($appDescriptor) | ||
86 | ## Edit an existing application. | ||
![]() |
7.1 | 87 | #getAppClassReference($appDescriptor) |
88 | #set ($appClassRef = $classReference) | ||
![]() |
5.1 | 89 | #else |
90 | ## Create a new application. | ||
91 | #set ($appCodeRef = $services.model.createSpaceReference('Code', $appReference)) | ||
92 | #set ($appClassRef = $services.model.createDocumentReference("$!{appReference.name}Class", $appCodeRef)) | ||
![]() |
1.1 | 93 | #end |
![]() |
7.1 | 94 | <dl> |
95 | <dt>$services.localization.render('platform.appwithinminutes.appNamePreviewHomePageUrlLabel')</dt> | ||
96 | <dd><pre>$!escapetool.xml($xwiki.getDocument($appReference).externalURL)</pre></dd> | ||
97 | <dt>$services.localization.render('platform.appwithinminutes.appNamePreviewCodeSpaceLabel')</dt> | ||
98 | <dd>#hierarchy($appClassRef.parent)</dd> | ||
99 | </dl> | ||
![]() |
5.1 | 100 | #set ($appHomeRef = $services.model.resolveDocument('', 'default', $appReference)) |
101 | #if ($appDescriptor || $xwiki.exists($appHomeRef) || $xwiki.exists($appClassRef)) | ||
![]() |
7.1 | 102 | <div class="box warningmessage"> |
103 | $services.localization.render('platform.appwithinminutes.appNameIsUsedWarning') | ||
104 | </div> | ||
![]() |
5.1 | 105 | #end |
![]() |
1.1 | 106 | #end |
![]() |
5.1 | 107 | #end |
![]() |
1.1 | 108 | |
![]() |
5.1 | 109 | #macro (getAppReference) |
110 | #if ($request.resolve == 'true') | ||
111 | #set ($appReference = $services.model.resolveSpace($request.appName)) | ||
112 | #elseif ("$!request.appName" != '') | ||
113 | #set ($parentReference = $doc.documentReference.wikiReference) | ||
114 | #if ("$!request.appParentReference" != '') | ||
115 | #set ($parentReference = $services.model.resolveSpace($request.appParentReference)) | ||
116 | #end | ||
117 | #set ($appReference = $services.model.createSpaceReference($request.appName, $parentReference)) | ||
118 | #else | ||
119 | #set ($appReference = $NULL) | ||
![]() |
1.1 | 120 | #end |
121 | #end | ||
![]() |
5.1 | 122 | |
123 | #macro (getAppDescriptor $appReference) | ||
124 | #set ($appDescriptorClassName = 'AppWithinMinutes.LiveTableClass') | ||
125 | #set ($appDescriptorStatement = "from doc.object($appDescriptorClassName) as obj where doc.space = :space") | ||
126 | #set ($localSpaceReference = $services.model.serialize($appReference, 'local')) | ||
127 | #set ($appDescriptors = $services.query.xwql($appDescriptorStatement).bindValue('space', $localSpaceReference).execute()) | ||
128 | #if ($appDescriptors.size() > 0) | ||
129 | #set ($appDescriptor = $xwiki.getDocument($appDescriptors.get(0))) | ||
![]() |
7.1 | 130 | #else |
131 | #set ($appDescriptor = $NULL) | ||
![]() |
5.1 | 132 | #end |
133 | #end | ||
![]() |
1.1 | 134 | {{/velocity}} |
135 | |||
136 | {{velocity}} | ||
![]() |
7.1 | 137 | {{html clean="false"}} |
![]() |
5.1 | 138 | #if ("$!request.appName" != '') |
139 | #if ($xcontext.action == 'get') | ||
140 | #validateAppName | ||
![]() |
1.1 | 141 | #else |
142 | ## CSRF protection is not needed because this step only redirects to the next one passing data in the query string. | ||
![]() |
5.1 | 143 | #processStep |
![]() |
1.1 | 144 | #end |
![]() |
7.1 | 145 | #elseif ($request.wizard == 'true') |
![]() |
5.1 | 146 | #showStep |
![]() |
7.1 | 147 | #set ($displayDocExtra = false) |
![]() |
1.1 | 148 | #end |
![]() |
7.1 | 149 | {{/html}} |
![]() |
1.1 | 150 | {{/velocity}} |