0 Votes

Wiki source code of LiveTable View Sheet

Last modified by Сергей Коршунов on 2025/05/01 21:19

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 * [[{{displayIcon name="add"/}} $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 'form_token': $services.csrf.token,
64 'template': "${className}Template",
65 'title': '__entryName__',
66 'parent': $services.model.serialize($doc.documentReference, 'local')
67 })
68 #if ($xwiki.getDocument($classRef).xWikiClass.properties.size() > 0)
69 ## The entry has properties so go in edit mode to edit them.
70 #set ($action = 'edit')
71 #set ($params.editor = 'inline')
72 #else
73 ## There are no properties to edit so create the new entry and get back to the home page.
74 #set ($action = 'save')
75 #set ($discard = $params.putAll({
76 'xredirect': $doc.getURL(),
77 'form_token': $services.csrf.token
78 }))
79 #end
80 {{html}}<input type="hidden" value="$xwiki.getURL($entryReference, $action, $escapetool.url($params))" />{{/html}}
81 #end
82 #if ($hasEditApplication)
83 #set ($queryString = $escapetool.url({
84 'appName': $doc.space,
85 'resolve': true
86 }))
87 * [[{{displayIcon name="edit"/}} $services.localization.render('platform.appwithinminutes.appHomePageEditAppLabel')>>AppWithinMinutes.CreateApplication||queryString="$queryString" class="action edit"]]
88 #end
89 #if ($hasEditTranslations)
90 * [[{{displayIcon name="translate"/}} $services.localization.render('platform.appwithinminutes.appHomePageTranslateAppLabel')>>path:${xwiki.getURL($translationsRef, 'edit', 'editor=wiki')}||class="action translate"]]
91 #end
92 #if ($hasDeleteData)
93 #set ($deleteDataURL = $xwiki.getURL('AppWithinMinutes.DeleteApplication', 'view', $escapetool.url({
94 'appName': $doc.space,
95 'resolve': true,
96 'scope': 'entries',
97 'xredirect': $doc.getURL()
98 })))
99 * [[{{displayIcon name="cross"/}} $services.localization.render('platform.appwithinminutes.appHomePageDeleteEntriesLabel')>>path:${deleteDataURL}||class="action deleteData"]]
100 #end
101 #if ($hasDeleteApplication)
102 #set ($deleteAppURL = $xwiki.getURL('AppWithinMinutes.DeleteApplication', 'view', $escapetool.url({
103 'appName': $doc.space,
104 'resolve': true,
105 'xredirect': $doc.getURL()
106 })))
107 * [[{{displayIcon name="trash"/}} $services.localization.render('platform.appwithinminutes.appHomePageDeleteAppLabel')>>path:${deleteAppURL}||class="action delete"]]
108 #end
109 )))
110 #end
111 #end
112
113 #macro (renameAppModal)
114 <div class="modal" id="renameAppModal" tabindex="-1" role="dialog" aria-labelledby="renameAppModal-label"
115 data-backdrop="static" data-keyboard="false">
116 <div class="modal-dialog" role="document">
117 <form class="modal-content xform">
118 ## The fieldset allows us to disable and enable the entire form quickly and easy.
119 <fieldset>
120 <div class="modal-header">
121 <button type="button" class="close" data-dismiss="modal"
122 title="$escapetool.xml($services.localization.render('appWithinMinutes.renameApp.close'))"
123 aria-label="$escapetool.xml($services.localization.render('appWithinMinutes.renameApp.close'))">
124 <span aria-hidden="true">&times;</span>
125 </button>
126 <span class="modal-title" id="renameAppModal-label">
127 $escapetool.xml($services.localization.render('appWithinMinutes.renameApp.label'))
128 </span>
129 </div>
130 <div class="modal-body">
131 #renameAppModalBody
132 </div>
133 <div class="modal-footer">
134 <button type="button" class="btn btn-default" data-dismiss="modal">
135 $escapetool.xml($services.localization.render('cancel'))
136 </button>
137 <button type="submit" class="btn btn-primary" disabled="disabled">
138 $escapetool.xml($services.localization.render('core.rename.submit'))
139 </button>
140 </div>
141 </fieldset>
142 </form>
143 </div>
144 </div>
145 #end
146
147 #macro (renameAppModalBody)
148 #info($services.localization.render('appWithinMinutes.renameApp.changeAppTitleInfo'))
149 #warning($services.localization.render('appWithinMinutes.renameApp.regenerateAppCodeWarning'))
150 <div class="hidden">
151 <input type="hidden" name="form_token" value="$!escapetool.xml($services.csrf.token)" />
152 <input type="hidden" name="oldAppReference" value="$escapetool.xml(
153 $services.model.serialize($doc.documentReference.parent, 'local'))"/>
154 <span class="appNameEmptyError xErrorMsg">
155 $services.localization.render("platform.appwithinminutes.appNameEmptyError")
156 </span>
157 <span class="pageExistsError xErrorMsg">
158 $services.localization.render("appWithinMinutes.renameApp.pageExistsError")
159 </span>
160 <span class="locationForbiddenError xErrorMsg">
161 $services.localization.render("appWithinMinutes.renameApp.locationForbiddenError")
162 </span>
163 </div>
164 #set ($appName = $doc.pageReference.name)
165 #set ($isNestedPage = $doc.documentReference.name == $services.model.getEntityReference('DOCUMENT', 'default').name)
166 #set ($parentReference = $doc.documentReference.parent)
167 #if ($isNestedPage)
168 #set ($parentReference = $parentReference.parent)
169 #end
170 #locationPicker({
171 'id': 'renameApp',
172 'title': {
173 'label': 'appWithinMinutes.renameApp.newName.label',
174 'hint': 'platform.appwithinminutes.appNameHint',
175 'name': 'newAppName',
176 'value': $appName,
177 'placeholder': 'appWithinMinutes.renameApp.newName.label'
178 },
179 'preview': {
180 'label': 'appWithinMinutes.renameApp.location.label',
181 'hint': 'appWithinMinutes.renameApp.location.hint'
182 },
183 'parent': {
184 'label': 'appWithinMinutes.renameApp.parent.label',
185 'hint': 'appWithinMinutes.renameApp.parent.hint',
186 'name': 'newAppParentReference',
187 'reference': $parentReference,
188 'placeholder': 'appWithinMinutes.createApp.parent.placeholder'
189 }
190 })
191 #end
192 {{/velocity}}
193
194 {{velocity}}
195 #set ($liveTableObj = $doc.getObject('AppWithinMinutes.LiveTableClass'))
196 #if ($liveTableObj)
197 #set ($discard = $doc.use($liveTableObj))
198 #set ($classFullName = $doc.getValue('class'))
199 #if ("$!classFullName" == '' || !$xwiki.exists($classFullName))
200 {{warning}}
201 {{translation key="platform.appwithinminutes.appHomePageMovedWarning"/}}
202 {{/warning}}
203
204 #end
205 #displayApp()
206
207 {{html clean="false"}}
208 #renameAppModal()
209 {{/html}}
210 #end
211 {{/velocity}}