Changes for page LiveTableEditSheet
Last modified by Administrator on 2024/02/03 10:14
From version
2.1


edited by Administrator
on 2020/01/07 18:45
on 2020/01/07 18:45
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/11.10.2]
To version
4.1


edited by Administrator
on 2022/12/28 19:36
on 2022/12/28 19:36
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/14.10.2]
Summary
Details
- Page properties
-
- Content
-
... ... @@ -170,7 +170,6 @@ 170 170 {{html clean="false"}} 171 171 #set ($liveTableObj = $doc.getObject('AppWithinMinutes.LiveTableClass', true)) 172 172 #set ($discard = $doc.use($liveTableObj)) 173 - #set ($discard = $xwiki.jsfx.use('js/scriptaculous/dragdrop.js')) 174 174 #set ($discard = $xwiki.ssx.use('AppWithinMinutes.LiveTableEditSheet')) 175 175 #set ($discard = $xwiki.jsx.use('AppWithinMinutes.LiveTableEditSheet')) 176 176 #if ("$!request.wizard" == 'true') ... ... @@ -194,7 +194,9 @@ 194 194 ## Grant space administration rights only if the space is new. Don't overwrite existing space preferences. 195 195 #set ($spaceHomeRef = $services.model.resolveDocument('', 'default', $spaceRef)) 196 196 #set ($spacePrefsRef = $services.model.resolveDocument('WebPreferences', 'explicit', $spaceRef)) 197 - #if (!$xwiki.exists($spaceHomeRef) && !$xwiki.exists($spacePrefsRef)) 196 + ## Verify that the current user has script right on the current space home. 197 + #set ($hasScript = $services.security.authorization.hasAccess('script', $xcontext.userReference, $spaceHomeRef)) 198 + #if ($hasScript && !$xwiki.exists($spaceHomeRef) && !$xwiki.exists($spacePrefsRef)) 198 198 #set ($spacePrefsDoc = $xwiki.getDocument($spacePrefsRef)) 199 199 #set ($discard = $spacePrefsDoc.use($spacePrefsDoc.getObject('XWiki.XWikiGlobalRights', true))) 200 200 #set ($discard = $spacePrefsDoc.set('allow', 1)) ... ... @@ -228,7 +228,10 @@ 228 228 #set ($displayParameters = $services.display.createDocumentDisplayerParameters()) 229 229 #set ($discard = $displayParameters.setExecutionContextIsolated(false)) 230 230 #set ($discard = $displayParameters.setContentTranslated(true)) 231 - #set ($generatedLiveTableContent = $services.display.content($liveTableGeneratorDoc, { 'outputSyntaxId' : 'plain/1.0', 'displayerParameters' : $displayParameters })) 232 + #set ($generatedLiveTableContent = $services.display.content($liveTableGeneratorDoc, { 233 + 'outputSyntaxId': 'plain/1.0', 234 + 'displayerParameters': $displayParameters 235 + })) 232 232 233 233 ## Use the generated LiveTable content for the data home page. 234 234 #set ($dataSpaceReference = $services.model.resolveSpace($doc.getValue('dataSpace'))) ... ... @@ -254,6 +254,10 @@ 254 254 #set ($discard = $doc.setContent($homePageContent)) 255 255 #end 256 256 #set ($discard = $dataHomePage.setContent($generatedLiveTableContent)) 261 + ## We assume for now that the output produced by the live table generator uses the same syntax as the code of the live 262 + ## table generator. We have to set the syntax because the default wiki syntax (used when creating new wiki pages) 263 + ## could be different than the one used by the live table generator. 264 + #set ($discard = $dataHomePage.setSyntax($liveTableGeneratorDoc.syntax)) 257 257 258 258 #set ($minorEdit = "$!request.minorEdit" != '') 259 259 #set ($comment = $request.comment) ... ... @@ -309,6 +309,10 @@ 309 309 {{/velocity}} 310 310 311 311 {{velocity}} 320 +#if (!$services.security.authorization.hasAccess('script', $xcontext.userReference, $doc.documentReference)) 321 + {{error}}{{translation key="platform.appwithinminutes.appHomePageNoScriptRight" /}}{{/error}} 322 + 323 +#end 312 312 #if ("$!request.wizard" == 'true') 313 313 {{include reference="AppWithinMinutes.WizardStep" /}} 314 314 #end
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -121,11 +121,7 @@ 121 121 } 122 122 }); 123 123 124 -function init() { 125 - var form = $('inline'); 126 - if (!form) { 127 - return false; 128 - } 124 +function initForm(form) { 129 129 // Let the sheet handle the form submit. The form is submitted by default to the preview action which dispatches the 130 130 // request to the save action if the save button is detected on the request parameters. By submitting to the edit 131 131 // action the edit sheet is evaluated and thus it can handle the save by itself. ... ... @@ -154,9 +154,18 @@ 154 154 }.bindAsEventListener(window)); 155 155 156 156 new XWiki.LiveTableEditor(); 153 +} 157 157 158 - return true; 155 +function init() { 156 + var form = $('inline'); 157 + if (form) { 158 + require(['scriptaculous/dragdrop'], function() { 159 + initForm(form); 160 + }); 161 + } 162 + return form; 159 159 } 164 + 160 160 (XWiki.domIsLoaded && init()) || document.observe('xwiki:dom:loaded', init); 161 161 162 162 // Allow widgets to catch the save event before the form is submitted when the 'Save & Continue' button is clicked. We