0 Votes
Version 4.1 by Сергей Коршунов on 2023/01/17 14:14

Show last authors
1 {{template name="locationPicker_macros.vm" /}}
2
3 {{velocity output="false"}}
4 #macro (displayApp)
5 #set ($discard = $xwiki.ssx.use('AppWithinMinutes.LiveTableViewSheet'))
6 #set ($discard = $xwiki.jsx.use('AppWithinMinutes.LiveTableViewSheet', {'currentApp': $doc.getDocumentReference()}))
7 #if (!$isReadOnly)
8 #displayAppActions
9 #end
10 $doc.display('description')
11 ## Display the live table only if it was generated.
12 #if ($doc.content.length() > 0)
13 = $services.localization.render('platform.appwithinminutes.appLiveTableHeading') =
14
15 {{include reference="" author="target"/}}
16 #end
17 #end
18
19 #macro (displayAppActions)
20 ## Determine the user's rights
21 #set ($className = $stringtool.removeEnd($classFullName, 'Class'))
22 #set ($templateProviderReference = $services.model.resolveDocument("${className}TemplateProvider"))
23 #set ($templateProvider = $xwiki.getDocument($templateProviderReference))
24 #set ($creationRestrictions = $templateProvider.getValue('creationRestrictions'))
25 #if ($creationRestrictions)
26 #if ($creationRestrictions.size() > 0)
27 #set ($dataSpaceRef = $services.model.resolveSpace($creationRestrictions.get(0)))
28 #else
29 ## There is no data space as the user can create application entries anywhere. Let's use the application space
30 ## when the user clicks on the Add New Entry link from the home page.
31 #set ($dataSpaceRef = $doc.documentReference.parent)
32 #end
33 #else
34 ## The template provider is missing. Fall-back on the old 'dataSpace' property.
35 #set ($dataSpaceRef = $services.model.resolveSpace($doc.getValue('dataSpace'), 'explicit',
36 $doc.documentReference))
37 #end
38 #set ($hasCreateData = $services.security.authorization.hasAccess('edit', $dataSpaceRef))
39 #set ($hasDeleteData = $services.security.authorization.hasAccess('admin', $dataSpaceRef))
40 #set ($translationsRef = $services.model.resolveDocument("${className}Translations"))
41 #set ($hasEditTranslations = $xwiki.isMultiLingual() && $xwiki.exists($translationsRef)
42 && $services.security.authorization.hasAccess('edit', $translationsRef))
43 #set ($classRef = $services.model.resolveDocument($classFullName))
44 #set ($hasEditApplication = $services.security.authorization.hasAccess('edit', $classRef))
45 #set ($hasDeleteApplication = $hasDeleteData
46 && $services.security.authorization.hasAccess('admin', $doc.documentReference.parent)
47 && $services.security.authorization.hasAccess('admin', $classRef.parent))
48 ## Display the application actions based on the user's rights
49 #if ($hasCreateData || $hasDeleteData || $hasEditApplication || $hasEditTranslations || $hasDeleteApplication)
50 (% id="actionBox" class="floatinginfobox" %)
51 (((
52 = $services.localization.render('platform.appwithinminutes.appHomePageActionsHeading') =
53 #if ($hasCreateData)
54 * [[$services.localization.render('platform.appwithinminutes.appHomePageAddEntryHint')>>||anchor="AddNewEntry" class="action add"]]##
55 #if ("$!templateProvider.getValue('terminal')" == '1')
56 #set ($entryReference = $services.model.createDocumentReference('__entryName__', $dataSpaceRef))
57 #else
58 #set ($entryReference = $services.model.resolveDocument('', 'default',
59 $services.model.createSpaceReference('__entryName__', $dataSpaceRef)))
60 #end
61 ## We need to set the title if we want to be able to sort or filter the doc.title live table column.
62 #set ($params = {
63 'template': "${className}Template",
64 'title': '__entryName__',
65 'parent': $services.model.serialize($doc.documentReference, 'local')
66 })
67 #if ($xwiki.getDocument($classRef).xWikiClass.properties.size() > 0)
68 ## The entry has properties so go in edit mode to edit them.
69 #set ($action = 'edit')
70 #set ($params.editor = 'inline')
71 #else
72 ## There are no properties to edit so create the new entry and get back to the home page.
73 #set ($action = 'save')
74 #set ($discard = $params.putAll({
75 'xredirect': $doc.getURL(),
76 'form_token': $services.csrf.token
77 }))
78 #end
79 {{html}}<input type="hidden" value="$xwiki.getURL($entryReference, $action, $escapetool.url($params))" />{{/html}}
80 #end
81 #if ($hasEditApplication)
82 #set ($queryString = $escapetool.url({
83 'appName': $doc.space,
84 'resolve': true
85 }))
86 * [[$services.localization.render('platform.appwithinminutes.appHomePageEditAppLabel')>>AppWithinMinutes.CreateApplication||queryString="$queryString" class="action edit"]]
87 #end
88 #if ($hasEditTranslations)
89 * [[$services.localization.render('platform.appwithinminutes.appHomePageTranslateAppLabel')>>path:${xwiki.getURL($translationsRef, 'edit', 'editor=wiki')}||class="action translate"]]
90 #end
91 #if ($hasDeleteData)
92 #set ($deleteDataURL = $xwiki.getURL('AppWithinMinutes.DeleteApplication', 'view', $escapetool.url({
93 'appName': $doc.space,
94 'resolve': true,
95 'scope': 'entries',
96 'xredirect': $doc.getURL()
97 })))
98 * [[$services.localization.render('platform.appwithinminutes.appHomePageDeleteEntriesLabel')>>path:${deleteDataURL}||class="action deleteData"]]
99 #end
100 #if ($hasDeleteApplication)
101 #set ($deleteAppURL = $xwiki.getURL('AppWithinMinutes.DeleteApplication', 'view', $escapetool.url({
102 'appName': $doc.space,
103 'resolve': true,
104 'xredirect': $doc.getURL()
105 })))
106 * [[$services.localization.render('platform.appwithinminutes.appHomePageDeleteAppLabel')>>path:${deleteAppURL}||class="action delete"]]
107 #end
108 )))
109 #end
110 #end
111
112 #macro (renameAppModal)
113 <div class="modal" id="renameAppModal" tabindex="-1" role="dialog" aria-labelledby="renameAppModal-label"
114 data-backdrop="static" data-keyboard="false">
115 <div class="modal-dialog" role="document">
116 <form class="modal-content xform">
117 ## The fieldset allows us to disable and enable the entire form quickly and easy.
118 <fieldset>
119 <div class="modal-header">
120 <button type="button" class="close" data-dismiss="modal"
121 title="$escapetool.xml($services.localization.render('appWithinMinutes.renameApp.close'))"
122 aria-label="$escapetool.xml($services.localization.render('appWithinMinutes.renameApp.close'))">
123 <span aria-hidden="true">&times;</span>
124 </button>
125 <span class="modal-title" id="renameAppModal-label">
126 $escapetool.xml($services.localization.render('appWithinMinutes.renameApp.label'))
127 </span>
128 </div>
129 <div class="modal-body">
130 #renameAppModalBody
131 </div>
132 <div class="modal-footer">
133 <button type="button" class="btn btn-default" data-dismiss="modal">
134 $escapetool.xml($services.localization.render('cancel'))
135 </button>
136 <button type="submit" class="btn btn-primary" disabled="disabled">
137 $escapetool.xml($services.localization.render('core.rename.submit'))
138 </button>
139 </div>
140 </fieldset>
141 </form>
142 </div>
143 </div>
144 #end
145
146 #macro (renameAppModalBody)
147 <div class="box infomessage">
148 $services.icon.renderHTML('info')
149 $services.localization.render('appWithinMinutes.renameApp.changeAppTitleInfo')
150 </div>
151 <div class="box warningmessage">
152 $services.icon.renderHTML('warning')
153 $services.localization.render('appWithinMinutes.renameApp.regenerateAppCodeWarning')
154 </div>
155 <div class="hidden">
156 <input type="hidden" name="form_token" value="$!escapetool.xml($services.csrf.token)" />
157 <input type="hidden" name="oldAppReference" value="$escapetool.xml(
158 $services.model.serialize($doc.documentReference.parent, 'local'))"/>
159 <span class="appNameEmptyError xErrorMsg">
160 $services.localization.render("platform.appwithinminutes.appNameEmptyError")
161 </span>
162 <span class="pageExistsError xErrorMsg">
163 $services.localization.render("appWithinMinutes.renameApp.pageExistsError")
164 </span>
165 <span class="locationForbiddenError xErrorMsg">
166 $services.localization.render("appWithinMinutes.renameApp.locationForbiddenError")
167 </span>
168 </div>
169 #set ($appName = $doc.pageReference.name)
170 #set ($isNestedPage = $doc.documentReference.name == $services.model.getEntityReference('DOCUMENT', 'default').name)
171 #set ($parentReference = $doc.documentReference.parent)
172 #if ($isNestedPage)
173 #set ($parentReference = $parentReference.parent)
174 #end
175 #locationPicker({
176 'id': 'renameApp',
177 'title': {
178 'label': 'appWithinMinutes.renameApp.newName.label',
179 'hint': 'platform.appwithinminutes.appNameHint',
180 'name': 'newAppName',
181 'value': $appName,
182 'placeholder': 'appWithinMinutes.renameApp.newName.label'
183 },
184 'preview': {
185 'label': 'appWithinMinutes.renameApp.location.label',
186 'hint': 'appWithinMinutes.renameApp.location.hint'
187 },
188 'parent': {
189 'label': 'appWithinMinutes.renameApp.parent.label',
190 'hint': 'appWithinMinutes.renameApp.parent.hint',
191 'name': 'newAppParentReference',
192 'reference': $parentReference,
193 'placeholder': 'appWithinMinutes.createApp.parent.placeholder'
194 }
195 })
196 #end
197 {{/velocity}}
198
199 {{velocity}}
200 #set ($liveTableObj = $doc.getObject('AppWithinMinutes.LiveTableClass'))
201 #if ($liveTableObj)
202 #set ($discard = $doc.use($liveTableObj))
203 #set ($classFullName = $doc.getValue('class'))
204 #if ("$!classFullName" == '' || !$xwiki.exists($classFullName))
205 {{warning}}
206 $services.icon.render('warning') {{translation key="platform.appwithinminutes.appHomePageMovedWarning"/}}
207 {{/warning}}
208
209 #end
210 #displayApp()
211
212 {{html clean="false"}}
213 #renameAppModal()
214 {{/html}}
215 #end
216 {{/velocity}}