Wiki source code of Object Sheet
Last modified by admin admin on 2024/07/23 00:56
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{velocity}} | ||
| 2 | ## You can modify this page to customize the presentation of your object. | ||
| 3 | ## At first you should keep the default presentation and just save the document. | ||
| 4 | |||
| 5 | ## We have to use wiki=true because $doc.display() can produce wiki syntax. | ||
| 6 | {{html wiki="true" clean="false"}} | ||
| 7 | ## Load the JavaScript code required to make the object properties editable in-place. | ||
| 8 | #set ($discard = $xwiki.jsfx.use('uicomponents/edit/editableProperty.js', { | ||
| 9 | 'forceSkinAction': true, | ||
| 10 | 'language': $xcontext.locale | ||
| 11 | })) | ||
| 12 | #set ($editing = $xcontext.action == 'edit') | ||
| 13 | ## The object to display. | ||
| 14 | #set ($xobject = $doc.getObject('XWiki.MyClass')) | ||
| 15 | ## The class that describes the object properties. | ||
| 16 | #set ($xclass = $xobject.xWikiClass) | ||
| 17 | ## Make sure the following display* method calls use the right object. | ||
| 18 | #set ($discard = $doc.use($xobject)) | ||
| 19 | ## Using the xform vertical form layout. | ||
| 20 | <div class="xform"> | ||
| 21 | <dl> | ||
| 22 | #foreach ($property in $xclass.properties) | ||
| 23 | <dt #if (!$editing && $hasEdit) | ||
| 24 | class="editableProperty" | ||
| 25 | #set ($xobjectPropertyReference = $xobject.getPropertyReference($property.name)) | ||
| 26 | data-property="$escapetool.xml($services.model.serialize($xobjectPropertyReference))" | ||
| 27 | data-property-type="object"#end> | ||
| 28 | ## This must match the id generated by the $doc.display() method below. | ||
| 29 | #set ($propertyId = "${xclass.name}_${xobject.number}_$property.name") | ||
| 30 | <label#if ($editing) for="$escapetool.xml($propertyId)"#end> | ||
| 31 | $escapetool.xml($property.translatedPrettyName) | ||
| 32 | </label> | ||
| 33 | ## Support for specifying a translation key as hint in the property definition. | ||
| 34 | <span class="xHint">$!escapetool.xml($services.localization.render($property.hint))</span> | ||
| 35 | </dt> | ||
| 36 | <dd>$doc.display($property.name)</dd> | ||
| 37 | #end | ||
| 38 | #if (!$xclass.properties || $xclass.properties.size() == 0) | ||
| 39 | ## Keep the empty definition term in order to have valid HTML. | ||
| 40 | <dt></dt> | ||
| 41 | <dd>$escapetool.xml($services.localization.render('xclass.defaultObjectSheet.noProperties'))</dd> | ||
| 42 | #end | ||
| 43 | </dl> | ||
| 44 | </div> | ||
| 45 | {{/html}} | ||
| 46 | {{/velocity}} |