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