Code source wiki de TemplateProviderMacros
Version 1.1 par superadmin le 2022/06/20 08:48
Afficher les derniers auteurs
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{template name="hierarchy_macros.vm" /}} | ||
| 2 | |||
| 3 | {{velocity output="false"}} | ||
| 4 | #set ($isEditing = $xcontext.action == 'edit') | ||
| 5 | |||
| 6 | #macro (displayPropertyValue $property $action) | ||
| 7 | #if ($action) | ||
| 8 | #set ($output = $doc.display($property, $action)) | ||
| 9 | #else | ||
| 10 | #set ($output = $doc.display($property)) | ||
| 11 | #end | ||
| 12 | #set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}')) | ||
| 13 | #set ($output = $stringtool.removeEnd($output, '{{/html}}')) | ||
| 14 | $output | ||
| 15 | #end | ||
| 16 | |||
| 17 | #macro (displayPathsPropertyValue $property) | ||
| 18 | <ul class="paths"> | ||
| 19 | #set ($hierarchyOptions = { | ||
| 20 | 'local': true, | ||
| 21 | 'selfIsActive': false | ||
| 22 | }) | ||
| 23 | #set ($paths = $doc.getValue($property)) | ||
| 24 | #foreach ($path in $paths) | ||
| 25 | <li class="path"> | ||
| 26 | #if ($isEditing) | ||
| 27 | <a href="#path-delete" class="path-delete">$services.icon.renderHTML('delete')</a> | ||
| 28 | <input type="hidden" name="XWiki.TemplateProviderClass_0_$property" | ||
| 29 | value="$escapetool.xml($path)" /> | ||
| 30 | #end | ||
| 31 | #set ($spaceReference = $services.model.resolveSpace($path)) | ||
| 32 | #hierarchy($spaceReference $hierarchyOptions) | ||
| 33 | </li> | ||
| 34 | #end | ||
| 35 | #if ($isEditing) | ||
| 36 | ## This is used as a template on the client side when a new path is added. | ||
| 37 | <li class="path hidden"> | ||
| 38 | <a href="#path-delete" class="path-delete">$services.icon.renderHTML('delete')</a> | ||
| 39 | <input type="hidden" name="XWiki.TemplateProviderClass_0_$property" disabled="disabled" /> | ||
| 40 | <ol class="breadcrumb"> | ||
| 41 | <li class="loading"></li> | ||
| 42 | </ol> | ||
| 43 | </li> | ||
| 44 | <li class="path-add"> | ||
| 45 | <input type="hidden" name="XWiki.TemplateProviderClass_0_$property" value="" /> | ||
| 46 | <a href="#path-add">$services.icon.renderHTML('add')</a> | ||
| 47 | </li> | ||
| 48 | #end | ||
| 49 | </ul> | ||
| 50 | #end | ||
| 51 | |||
| 52 | #macro (locationPickerModal) | ||
| 53 | <div class="location-picker modal fade" tabindex="-1" role="dialog" data-backdrop="static"> | ||
| 54 | <div class="modal-dialog" role="document"> | ||
| 55 | <div class="modal-content"> | ||
| 56 | <div class="modal-header"> | ||
| 57 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
| 58 | <span aria-hidden="true">×</span> | ||
| 59 | </button> | ||
| 60 | <div class="modal-title">$services.localization.render('core.documentPicker.title')</div> | ||
| 61 | </div> | ||
| 62 | <div class="modal-body"> | ||
| 63 | #documentTree({ | ||
| 64 | 'class': 'location-tree', | ||
| 65 | 'finder': true, | ||
| 66 | 'showAttachments': false, | ||
| 67 | 'showTerminalDocuments': false, | ||
| 68 | 'showTranslations': false | ||
| 69 | }) | ||
| 70 | </div> | ||
| 71 | <div class="modal-footer"> | ||
| 72 | <button type="button" class="btn btn-default" data-dismiss="modal"> | ||
| 73 | $services.localization.render('core.documentPicker.cancel') | ||
| 74 | </button> | ||
| 75 | <button type="button" class="btn btn-primary" disabled="disabled"> | ||
| 76 | $services.localization.render('core.documentPicker.select') | ||
| 77 | </button> | ||
| 78 | </div> | ||
| 79 | </div> | ||
| 80 | </div> | ||
| 81 | </div> | ||
| 82 | #end | ||
| 83 | {{/velocity}} |