Hide last authors
Administrator 5.1 1 {{include reference="AppWithinMinutes.VelocityMacros"/}}
Administrator 1.1 2
Administrator 5.1 3 {{velocity}}
4 #if ($request.wizard == 'true')
5 {{include reference="AppWithinMinutes.WizardStep"/}}
6 #end
7 {{/velocity}}
8
Barry Bishop 3.1 9 {{template name="locationPicker_macros.vm" /}}
10
Administrator 1.1 11 {{velocity output="false"}}
Administrator 5.1 12 #macro (showStep)
Administrator 4.1 13 #appWizardHeader('name')
Administrator 5.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>
Administrator 1.1 29 <form action="$doc.getURL()" method="post" class="xform wizard-body">
Barry Bishop 3.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>
Administrator 1.1 50 #appWizardFooter(1)
51 </form>
52 #end
53
Sebastian Sams 2.1 54 #macro (processStep)
Administrator 1.1 55 ## Check if the application already exists.
Barry Bishop 3.1 56 #getAppReference
Sebastian Sams 2.1 57 #getAppDescriptor($appReference)
Barry Bishop 3.1 58 #if ($appDescriptor)
Administrator 5.1 59 ## Edit an existing application.
60 #getAppClassReference($appDescriptor)
61 #set ($appClassRef = $classReference)
Administrator 1.1 62 #else
63 ## Create a new application. Use the default class name.
Barry Bishop 3.1 64 #set ($appCodeRef = $services.model.createSpaceReference('Code', $appReference))
65 #set ($appClassRef = $services.model.createDocumentReference("$!{appReference.name}Class", $appCodeRef))
Administrator 1.1 66 #end
Barry Bishop 3.1 67 #set ($queryString = {'wizard': true})
68 #if (!$xwiki.exists($appClassRef))
69 #set ($appHomeRef = $services.model.resolveDocument('', 'default', $appReference))
70 #set ($discard = $queryString.putAll({
Sebastian Sams 2.1 71 'template': 'AppWithinMinutes.ClassTemplate',
72 'parent': $services.model.serialize($appHomeRef),
Barry Bishop 3.1 73 'title': "$appReference.name Class"
Sebastian Sams 2.1 74 }))
Administrator 1.1 75 #end
Barry Bishop 3.1 76 $response.sendRedirect($xwiki.getURL($appClassRef, 'edit', $escapetool.url($queryString)))
Administrator 1.1 77 #end
78
Barry Bishop 3.1 79 #macro (validateAppName)
80 #getAppReference
81 #if (!$appReference)
Administrator 5.1 82 <span class="xErrorMsg">$services.localization.render('platform.appwithinminutes.appNameEmptyError')</span>
Administrator 1.1 83 #else
Barry Bishop 3.1 84 #getAppDescriptor($appReference)
85 #if ($appDescriptor)
86 ## Edit an existing application.
Administrator 5.1 87 #getAppClassReference($appDescriptor)
88 #set ($appClassRef = $classReference)
Barry Bishop 3.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))
Administrator 1.1 93 #end
Administrator 5.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>
Barry Bishop 3.1 100 #set ($appHomeRef = $services.model.resolveDocument('', 'default', $appReference))
101 #if ($appDescriptor || $xwiki.exists($appHomeRef) || $xwiki.exists($appClassRef))
Administrator 5.1 102 <div class="box warningmessage">
103 $services.localization.render('platform.appwithinminutes.appNameIsUsedWarning')
104 </div>
Barry Bishop 3.1 105 #end
Administrator 1.1 106 #end
Barry Bishop 3.1 107 #end
Administrator 1.1 108
Barry Bishop 3.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)
Administrator 1.1 120 #end
121 #end
Barry Bishop 3.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)))
Administrator 5.1 130 #else
131 #set ($appDescriptor = $NULL)
Barry Bishop 3.1 132 #end
133 #end
Administrator 1.1 134 {{/velocity}}
135
136 {{velocity}}
Administrator 5.1 137 {{html clean="false"}}
Barry Bishop 3.1 138 #if ("$!request.appName" != '')
139 #if ($xcontext.action == 'get')
140 #validateAppName
Administrator 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.
Barry Bishop 3.1 143 #processStep
Administrator 1.1 144 #end
Administrator 5.1 145 #elseif ($request.wizard == 'true')
Barry Bishop 3.1 146 #showStep
Administrator 5.1 147 #set ($displayDocExtra = false)
Administrator 1.1 148 #end
Administrator 5.1 149 {{/html}}
Administrator 1.1 150 {{/velocity}}
Copyright 2018 - Österreichisches Weltraum Forum. All rights reserved.