Wiki source code of TemplateProviderEditSheet
Version 1.1 by superadmin on 2018/07/31 17:43
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | {{include reference="XWiki.TemplateProviderMacros" /}} |
| 2 | |||
| 3 | {{velocity}} | ||
| 4 | #if("$!request.wizard" == 'true') | ||
| 5 | {{include reference="AppWithinMinutes.WizardStep" /}} | ||
| 6 | #end | ||
| 7 | {{/velocity}} | ||
| 8 | |||
| 9 | {{velocity output="false"}} | ||
| 10 | #set ($appDescriptorClassName = 'AppWithinMinutes.LiveTableClass') | ||
| 11 | |||
| 12 | #macro (initializeTemplateProvider) | ||
| 13 | #set ($prefix = $stringtool.removeEnd($doc.name, 'TemplateProvider')) | ||
| 14 | #set ($discard = $doc.setTitle("$prefix Template Provider")) | ||
| 15 | #set ($templateProviderObj = $doc.getObject('XWiki.TemplateProviderClass')) | ||
| 16 | #set ($discard = $templateProviderObj.set('name', "${prefix.toLowerCase()}.entry.name")) | ||
| 17 | #set ($discard = $templateProviderObj.set('template', $stringtool.removeEnd($doc.fullName, 'Provider'))) | ||
| 18 | #getAppReference | ||
| 19 | #set ($localStringAppRef = $services.model.serialize($appReference, 'local')) | ||
| 20 | #set ($icon = 'application') | ||
| 21 | #foreach ($uix in $services.uix.getExtensions('org.xwiki.platform.panels.Applications')) | ||
| 22 | #if ($uix.id == "platform.panels.${localStringAppRef}Application" && $uix.parameters.icon.startsWith('icon:')) | ||
| 23 | ## Use the application icon by default if set. | ||
| 24 | #set ($icon = $stringtool.removeStart($uix.parameters.icon, 'icon:')) | ||
| 25 | #end | ||
| 26 | #end | ||
| 27 | #set ($discard = $templateProviderObj.set('icon', $icon)) | ||
| 28 | #set ($homePageRef = $services.model.resolveDocument('', 'default', $appReference)) | ||
| 29 | ## We recommend the users to create the entries in the application space by default because: | ||
| 30 | ## * for most applications it's better to keep the entries in the same place | ||
| 31 | ## * if the application is not yet created the application space doesn't exist so the user cannot select it from the | ||
| 32 | ## tree unless we select it by default | ||
| 33 | #set ($creationRestrictions = [$services.model.serialize($appReference, 'local')]) | ||
| 34 | #set ($creationRestrictionsAreSuggestions = 1) | ||
| 35 | #if ($xwiki.exists($homePageRef)) | ||
| 36 | ## We are (most probably) editing an existing application. Initialize the entry location based on the information | ||
| 37 | ## stored on the application home page. | ||
| 38 | #set ($dataSpace = $xwiki.getDocument($homePageRef).getValue('dataSpace')) | ||
| 39 | #set ($dataSpaceReference = $services.model.resolveSpace($dataSpace, 'explicit', $appReference)) | ||
| 40 | #set ($creationRestrictions = [$services.model.serialize($dataSpaceReference, 'local')]) | ||
| 41 | #set ($creationRestrictionsAreSuggestions = 0) | ||
| 42 | ## Preserve the old behavior. | ||
| 43 | #set ($discard = $templateProviderObj.set('terminal', 1)) | ||
| 44 | #end | ||
| 45 | #set ($discard = $templateProviderObj.set('creationRestrictions', $creationRestrictions)) | ||
| 46 | #set ($discard = $templateProviderObj.set('creationRestrictionsAreSuggestions', $creationRestrictionsAreSuggestions)) | ||
| 47 | #end | ||
| 48 | |||
| 49 | #macro (getAppReference) | ||
| 50 | #set ($appLocalRef = $doc.getValue('dataSpaceName')) | ||
| 51 | #if ("$!appLocalRef" != '') | ||
| 52 | ## Between 6.3M2 (XWIKI-11249) and 7.3RC1 (XWIKI-12741). | ||
| 53 | #set ($appReference = $services.model.resolveSpace($appLocalRef)) | ||
| 54 | #else | ||
| 55 | ## Possible locations: | ||
| 56 | ## 1. same space (<6.2M1, XWIKI-8757) | ||
| 57 | ## 2. sibling space (between 6.2M1 and 6.3M2) | ||
| 58 | ## 3. grand parent space (7.3RC1+) | ||
| 59 | #set ($appReferences = [ | ||
| 60 | $doc.documentReference.parent, | ||
| 61 | $services.model.createSpaceReference($stringtool.removeEnd($doc.name, 'TemplateProvider'), | ||
| 62 | $doc.documentReference.parent.parent), | ||
| 63 | $doc.documentReference.parent.parent | ||
| 64 | ]) | ||
| 65 | #foreach ($item in $appReferences) | ||
| 66 | #set ($appReference = $item) | ||
| 67 | #if ($xwiki.getDocument($appReference).getObject($appDescriptorClassName)) | ||
| 68 | #break | ||
| 69 | #end | ||
| 70 | #end | ||
| 71 | #end | ||
| 72 | #end | ||
| 73 | |||
| 74 | #macro (maybeAddXRedirectToNextWizardStep) | ||
| 75 | #if ("$!request.wizard" == 'true') | ||
| 76 | ## Add redirect to next wizard step. | ||
| 77 | #getAppReference | ||
| 78 | #set ($homePageRef = $services.model.resolveDocument('', 'default', $appReference)) | ||
| 79 | #set ($queryString = {"wizard" : true}) | ||
| 80 | #if (!$xwiki.exists($homePageRef)) | ||
| 81 | #set ($classReference = "${stringtool.removeEnd($doc.fullName, 'TemplateProvider')}Class") | ||
| 82 | #set ($wikiHomePageRef = $services.model.resolveDocument('', 'default')) | ||
| 83 | #set ($wikiHomePage = $services.model.serialize($wikiHomePageRef, 'local')) | ||
| 84 | #set ($discard = $queryString.putAll({ | ||
| 85 | 'template': 'AppWithinMinutes.LiveTableTemplate', | ||
| 86 | "${appDescriptorClassName}_0_class": $classReference, | ||
| 87 | 'title': $appReference.name, | ||
| 88 | 'parent': $wikiHomePage | ||
| 89 | })) | ||
| 90 | #end | ||
| 91 | #set ($queryString = $escapetool.url($queryString)) | ||
| 92 | <input type="hidden" name="xredirect" value="$escapetool.xml($xwiki.getURL($homePageRef, 'edit', $queryString))" /> | ||
| 93 | #end | ||
| 94 | #end | ||
| 95 | |||
| 96 | #macro (displayEditForm) | ||
| 97 | {{html clean="false"}} | ||
| 98 | #set ($discard = $xwiki.ssx.use('XWiki.TemplateProviderMacros')) | ||
| 99 | #set ($discard = $xwiki.jsx.use('XWiki.TemplateProviderMacros')) | ||
| 100 | #if ($doc.isNew()) | ||
| 101 | #initializeTemplateProvider | ||
| 102 | #end | ||
| 103 | <div class="hidden"> | ||
| 104 | <input type="hidden" name="title" value="$escapetool.xml($doc.title)" /> | ||
| 105 | <input type="hidden" name="xhidden" value="1" /> | ||
| 106 | #foreach ($property in ['name', 'template', 'action']) | ||
| 107 | #displayPropertyValue($property 'hidden') | ||
| 108 | #end | ||
| 109 | #maybeAddXRedirectToNextWizardStep | ||
| 110 | </div> | ||
| 111 | <div class="xform row templateProviderSheet"> | ||
| 112 | <div class="xHint col-xs-12"> | ||
| 113 | $services.icon.renderHTML('info') | ||
| 114 | $services.localization.render('appWithinMinutes.templateProviderEditor.hint') | ||
| 115 | </div> | ||
| 116 | ## | ||
| 117 | ## Left side | ||
| 118 | ## | ||
| 119 | <div class="col-xs-12 col-md-6"> | ||
| 120 | <dl> | ||
| 121 | ## | ||
| 122 | ## Icon | ||
| 123 | ## | ||
| 124 | <dt> | ||
| 125 | <label for="XWiki.TemplateProviderClass_0_icon"> | ||
| 126 | $escapetool.xml($doc.displayPrettyName('icon')) | ||
| 127 | </label> | ||
| 128 | <span class="xHint"> | ||
| 129 | $services.localization.render('appWithinMinutes.templateProviderEditor.icon.hint') | ||
| 130 | </span> | ||
| 131 | </dt> | ||
| 132 | <dd>#displayPropertyValue('icon')</dd> | ||
| 133 | ## | ||
| 134 | ## Description | ||
| 135 | ## | ||
| 136 | <dt> | ||
| 137 | <label for="XWiki.TemplateProviderClass_0_description"> | ||
| 138 | $escapetool.xml($doc.displayPrettyName('description')) | ||
| 139 | </label> | ||
| 140 | <span class="xHint"> | ||
| 141 | $services.localization.render('appWithinMinutes.templateProviderEditor.description.hint') | ||
| 142 | </span> | ||
| 143 | </dt> | ||
| 144 | <dd>#displayPropertyValue('description')</dd> | ||
| 145 | ## | ||
| 146 | ## Visibility Restrictions | ||
| 147 | ## | ||
| 148 | <dt> | ||
| 149 | <label> | ||
| 150 | $escapetool.xml($services.localization.render('appWithinMinutes.templateProviderEditor.visibilityRestrictions.name')) | ||
| 151 | </label> | ||
| 152 | <span class="xHint"> | ||
| 153 | $escapetool.xml($services.localization.render('appWithinMinutes.templateProviderEditor.visibilityRestrictions.hint')) | ||
| 154 | </span> | ||
| 155 | </dt> | ||
| 156 | <dd>#displayPathsPropertyValue('visibilityRestrictions')</dd> | ||
| 157 | </dl> | ||
| 158 | </div> | ||
| 159 | ## | ||
| 160 | ## Right side | ||
| 161 | ## | ||
| 162 | <div class="col-xs-12 col-md-6"> | ||
| 163 | <dl> | ||
| 164 | ## | ||
| 165 | ## Creation Restrictions | ||
| 166 | ## | ||
| 167 | <dt> | ||
| 168 | <label for="XWiki.TemplateProviderClass_0_creationRestrictions"> | ||
| 169 | $escapetool.xml($services.localization.render('appWithinMinutes.templateProviderEditor.creationRestrictions.name')) | ||
| 170 | </label> | ||
| 171 | <span class="xHint"> | ||
| 172 | $services.localization.render('appWithinMinutes.templateProviderEditor.creationRestrictions.hint') | ||
| 173 | </span> | ||
| 174 | </dt> | ||
| 175 | <dd>#displayPathsPropertyValue('creationRestrictions')</dd> | ||
| 176 | ## | ||
| 177 | ## Creation Restrictions As Suggestions | ||
| 178 | ## | ||
| 179 | <dt> | ||
| 180 | <label for="XWiki.TemplateProviderClass_0_creationRestrictionsAreSuggestions"> | ||
| 181 | #displayPropertyValue('creationRestrictionsAreSuggestions') | ||
| 182 | $escapetool.xml($services.localization.render('appWithinMinutes.templateProviderEditor.creationRestrictionsAreSuggestions.name')) | ||
| 183 | </label> | ||
| 184 | <span class="xHint"> | ||
| 185 | $services.localization.render('appWithinMinutes.templateProviderEditor.creationRestrictionsAreSuggestions.hint') | ||
| 186 | </span> | ||
| 187 | </dt> | ||
| 188 | <dd></dd> | ||
| 189 | ## | ||
| 190 | ## Terminal page creation - Advanced user | ||
| 191 | ## | ||
| 192 | #if ($isAdvancedUser || $isSuperAdmin) | ||
| 193 | <dt> | ||
| 194 | <label for="XWiki.TemplateProviderClass_0_terminal"> | ||
| 195 | $escapetool.xml($doc.displayPrettyName('terminal')) | ||
| 196 | </label> | ||
| 197 | <span class="xHint"> | ||
| 198 | $escapetool.xml($services.localization.render('appWithinMinutes.templateProviderEditor.terminal.hint')) | ||
| 199 | </span> | ||
| 200 | </dt> | ||
| 201 | <dd>#displayPropertyValue('terminal')</dd> | ||
| 202 | #else | ||
| 203 | <dd>#displayPropertyValue('terminal' 'hidden')</dd> | ||
| 204 | #end | ||
| 205 | </dl> | ||
| 206 | </div> | ||
| 207 | #locationPickerModal | ||
| 208 | </div> | ||
| 209 | {{/html}} | ||
| 210 | |||
| 211 | {{iconPicker id="XWiki\\.TemplateProviderClass_0_icon" prefix="" /}} | ||
| 212 | #end | ||
| 213 | |||
| 214 | #macro (doEdit) | ||
| 215 | #if("$!request.wizard" == 'true') | ||
| 216 | #appWizardHeader('entries') | ||
| 217 | |||
| 218 | #end | ||
| 219 | #displayEditForm | ||
| 220 | #if("$!request.wizard" == 'true') | ||
| 221 | #appWizardFooter('entries') | ||
| 222 | #end | ||
| 223 | #end | ||
| 224 | {{/velocity}} | ||
| 225 | |||
| 226 | {{velocity}} | ||
| 227 | #if ($doc.getObject('XWiki.TemplateProviderClass')) | ||
| 228 | #doEdit | ||
| 229 | #end | ||
| 230 | {{/velocity}} |