Hide last authors
Administrator 1.1 1 {{include reference="AppWithinMinutes.WizardStep"/}}
2
3 {{velocity output="false"}}
4 #macro(showStep)
5 {{html wiki="true"}}
6 #appWizardHeader(1)
7 (% class="wizard-help" %)
8 (((
9 **$services.localization.render('platform.appwithinminutes.wizardStepHelpTitle')** $services.localization.render('platform.appwithinminutes.wizardStepHelpDescription')
10 (% class="steps vertical" %)
11 #foreach($index in [1, 2, 3])
12 * (% class="number" %)$index(%%) (% class="name" %)$services.localization.render("platform.appwithinminutes.wizardStep${index}Name")(%%)
13 (% class="description" %)$services.localization.render("platform.appwithinminutes.wizardStep${index}Description")
14 #end
15 )))
16 <form action="$doc.getURL()" method="post" class="xform wizard-body">
17 ; <label for="appName">$services.localization.render('platform.appwithinminutes.appNameLabel')</label>
18 (% class="xHint" %)$services.localization.render('platform.appwithinminutes.appNameHint')
19 : <input type="text" id="appName" name="appName" />
20 #appWizardFooter(1)
21 </form>
22 {{/html}}
23 #end
24
Sebastian Sams 2.1 25 #macro(getAppDescriptor $appReference)
Administrator 1.1 26 #set($appDescriptorClassName = 'AppWithinMinutes.LiveTableClass')
27 #set($appDescriptorStatement = "from doc.object($appDescriptorClassName) as obj where doc.space = :space")
Sebastian Sams 2.1 28 #set($localSpaceReference = $services.model.serialize($appReference, 'local'))
29 #set($appDescriptors = $services.query.xwql($appDescriptorStatement).bindValue('space', $localSpaceReference).execute())
Administrator 1.1 30 #if($appDescriptors.size() > 0)
31 #set($appDescriptor = $xwiki.getDocument($appDescriptors.get(0)))
32 #end
33 #end
34
Sebastian Sams 2.1 35 #macro (processStep)
Administrator 1.1 36 ## Check if the application already exists.
Sebastian Sams 2.1 37 #if ($request.resolve == 'true')
38 #set ($appReference = $services.model.resolveSpace($request.appName))
39 #else
40 #set ($appReference = $services.model.createSpaceReference($request.appName,
41 $doc.documentReference.wikiReference))
42 #end
43 #set ($appName = $appReference.name)
44 #getAppDescriptor($appReference)
Administrator 1.1 45 #if($appDescriptor)
46 ## Edit an existing application. Use the configured class name.
47 #set($classStringRef = $appDescriptor.getObject($appDescriptorClassName).getProperty('class').value)
48 ## The class string reference is relative to the document holding the application descriptor.
49 #set($classRef = $services.model.resolveDocument($classStringRef, 'explicit', $appDescriptor.documentReference))
50 #else
51 ## Create a new application. Use the default class name.
52 #set($className = "#toXMLName($appName)")
53 #set($classRef = $services.model.createDocumentReference($doc.wiki, "${className}Code", "${className}Class"))
54 #end
Sebastian Sams 2.1 55 #set($queryString = {'wizard': true})
Administrator 1.1 56 #if(!$xwiki.exists($classRef))
Sebastian Sams 2.1 57 #set($appHomeRef = $services.model.resolveDocument('', 'default', $appReference))
58 #set($discard = $queryString.putAll({
59 'editor': 'inline',
60 'template': 'AppWithinMinutes.ClassTemplate',
61 'parent': $services.model.serialize($appHomeRef),
62 'title': "$appName Class",
63 'AppWithinMinutes.MetadataClass_0_dataSpaceName': $appName
64 }))
Administrator 1.1 65 #end
Sebastian Sams 2.1 66 $response.sendRedirect($xwiki.getURL($classRef, 'edit', $escapetool.url($queryString)))
Administrator 1.1 67 #end
68
69 #macro(validateAppName $appName)
Sebastian Sams 2.1 70 #set ($appReference = $services.model.createSpaceReference($appName,
71 $doc.documentReference.wikiReference))
72 #getAppDescriptor($appReference)
Administrator 1.1 73 #if($appDescriptor)
74 ## Edit an existing application.
75 #set($classStringRef = $appDescriptor.getObject($appDescriptorClassName).getProperty('class').value)
76 ## The class string reference is relative to the document holding the application descriptor.
77 #set($appClassRef = $services.model.resolveDocument($classStringRef, 'explicit', $appDescriptor.documentReference))
78 #else
79 ## Create a new application.
80 #set($className = "#toXMLName($appName)")
81 #if($className == '')
82 (% class="xErrorMsg" %)$services.localization.render('platform.appwithinminutes.appNameInvalidClassNameError')
83 #end
84 #set($appClassRef = $services.model.createDocumentReference($doc.wiki, "$!{className}Code", "$!{className}Class"))
85 #end
Sebastian Sams 2.1 86 #set($appHomeRef = $services.model.resolveDocument('', 'default', $appReference))
Administrator 1.1 87 #set($appHomeURL = $stringtool.removeEnd($xwiki.getDocument($appHomeRef).getExternalURL(), 'WebHome'))
88 ; $services.localization.render('platform.appwithinminutes.appNamePreviewHomePageUrlLabel')
89 : {{{$!appHomeURL}}}
90 ; $services.localization.render('platform.appwithinminutes.appNamePreviewDataSpaceLabel')
91 : {{{$appHomeRef.wikiReference.name}}} » {{{$appHomeRef.lastSpaceReference.name}}}
92 ; $services.localization.render('platform.appwithinminutes.appNamePreviewCodeSpaceLabel')
93 : {{{$appClassRef.wikiReference.name}}} » {{{$appClassRef.lastSpaceReference.name}}}
94 ; $services.localization.render('platform.appwithinminutes.appNamePreviewClassReferenceLabel')
95 : {{{$appClassRef.wikiReference.name}}} » {{{$appClassRef.lastSpaceReference.name}}} » {{{$appClassRef.name}}}
96 #if($appDescriptor || $xwiki.exists($appHomeRef) || $xwiki.exists($appClassRef))
97
98 {{warning}}$services.localization.render('platform.appwithinminutes.appNameIsUsedWarning'){{/warning}}
99 #end
100 #end
101 {{/velocity}}
102
103 {{velocity}}
104 #if("$!request.appName" != '')
105 #if($xcontext.action == 'get')
106 #validateAppName($request.appName)
107 #else
108 ## CSRF protection is not needed because this step only redirects to the next one passing data in the query string.
109 #processStep()
110 #end
111 #else
112 #showStep()
113 #end
114 #set($docextras=[])
115 {{/velocity}}
Copyright 2018 - Österreichisches Weltraum Forum. All rights reserved.