Changes for page Main
Last modified by Administrator on 2023/03/27 10:53
From version
2.1


edited by Administrator
on 2019/11/04 23:53
on 2019/11/04 23:53
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/10.11.9]
To version
8.1

edited by Administrator
on 2023/03/27 10:53
on 2023/03/27 10:53
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/14.10.7]
Summary
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 -#if( !$doc.name.endsWith('Sheet'))$services.localization.render('appWithinMinutes.classEditor.title', [$stringtool.removeEnd($doc.title, 'Class').trim()])#{else}$doc.name#end1 +#if ("$!appTitle" != '')$appTitle#else$doc.pageReference.name#end - Syntax
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki 2. 01 +XWiki 2.1 - Content
-
... ... @@ -1,3 +1,5 @@ 1 +{{include reference="AppWithinMinutes.VelocityMacros" /}} 2 + 1 1 {{groovy}} 2 2 import com.xpn.xwiki.XWikiContext; 3 3 import com.xpn.xwiki.api.Context; ... ... @@ -52,99 +52,102 @@ 52 52 #** 53 53 * Displays the field palette. 54 54 *# 55 -#macro(displayFieldPalette) 56 - (% id="palette" %) 57 - ((( 58 - **$services.localization.render('platform.appwithinminutes.classEditorPaletteTitle')** 59 - 60 - (% class="xHint" %) 61 - $services.localization.render('platform.appwithinminutes.classEditorPaletteHint') 62 - 57 +#macro (displayFieldPalette) 58 + <div id="palette"> 59 + <p><strong>$services.localization.render('platform.appwithinminutes.classEditorPaletteTitle')</strong></p> 60 + <p class="xHint">$services.localization.render('platform.appwithinminutes.classEditorPaletteHint')</p> 63 63 ## List all form field types, grouped by category. 64 - #set($formFieldDocs = []) 65 - #set($formFieldClassName = 'AppWithinMinutes.FormFieldClass') 66 - #set($categoryListStatement = 'from doc.object(AppWithinMinutes.FormFieldCategoryClass) as category order by category.priority') 67 - #foreach($category in $services.query.xwql($categoryListStatement).execute()) 68 - #set($categoryDoc = $xwiki.getDocument($category)) 69 - * (% class="category" %)$categoryDoc.plainTitle 70 - #set($formFieldsForCategoryStatement = "from doc.object($formFieldClassName) as field where field.category = :category order by field.priority") 71 - #set($formFieldsForCategoryQuery = $services.query.xwql($formFieldsForCategoryStatement).bindValue('category', $category)) 72 - #foreach($formField in $formFieldsForCategoryQuery.execute()) 73 - #set($formFieldDoc = $xwiki.getDocument($formField)) 74 - #set($discard = $formFieldDocs.add($formFieldDoc)) 75 - #set($formFieldIcon = $formFieldDoc.getObject($formFieldClassName).getProperty('icon').value) 76 - #set($formFieldIconRendered = $services.icon.renderHTML($formFieldIcon)) 62 + #set ($formFieldDocs = []) 63 + #set ($formFieldClassName = 'AppWithinMinutes.FormFieldClass') 64 + #set ($categoryListStatement = 'from doc.object(AppWithinMinutes.FormFieldCategoryClass) as category order by category.priority') 65 + <ul> 66 + #foreach ($category in $services.query.xwql($categoryListStatement).execute()) 67 + #set ($categoryDoc = $xwiki.getDocument($category)) 68 + <li> 69 + <div class="category">$escapetool.xml($categoryDoc.plainTitle)</div> 70 + #set ($formFieldsForCategoryStatement = "from doc.object($formFieldClassName) as field where field.category = :category order by field.priority") 71 + #set ($formFieldsForCategoryQuery = $services.query.xwql($formFieldsForCategoryStatement).bindValue('category', $category)) 72 + <ul> 73 + #foreach ($formField in $formFieldsForCategoryQuery.execute()) 74 + #set ($formFieldDoc = $xwiki.getDocument($formField)) 75 + #set ($discard = $formFieldDocs.add($formFieldDoc)) 76 + #set ($formFieldIcon = $formFieldDoc.getObject($formFieldClassName).getProperty('icon').value) 77 + #set ($formFieldIconRendered = $services.icon.renderHTML($formFieldIcon)) 77 77 #if ("$!formFieldIconRendered" == "") 78 - #if($formFieldIcon.contains('/')) 79 - #set($formFieldIconURL = $xwiki.getSkinFile($formFieldIcon)) 79 + #if ($formFieldIcon.contains('/')) 80 + #set ($formFieldIconURL = $xwiki.getSkinFile($formFieldIcon)) 80 80 #else 81 - #set($formFieldIconURL = $formFieldDoc.getAttachmentURL($formFieldIcon)) 82 + #set ($formFieldIconURL = $formFieldDoc.getAttachmentURL($formFieldIcon)) 82 82 #end 83 - #set($formFieldIconRendered = "<img src='$formFieldIconURL' alt='$escapetool.xml($formFieldDoc.plainTitle)' class='icon' />") 84 + #set ($formFieldIconRendered = "<img src='$escapetool.xml($formFieldIconURL)' alt='$escapetool.xml($formFieldDoc.plainTitle)' class='icon' />") 84 84 #end 85 - ** (% class="field" %){{html}} 86 - $formFieldIconRendered 87 - $escapetool.xml($formFieldDoc.plainTitle) 88 - ## FIXME: We should use the 'get' action instead to prevent the stats module from recording this AJAX request. 89 - ## The 'edit' action is a temporary solution until the sheet module is modified to allow a sheet to be enforced through 90 - ## the query string even if it doesn't match the action (e.g. the 'get' action). 91 - ## The sheet parameter is required when editing a new class because the request will be made to a document that doesn't exist. 92 - ## FIXME2: In the future don't force the text editor type and instead use the default editor. This means 93 - ## that if the WYSIWYG editor is used, we'll need to convert the HTML into the target syntax so that the 94 - ## Template in #updateAndSaveTemplate is saved with target syntax and not HTML. 95 - ## See https://jira.xwiki.org/browse/XWIKI-13789 96 - <input type="hidden" value="$doc.getURL('edit', "xpage=plain&sheet=AppWithinMinutes.ClassEditSheet&field=$escapetool.url($formFieldDoc.fullName)&xeditmode=text")" class="data"/> 97 - {{/html}} 86 + <li class="field"> 87 + $formFieldIconRendered 88 + $escapetool.xml($formFieldDoc.plainTitle) 89 + ## FIXME: We should use the 'get' action instead to prevent the stats module from recording this AJAX request. 90 + ## The 'edit' action is a temporary solution until the sheet module is modified to allow a sheet to be enforced through 91 + ## the query string even if it doesn't match the action (e.g. the 'get' action). 92 + ## The sheet parameter is required when editing a new class because the request will be made to a document that doesn't exist. 93 + ## FIXME2: In the future don't force the text editor type and instead use the default editor. This means 94 + ## that if the WYSIWYG editor is used, we'll need to convert the HTML into the target syntax so that the 95 + ## Template in #updateAndSaveTemplate is saved with target syntax and not HTML. 96 + ## See https://jira.xwiki.org/browse/XWIKI-13789 97 + #set ($fieldURL = $doc.getURL('edit', $escapetool.url({ 98 + 'xpage': 'plain', 99 + 'sheet': 'AppWithinMinutes.ClassEditSheet', 100 + 'form_token': $services.csrf.getToken(), 101 + 'template': 'AppWithinMinutes.ClassTemplate', 102 + 'field': $formFieldDoc.fullName, 103 + 'xeditmode': 'text' 104 + }))) 105 + <input type="hidden" value="$escapetool.xml($fieldURL)" class="data"/> 106 + </li> 98 98 #end 108 + </ul> 109 + </li> 99 99 #end 100 - ))) 111 + </ul> 112 + </div> 101 101 #end 102 102 103 103 #** 104 104 * Displays the field canvas. 105 105 *# 106 -#macro(displayFieldCanvas) 107 - #set($propertyType2FormField = {}) 108 - #foreach($formFieldDoc in $formFieldDocs) 118 +#macro (displayFieldCanvas) 119 + #set ($propertyType2FormField = {}) 120 + #foreach ($formFieldDoc in $formFieldDocs) 109 109 ## Use the type of the field template. 110 - #set($type = $formFieldDoc.getxWikiClass().properties.get(0).classType) 111 - #set($discard = $propertyType2FormField.put($type, $formFieldDoc)) 122 + #set ($type = $formFieldDoc.getxWikiClass().properties.get(0).classType) 123 + #set ($discard = $propertyType2FormField.put($type, $formFieldDoc)) 112 112 #end 113 - (% id="canvas" %) 114 - ((( 115 - (% class="hint" %) 116 - $services.localization.render('platform.appwithinminutes.classEditorCanvasHint') 117 - 118 - #set($unknownFields = []) 119 - #set($empty = true) 120 - #foreach ($field in $doc.getxWikiClass().properties) 121 - #set($formFieldDoc = $propertyType2FormField.get($field.classType)) 122 - #if($formFieldDoc) 123 - #set($empty = false) 124 - * (((#displayField($field $formFieldDoc)))) 125 - #else 126 - #set($discard = $unknownFields.add($field)) 125 + <div id="canvas"> 126 + <p class="hint"> 127 + $services.localization.render('platform.appwithinminutes.classEditorCanvasHint') 128 + </p> 129 + <ul> 130 + #set ($unknownFields = []) 131 + #foreach ($field in $doc.getxWikiClass().properties) 132 + #set ($formFieldDoc = $propertyType2FormField.get($field.classType)) 133 + #if ($formFieldDoc) 134 + <li>#displayField($field $formFieldDoc)</li> 135 + #else 136 + #set($discard = $unknownFields.add($field)) 137 + #end 127 127 #end 128 - #end 129 - #if(!$empty) 130 - ## Leave an empty line to separate the blocks. 131 - 132 - #end 133 - ## 134 - (% class="hidden" %) 135 - {{html}} 139 + </ul> 140 + <div class="hidden"> 136 136 ## Output the field meta data even if the field is not supported to preserve it when the class is saved. 137 - #foreach($field in $unknownFields) 142 + #foreach ($field in $unknownFields) 138 138 #displayFieldMetaData($field) 139 139 #end 140 - {{/html}}141 - )))145 + </div> 146 + </div> 142 142 #end 143 143 144 144 #** 145 145 * Display the options to create/update the class template, the class sheet and the class translation bundle. 146 146 *# 147 -#macro(displayClassOptions) 152 +#macro (displayClassOptions) 148 148 #set ($className = $stringtool.removeEnd($doc.fullName, 'Class')) 149 149 #set ($templateReference = $services.model.resolveDocument("${className}Template")) 150 150 #set ($translationsReference = $services.model.resolveDocument("${className}Translations")) ... ... @@ -155,7 +155,6 @@ 155 155 #elseif ($classSheets.size() == 1) 156 156 #set ($sheetReference = $classSheets.get(0)) 157 157 #end 158 - {{html}} 159 159 ## Hide the options if neither the sheet nor the template nor the translation bundle exists. They don't have to be 160 160 ## updated, they have to be created. 161 161 <dl id="options" #if (!$xwiki.exists($sheetReference) && !$xwiki.exists($templateReference) ... ... @@ -204,7 +204,6 @@ 204 204 </span> 205 205 </dd> 206 206 </dl> 207 - {{/html}} 208 208 #end 209 209 210 210 #macro (pageLink $reference) ... ... @@ -216,25 +216,21 @@ 216 216 #set ($action = 'create') 217 217 #set ($discard = $params.put('parent', $doc.fullName)) 218 218 #end 219 - <span class="$class">## 220 - <a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))">## 221 - $escapetool.xml($reference.name)## 222 - </a>## 223 - </span>## 222 + <span class="$class"><a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))" 223 + >$escapetool.xml($reference.name)</a></span>## 224 224 #end 225 225 226 226 #** 227 227 * Display a form field. 228 228 *# 229 -#macro(displayField $field $formFieldDoc) 230 - #if($formFieldDoc.getObject('XWiki.StyleSheetExtension')) 231 - #set($discard = $xwiki.ssx.use($formFieldDoc.fullName)) 229 +#macro (displayField $field $formFieldDoc) 230 + #if ($formFieldDoc.getObject('XWiki.StyleSheetExtension')) 231 + #set ($discard = $xwiki.ssx.use($formFieldDoc.fullName)) 232 232 #end 233 - #if($formFieldDoc.getObject('XWiki.JavaScriptExtension')) 234 - #set($discard = $xwiki.jsx.use($formFieldDoc.fullName)) 233 + #if ($formFieldDoc.getObject('XWiki.JavaScriptExtension')) 234 + #set ($discard = $xwiki.jsx.use($formFieldDoc.fullName)) 235 235 #end 236 - (% class="hidden" %) 237 - {{html}} 236 + <div class="hidden"> 238 238 #displayFieldMetaData($field) 239 239 ## We need this information to avoid querying and loading all FormField documents twice. 240 240 ## NOTE: We use a different ID format to avoid collisions with the field meta properties. ... ... @@ -241,35 +241,35 @@ 241 241 <input type="hidden" id="template-$field.name" name="template-$field.name" 242 242 value="$escapetool.xml($formFieldDoc.fullName)" 243 243 data-propertyName="$escapetool.xml($formFieldDoc.getxWikiClass().propertyNames[0])" /> 244 - {{/html}} 245 - 246 - #set($className = $stringtool.removeEnd($doc.fullName, 'Class')) 247 - #set($templateRef = $services.model.resolveDocument("${className}Template")) 248 - #set($templateDoc = $xwiki.getDocument($templateRef)) 243 + </div> 244 + #set ($className = $stringtool.removeEnd($doc.fullName, 'Class')) 245 + #set ($templateRef = $services.model.resolveDocument("${className}Template")) 246 + #set ($templateDoc = $xwiki.getDocument($templateRef)) 249 249 ## Simulate the editing of the class instance from the template document. 250 250 ## Note that we can't simply call display on the template document because $field could be a new field that hasn't 251 251 ## been added to the class yet (so the object from the template doesn't have this field yet). 252 - (% class="field-viewer" %) 253 - #displayFieldProperty($field "${doc.fullName}_0_" $templateDoc.getObject($doc.fullName, true)) 254 - 255 - #set($propertyNames = ['name', 'prettyName', 'number', 'required', 'hint']) 256 - #set($formFieldObj = $formFieldDoc.getObject('AppWithinMinutes.FormFieldClass')) 257 - #set($customPropertyNames = $formFieldObj.getProperty('properties').value.split('\s+')) 258 - #set($discard = $customPropertyNames.removeAll($propertyNames)) 259 - #set($discard = $propertyNames.addAll($customPropertyNames.subList(0, $customPropertyNames.size()))) 260 - (% class="field-config" %) 261 - #foreach($propertyName in $propertyNames) 262 - #set($propertyDefinition = $field.xWikiClass.get($propertyName)) 263 - #if($propertyDefinition) 264 - #displayFieldProperty($propertyDefinition "field-${field.name}_" $field) 250 + <dl class="field-viewer"> 251 + #displayFieldProperty($field "${doc.fullName}_0_" $templateDoc.getObject($doc.fullName, true)) 252 + </dl> 253 + #set ($propertyNames = ['name', 'prettyName', 'number', 'required', 'hint']) 254 + #set ($formFieldObj = $formFieldDoc.getObject('AppWithinMinutes.FormFieldClass')) 255 + #set ($customPropertyNames = $formFieldObj.getProperty('properties').value.split('\s+')) 256 + #set ($discard = $customPropertyNames.removeAll($propertyNames)) 257 + #set ($discard = $propertyNames.addAll($customPropertyNames.subList(0, $customPropertyNames.size()))) 258 + <dl class="field-config"> 259 + #foreach ($propertyName in $propertyNames) 260 + #set ($propertyDefinition = $field.xWikiClass.get($propertyName)) 261 + #if ($propertyDefinition) 262 + #displayFieldProperty($propertyDefinition "field-${field.name}_" $field) 263 + #end 265 265 #end 266 - #end265 + </dl> 267 267 #end 268 268 269 269 #** 270 270 * Display the field meta data. This is needed to preserve the field when its type is not supported by the editor. 271 271 *# 272 -#macro(displayFieldMetaData $field) 271 +#macro (displayFieldMetaData $field) 273 273 <input type="hidden" id="type-$field.name" name="type-$field.name" value="$field.classType" /> 274 274 #end 275 275 ... ... @@ -276,13 +276,18 @@ 276 276 #** 277 277 * Displays a configuration property of a class field. This macro can also be used to display a property of an object. 278 278 *# 279 -#macro(displayFieldProperty $property $prefix $field) 280 - #set($displayFormType = $property.getProperty('displayFormType')) 281 - #if($property.classType == 'Boolean' && (!$displayFormType || $displayFormType.value == 'checkbox')) 282 - ; {{html clean="false"}}<label for="$!{prefix}$property.name">#displayPropertyEditInput($property, $prefix, $field)$escapetool.xml($property.prettyName)</label>{{/html}} 278 +#macro (displayFieldProperty $property $prefix $field) 279 + #set ($displayFormType = $property.getProperty('displayFormType')) 280 + #if ($property.classType == 'Boolean' && (!$displayFormType || $displayFormType.value == 'checkbox')) 281 + <dt> 282 + <label for="$!{prefix}$property.name"> 283 + #displayPropertyEditInput($property, $prefix, $field)$escapetool.xml($property.prettyName) 284 + </label> 285 + </dt> 286 + <dd></dd> 283 283 #else 284 - ; {{html}}<label for="${prefix}$property.name">$escapetool.xml($property.prettyName)</label>{{/html}}285 - : {{html clean="false"}}#displayPropertyEditInput($property, $prefix, $field){{/html}}288 + <dt><label for="${prefix}$property.name">$escapetool.xml($property.prettyName)</label></dt> 289 + <dd>#displayPropertyEditInput($property, $prefix, $field)</dd> 286 286 #end 287 287 #end 288 288 ... ... @@ -289,12 +289,18 @@ 289 289 #** 290 290 * Displays the input used to edit the specified property of the given object. The given object can be either an 291 291 * instance of an XWiki class or a class field. In the first case the property represents an object field and in the 292 - * second case the property represents a field meta property. 296 + * second case the property represents a field meta property. We currently don't use custom display for metaproperty, 297 + * so in that case we fallback on displayEdit. 293 293 *# 294 -#macro(displayPropertyEditInput $property $prefix $object) 295 - #set($wrappedProperty = $property.propertyClass) 296 - #if($wrappedProperty.isCustomDisplayed($xcontext.context)) 297 - $xcontext.get('propertyCustomDisplayer').display($property, $prefix, $object) 299 +#macro (displayPropertyEditInput $property $prefix $object) 300 + #set ($wrappedProperty = $property.propertyClass) 301 + #if ($wrappedProperty.isCustomDisplayed($xcontext.context)) 302 + #set ($customDisplayer = $!xcontext.get('propertyCustomDisplayer').display($property, $prefix, $object)) 303 + #if ((! $customDisplayer) && ("$!customDisplayer" == "")) 304 + $doc.displayEdit($property, $prefix, $object) 305 + #else 306 + $customDisplayer 307 + #end 298 298 #else 299 299 $doc.displayEdit($property, $prefix, $object) 300 300 #end ... ... @@ -303,26 +303,23 @@ 303 303 #** 304 304 * Called when a new form field is added via AJAX. 305 305 *# 306 -#macro(displayNewField) 316 +#macro (displayNewField) 307 307 ## Output the SkinExtension hooks to allow field displayers to pull JavaScript/CSS resources. 308 308 ## Output also the LinkExtension hook because $xwiki.linkx.use() is used to load CSS files from WebJars. 309 309 ## The class editor moves this resource includes in the HTML page head. 310 - {{html}} 311 311 <!-- com.xpn.xwiki.plugin.skinx.LinkExtensionPlugin --> 312 312 #skinExtensionHooks 313 - {{/html}} 314 - 315 - #set($formFieldDoc = $xwiki.getDocument($request.field)) 316 - #set($formFieldDocClassFields = $formFieldDoc.getxWikiClass().getXWikiClass().properties) 317 - #if($formFieldDocClassFields.size() > 0) 322 + #set ($formFieldDoc = $xwiki.getDocument($request.field)) 323 + #set ($formFieldDocClassFields = $formFieldDoc.getxWikiClass().getXWikiClass().properties) 324 + #if ($formFieldDocClassFields.size() > 0) 318 318 ## Clone the field template. 319 - #set($field = $formFieldDocClassFields.get(0).clone()) 320 - #if("$!field.prettyName" == '') 321 - #set($discard = $field.setPrettyName($formFieldDoc.title)) 326 + #set ($field = $formFieldDocClassFields.get(0).clone()) 327 + #if ("$!field.prettyName" == '') 328 + #set ($discard = $field.setPrettyName($formFieldDoc.title)) 322 322 #end 323 - #set($xclass = $doc.getxWikiClass().getXWikiClass()) 324 - #set($discard = $xclass.addField($field.name, $field)) 325 - #set($discard = $field.setObject($xclass)) 330 + #set ($xclass = $doc.getxWikiClass().getXWikiClass()) 331 + #set ($discard = $xclass.addField($field.name, $field)) 332 + #set ($discard = $field.setObject($xclass)) 326 326 #displayField($doc.getxWikiClass().get($field.name) $formFieldDoc) 327 327 #else 328 328 Unsupported form field. ... ... @@ -332,87 +332,90 @@ 332 332 #** 333 333 * Preview a class field (requires Programming Right). 334 334 *# 335 -#macro(previewField) 342 +#macro (previewField) 336 336 ## Find the request parameter that specifies the field template. 337 - #foreach($paramName in $request.getParameterMap().keySet()) 338 - #if($paramName.startsWith('template-')) 339 - #set($fieldName = $paramName.substring(9)) 340 - #set($fieldTemplateDoc = $xwiki.getDocument($request.getParameter($paramName))) 344 + #foreach ($paramName in $request.getParameterMap().keySet()) 345 + #if ($paramName.startsWith('template-')) 346 + #set ($fieldName = $paramName.substring(9)) 347 + #set ($fieldTemplateDoc = $xwiki.getDocument($request.getParameter($paramName))) 341 341 #break 342 342 #end 343 343 #end 344 344 ## 345 345 ## Clone the field template. 346 - #set($field = $fieldTemplateDoc.getxWikiClass().getXWikiClass().properties.get(0).clone()) 353 + #set ($field = $fieldTemplateDoc.getxWikiClass().getXWikiClass().properties.get(0).clone()) 347 347 ## 348 348 ## Update the field meta properties based on the submitted data. 349 - #set($valuesFromRequest = $xcontext.context.getForm().getObject("field-$fieldName")) 350 - #set($discard = $field.getxWikiClass().fromMap($valuesFromRequest, $field)) 356 + #set ($valuesFromRequest = $xcontext.context.getForm().getObject("field-$fieldName")) 357 + #set ($discard = $field.getxWikiClass().fromMap($valuesFromRequest, $field)) 351 351 ## 352 352 ## Don't rename the field (ignore the submitted name). 353 - #set($discard = $field.setName($fieldName)) 360 + #set ($discard = $field.setName($fieldName)) 354 354 ## 355 355 ## We have to add the field to the class before setting its value. 356 356 ## (otherwise the field value from the request is ignored). 357 - #set($xclass = $doc.getxWikiClass().getXWikiClass()) 358 - #set($discard = $xclass.addField($fieldName, $field)) 359 - #set($discard = $field.setObject($xclass)) 364 + #set ($xclass = $doc.getxWikiClass().getXWikiClass()) 365 + #set ($discard = $xclass.addField($fieldName, $field)) 366 + #set ($discard = $field.setObject($xclass)) 360 360 ## 361 361 ## Create an object that has this field and set its value from request. 362 - #set($object = $fieldTemplateDoc.getObject($doc.fullName, true)) 369 + #set ($object = $fieldTemplateDoc.getObject($doc.fullName, true)) 363 363 ## 364 364 ## Filter empty values from the request, otherwise the update method could try to select an invalid value. 365 - #set($values = []) 366 - #foreach($value in $request.getParameterValues("${doc.fullName}_0_$fieldName")) 367 - #if($value != '') 368 - #set($discard = $values.add($value)) 372 + #set ($values = []) 373 + #foreach ($value in $request.getParameterValues("${doc.fullName}_0_$fieldName")) 374 + #if ($value != '') 375 + #set ($discard = $values.add($value)) 369 369 #end 370 370 #end 371 - #if($values.size() > 0) 372 - #set($stringArray = $request.getParameterValues("template-$fieldName")) 373 - #set($discard = $xclass.fromMap({$fieldName: $values.toArray($stringArray)}, $object.getXWikiObject())) 378 + #if ($values.size() > 0) 379 + #set ($stringArray = $request.getParameterValues("template-$fieldName")) 380 + #set ($discard = $xclass.fromMap({$fieldName: $values.toArray($stringArray)}, $object.getXWikiObject())) 374 374 #end 375 375 ## 376 376 ## Display the field. 377 - #set($field = $doc.getxWikiClass().get($fieldName)) 378 - {{html clean="false"}}#displayPropertyEditInput($field, "${doc.fullName}_0_", $object){{/html}}384 + #set ($field = $doc.getxWikiClass().get($fieldName)) 385 + #displayPropertyEditInput($field, "${doc.fullName}_0_", $object) 379 379 #end 380 380 381 381 #** 382 382 * Display the edit class form. 383 383 *# 384 -#macro(displayEditForm) 385 - $xwiki.jsfx.use('js/scriptaculous/dragdrop.js')## 386 - $xwiki.jsx.use('AppWithinMinutes.ClassEditSheet')## 387 - $xwiki.ssx.use('AppWithinMinutes.ClassEditSheet')## 388 - $xwiki.ssx.use('AppWithinMinutes.ClassSheetGenerator')## 389 - #if("$!request.wizard" == 'true') 391 +#macro (displayEditForm) 392 + #set ($discard = $xwiki.jsx.use('AppWithinMinutes.ClassEditSheet')) 393 + #set ($discard = $xwiki.ssx.use('AppWithinMinutes.ClassEditSheet')) 394 + #set ($discard = $xwiki.ssx.use('AppWithinMinutes.ClassSheetGenerator')) 395 + #if ("$!request.wizard" == 'true') 390 390 #appWizardHeader('structure') 391 - 392 392 #end 393 393 #displayFieldPalette() 394 394 #displayFieldCanvas() 395 395 #displayClassOptions() 396 396 #if("$!request.wizard" == 'true') 397 - 398 398 #appWizardFooter('structure') 399 399 #end 400 - (%class="clearfloats"%)((()))404 + <div class="clearfloats"></div> 401 401 #end 402 402 403 403 #** 404 404 * Displays either the edit class form or a new form field. The later is used when adding a new form field via AJAX. 405 405 *# 406 -#macro(doEdit) 407 - #if("$!request.field" != '') 410 +#macro (doEdit) 411 + #if ("$!request.field" != '') 408 408 #displayNewField() 409 - #elseif("$!request.preview" == 'true') 413 + #elseif ("$!request.preview" == 'true') 410 410 #previewField() 411 411 #else 412 412 ## Make sure that only the sheet content is rendered when the class is saved using AJAX. 413 - (% class="hidden" %) 414 - {{html}}<input type="hidden" name="xpage" value="plain" />{{/html}} 415 - 417 + <div class="hidden"> 418 + <input type="hidden" name="xpage" value="plain" /> 419 + #if ($request.wizard == 'true') 420 + ## Preserve the wizard mode. 421 + <input type="hidden" name="wizard" value="true" /> 422 + #end 423 + ## Compute the application title to be used as the wizard step title. 424 + #getAppTitle 425 + </div> 416 416 #displayEditForm() 417 417 #end 418 418 #end ... ... @@ -428,10 +428,7 @@ 428 428 #try() 429 429 #set ($discard = $copyAsJob.join()) 430 430 #set ($copyAsJobStatus = $services.job.getJobStatus($copyAsJob.request.id)) 431 - #set ($errorLogs = $copyAsJobStatus.log.getLogs('ERROR')) 432 - #if ($errorLogs.size() > 0) 433 - #set ($errorMessage = $errorLogs.get(0).toString()) 434 - #end 441 + #set ($errorMessage = $copyAsJobStatus.logTail.getFirstLogEvent('ERROR').toString()) 435 435 #end 436 436 #end 437 437 #end ... ... @@ -570,7 +570,7 @@ 570 570 #set($className = $stringtool.removeEnd($doc.fullName, 'Class')) 571 571 #set($templateRef = $services.model.resolveDocument("${className}Template")) 572 572 #set($templateDoc = $xwiki.getDocument($templateRef)) 573 - #set($discard = $templateDoc.setParent($doc.name)) 580 + #set($discard = $templateDoc.setParent($doc.documentReference.name)) 574 574 #if ($request.templateTitle) 575 575 #set($discard = $templateDoc.setTitle($request.templateTitle)) 576 576 #end ... ... @@ -608,9 +608,13 @@ 608 608 #if($sheetReference) 609 609 #set($sheetDoc = $xwiki.getDocument($sheetReference)) 610 610 #set($sheetGeneratorDoc = $xwiki.getDocument('AppWithinMinutes.ClassSheetGenerator')) 611 - #set($discard = $sheetDoc.setParent($doc.name)) 618 + #set($discard = $sheetDoc.setParent($doc.documentReference.name)) 612 612 #set($discard = $sheetDoc.setContent($doc.getRenderedContent($sheetGeneratorDoc.content, 613 613 $sheetGeneratorDoc.syntax.toIdString(), 'plain/1.0'))) 621 + ## We assume for now that the output produced by the sheet generator uses the same syntax as the code of the sheet 622 + ## generator. We have to set the syntax because the default wiki syntax (used when creating new wiki pages) could 623 + ## be different than the one used by the sheet generator. 624 + #set($discard = $sheetDoc.setSyntax($sheetGeneratorDoc.syntax)) 614 614 #set($discard = $sheetDoc.setHidden(true)) 615 615 #set($discard = $sheetDoc.save($services.localization.render('platform.appwithinminutes.classEditorSheetSaveComment'), 616 616 $minorEdit)) ... ... @@ -632,10 +632,11 @@ 632 632 #set ($scope = 'WIKI') 633 633 #end 634 634 #set($discard = $translationsObj.set('scope', $scope)) 635 - #set($discard = $translationsDoc.setParent($doc.name)) 646 + #set($discard = $translationsDoc.setParent($doc.documentReference.name)) 636 636 #set($translationsGeneratorDoc = $xwiki.getDocument('AppWithinMinutes.ClassTranslationsGenerator')) 637 637 #set($discard = $translationsDoc.setContent($doc.getRenderedContent($translationsGeneratorDoc.content, 638 638 $translationsGeneratorDoc.syntax.toIdString(), 'plain/1.0'))) 650 + #set($discard = $translationsDoc.setSyntaxId('plain/1.0')) 639 639 #set($discard = $translationsDoc.setHidden(true)) 640 640 #set($discard = $translationsDoc.save( 641 641 $services.localization.render('platform.appwithinminutes.classEditorTranslationsSaveComment'), ... ... @@ -646,17 +646,17 @@ 646 646 #** 647 647 * Updates and saves the class definition, the class sheet and the class template. 648 648 *# 649 -#macro(doSave) 650 - #set($minorEdit = "$!request.minorEdit" != '') 661 +#macro (doSave) 662 + #set ($minorEdit = "$!request.minorEdit" != '') 651 651 #maybeCreateCodeSpace 652 652 #updateAndSaveClass 653 653 #updateAndSaveTemplate 654 654 #updateAndSaveSheet 655 655 #updateAndSaveTranslations 656 - #if($action == 'save') 657 - #if($errorMessage) 658 - {{error}}{{html}}$errorMessage{{/html}}{{/error}}659 - #elseif("$!request.wizard" == 'true') 668 + #if ($action == 'save') 669 + #if ($errorMessage) 670 + <div class="box errormessage">$errorMessage</div> 671 + #elseif ("$!request.wizard" == 'true') 660 660 ## Redirect to next wizard step. 661 661 #set ($className = $stringtool.removeEnd($doc.fullName, 'Class')) 662 662 #set ($templateProviderReference = $services.model.resolveDocument("${className}TemplateProvider")) ... ... @@ -666,6 +666,7 @@ 666 666 }) 667 667 #if (!$xwiki.exists($templateProviderReference)) 668 668 #set ($discard = $queryString.putAll({ 681 + 'form_token': $services.csrf.getToken(), 669 669 'template': 'XWiki.TemplateProviderTemplate', 670 670 'parent': $doc.fullName 671 671 })) ... ... @@ -676,7 +676,7 @@ 676 676 $response.sendRedirect($doc.getURL()) 677 677 #end 678 678 #else 679 - #if($errorMessage) 692 + #if ($errorMessage) 680 680 $response.sendError(400, $errorMessage) 681 681 #else 682 682 $response.setStatus(204) ... ... @@ -692,21 +692,23 @@ 692 692 {{/velocity}} 693 693 694 694 {{velocity}} 708 +{{html clean="false"}} 695 695 ## Determine the action button that triggered the request 696 -#set($action = 'edit') 697 -#foreach($paramName in $request.getParameterMap().keySet()) 698 - #if($paramName.startsWith('xaction_')) 699 - #set($action = $paramName.substring(8)) 710 +#set ($action = 'edit') 711 +#foreach ($paramName in $request.getParameterMap().keySet()) 712 + #if ($paramName.startsWith('xaction_')) 713 + #set ($action = $paramName.substring(8)) 700 700 #break 701 701 #end 702 702 #end 703 -#if($action == 'edit') 717 +#if ($action == 'edit') 704 704 #doEdit() 705 -#elseif($action == 'save' || $action == 'saveandcontinue') 706 - #if($services.csrf.isTokenValid($request.form_token)) 719 +#elseif ($action == 'save' || $action == 'saveandcontinue') 720 + #if ($services.csrf.isTokenValid($request.form_token)) 707 707 #doSave() 708 708 #else 709 - $response.sendRedirect($services.csrf.getResubmissionURL()) ;723 + $response.sendRedirect($services.csrf.getResubmissionURL()) 710 710 #end 711 711 #end 726 +{{/html}} 712 712 {{/velocity}}
- XWiki.JavaScriptExtension[2]
-
- Code
-
... ... @@ -515,15 +515,11 @@ 515 515 }(XWiki || {})); 516 516 517 517 (function() { 518 - function init() { 519 - var form = $('inline'); 520 - if (!form) { 521 - return false; 522 - } 523 - // Let the sheet handle the form submit. 524 - // NOTE: The code that handles Save&Continue uses this URL to make the AJAX request and Firefox 3.6 doesn't resolve 525 - // the empty string to the current page URL so we have to explicitly specify it. 526 - form.action = window.location.href; 518 + function initForm(form) { 519 + // Let the sheet handle the form submit. The form is submitted by default to the preview action which dispatches the 520 + // request to the save action if the save button is detected on the request parameters. By submitting to the edit 521 + // action the edit sheet is evaluated and thus it can handle the save by itself. 522 + form.action = XWiki.currentDocument.getURL('edit'); 527 527 528 528 // Apply the vertical form layout standard. 529 529 form.addClassName('xform'); ... ... @@ -557,9 +557,18 @@ 557 557 // Make the palette and the canvas live. 558 558 new XWiki.FormFieldPalette('palette'); 559 559 new XWiki.FormCanvas('canvas'); 556 + } 560 560 561 - return true; 558 + function init() { 559 + var form = $('inline'); 560 + if (form) { 561 + require(['scriptaculous/dragdrop'], function() { 562 + initForm(form); 563 + }); 564 + } 565 + return form; 562 562 } 567 + 563 563 (XWiki.domIsLoaded && init()) || document.observe('xwiki:dom:loaded', init); 564 564 }).call(); 565 565