Wiki broncode van homeopathsSheet
Version 3.260 by Jip-jan Alunkel on maart 15, 22:10
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | {{include reference="assets.pagemaker.macros"/}} |
2 | |||
3 | {{velocity}} | ||
![]() |
3.2 | 4 | #set($discard = $services.localization.use('document', 'assets.global.translations')) |
![]() |
1.1 | 5 | #set($discard = $services.localization.use('document', 'assets.pagemaker.translations')) |
6 | #set($discard = $xwiki.ssx.use('assets.pagemaker.WebHome', {'minify': false})) | ||
7 | #set($discard = $xwiki.jsx.use('assets.pagemaker.WebHome', {'minify': false, 'language': $context.language, 'myParameter': 'value'})) | ||
![]() |
3.165 | 8 | #set($subjectTitle = $doc.getFullName().split('\.')[0]) |
![]() |
3.162 | 9 | ## Find the correct class name. This is if the class name starts with the name of the top parent space (referenced here by $subjectTitle). |
![]() |
3.154 | 10 | ## Specify a class name below to override this. |
![]() |
3.148 | 11 | #set($theClass = "") |
![]() |
3.143 | 12 | #set($docObjects = $doc.getxWikiObjects()) |
![]() |
3.133 | 13 | #foreach($docObjectKey in $docObjects.keySet()) |
![]() |
3.239 | 14 | #if($docObjectKey.indexOf($subjectTitle) == 0) |
![]() |
3.150 | 15 | #if($theClass == "") |
16 | #set($theClass = $docObjectKey) | ||
17 | #end | ||
![]() |
3.134 | 18 | #end |
![]() |
3.133 | 19 | #end |
![]() |
3.154 | 20 | #set($theDocObj = $doc.getObject($theClass, true)) |
![]() |
3.149 | 21 | #set($hasRight = !$isGuest && ($theDocObj.getProperty('doc_owner').value == $context.getUser() || $hasAdmin)) |
![]() |
3.166 | 22 | ## ADDRESS: Prepare object to provide hidden values to the address input. The keys are equal to the class property names. |
23 | ## The entries will be filled by the class property values. | ||
24 | #set($xa = {'pmLatlong': '','pmCountry': '','pmState': '','pmCounty': '','pmPostcode': '','pmCity': '','pmStreet': '','pmHousenumber': ''}) | ||
25 | #foreach($item in $xa.keySet()) | ||
![]() |
3.258 | 26 | #if($theDocObj.getProperty("$item").value) |
![]() |
3.166 | 27 | #set($xa["$item"] = $theDocObj.getProperty("$item").value) |
28 | #end | ||
29 | #end | ||
30 | ## The classProperties Map has to be in the order of how you want the form elements to appear in the form. | ||
![]() |
3.246 | 31 | ## 'opener': 1 --> input functions as an interface control element, it 'opens' an additional block of form inputs. Only for select, input or radio inputs. |
32 | ## 'classless': 1 --> input is not bound to any XClass or XClass property. | ||
![]() |
3.166 | 33 | ## 'disabled': 1 --> Will not show up in the form at all. |
34 | ## 'extraAttributes': {"disabled": "disabled"} --> Will show up in the form as a disabled input. | ||
35 | #set($classProperties = { | ||
36 | 'editAddress': {'type': 'checkbox', 'opener': 1, 'classless': 1, 'extraAttributes': {"data-checked": "false"}}, | ||
![]() |
3.186 | 37 | 'pmAddress': {'type': 'address', 'parent': 'editAddress', "help-block": 1, 'extraAttributes': {"pmLatlong": "$xa['pmLatlong']", "pmCountry": "$xa['pmCountry']", "pmState": "$xa['pmState']", "pmCounty": "$xa['pmCounty']", "pmPostcode": "$xa['pmPostcode']", "pmCity": "$xa['pmCity']", "pmStreet": "$xa['pmStreet']", "pmHousenumber": "$xa['pmHousenumber']", "data-auto-first-capital": "true", "data-query-type": "address", "data-query-reference": "", "data-query-list-type": "suggest-select", "data-query-list-header": "$services.localization.render('pagemaker.line.suggest_select_list')", "data-query-list-contents": "value/key", "data-query-list-editable": "false", "data-create-xobj": "true", "data-xobj-classname": "homeopaths.Code.homeopathsClass"}}, |
![]() |
3.184 | 38 | 'practiceName': {'type': 'text', 'disabled': 0, "help-block": 1, 'extraAttributes': {"disabled": "disabled"}}, |
![]() |
3.166 | 39 | 'pmStreet': {'type': 'text', 'disabled': 1}, |
40 | 'pmHousenumber': {'type': 'text', 'disabled': 1}, | ||
41 | 'pmPostcode': {'type': 'text', 'disabled': 1}, | ||
42 | 'pmCity': {'type': 'text', 'disabled': 1}, | ||
43 | 'pmCounty': {'type': 'text', 'disabled': 1}, | ||
44 | 'pmState': {'type': 'text', 'disabled': 1}, | ||
45 | 'pmCountry': {'type': 'text', 'disabled': 1}, | ||
46 | 'nrOfHomeopaths': {'type': 'number'}, | ||
47 | 'certification': {'type': 'checkbox', 'opener': 1}, | ||
48 | 'certificationFrom': {'type': 'text', 'parent': 'certification'} | ||
49 | }) | ||
![]() |
3.231 | 50 | $doc.getTranslatedDocument().getContent() |
![]() |
3.234 | 51 | |
![]() |
3.240 | 52 | {{html wiki="true" clean="false"}} |
![]() |
1.7 | 53 | #if($hasRight) |
![]() |
1.1 | 54 | <p class="buttons text-align-right"> |
![]() |
3.233 | 55 | <a class="btn btn-primary" title="Edit" href="$doc.getURL('edit','editor=wysiwyg')" role="button" rel="nofollow"> |
![]() |
3.246 | 56 | <span class="btn-label">$services.localization.render("global.multiword.edit_content")</span> |
![]() |
1.1 | 57 | </a> |
58 | </p> | ||
![]() |
1.7 | 59 | #end |
![]() |
3.237 | 60 | #if(!$isGuest)<p><script>var pmMenuCreate = "disable";</script></p>#end |
![]() |
1.1 | 61 | <div class="clearfix"></div> |
62 | #if($xcontext.action == "view") | ||
![]() |
3.50 | 63 | <h2 class="inline-data-summary">$services.localization.render("homeopaths.inlineDataSummary.sheet_properties")</h2> |
![]() |
3.126 | 64 | <div id="${subjectTitle}" class="sheet_properties inline-data-summary"> |
![]() |
3.246 | 65 | ## Show the address |
![]() |
3.94 | 66 | #createAddress($theClass 1) |
![]() |
3.246 | 67 | ## Set the XClass properties which you would like to be displayed. |
![]() |
3.99 | 68 | #set($properties = ['nrOfHomeopaths','certification','certificationFrom']) |
![]() |
3.246 | 69 | ## Show the above chosen properties |
![]() |
3.58 | 70 | #foreach($property in $properties) |
![]() |
3.259 | 71 | #set($hide = 0) |
![]() |
3.260 | 72 | ## #if($theDocObj.getProperty($property).value) |
![]() |
3.259 | 73 | ## All form elements that are hidden in the form should also be hidden in the page. |
![]() |
3.246 | 74 | #if($classProperties["$property"].containsKey('parent')) |
![]() |
3.249 | 75 | #set($parentKey = $classProperties["$property"].parent) |
![]() |
3.259 | 76 | #if((($classProperties["$parentKey"].type == "checkbox" || $classProperties["$parentKey"].type == "radio") && $theDocObj.getProperty($parentKey).value == 0) || !$theDocObj.getProperty($parentKey).value) |
![]() |
3.246 | 77 | #set($hide = 1) |
78 | #end | ||
79 | #end | ||
![]() |
3.260 | 80 | ## #else |
81 | ## #set($hide = 1) | ||
82 | ## #end | ||
![]() |
3.259 | 83 | #if($hide == 0) |
![]() |
2.1 | 84 | <p class="property"> |
![]() |
3.260 | 85 | <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}.label")</span>#if($theDocObj.getProperty($property).value && $theDocObj.getProperty($property).value != "") <span class="property-value">$doc.display($property)</span>#else <span class="property-value ghost">$services.localization.render("global.word.unknown")</span>#end |
![]() |
3.10 | 86 | </p> |
87 | #end | ||
![]() |
2.1 | 88 | #end |
![]() |
1.90 | 89 | #if($hasRight) |
90 | <p class="buttons text-align-right"> | ||
91 | <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow"> | ||
92 | <span class="btn-label">Edit details</span> | ||
93 | </a> | ||
94 | </p> | ||
95 | #end | ||
96 | </div> | ||
![]() |
3.1 | 97 | #if($hasRight) |
![]() |
1.90 | 98 | #set($form_start = { |
99 | "id": "homeopaths_form", | ||
100 | "product": "homeopath details", | ||
101 | "method": "post", | ||
102 | "url": "", | ||
103 | "use_captcha": "false" | ||
104 | }) | ||
![]() |
1.109 | 105 | #set($submit = { |
106 | "id" : "edit_details", | ||
107 | "button-text" : "Save changes", | ||
108 | "clean": "true", | ||
109 | "help-block" : "" | ||
110 | }) | ||
111 | #set($form_end = { | ||
112 | "use_captcha": "false" | ||
113 | }) | ||
114 | <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
115 | <div class="modal-dialog modal-dialog-centered" role="document"> | ||
116 | <div class="modal-content"> | ||
117 | #createFormStart($form_start) | ||
118 | <div class="modal-header"> | ||
119 | <h3 class="modal-title">Details</h3> | ||
120 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
121 | <span aria-hidden="true">×</span> | ||
122 | </button> | ||
123 | </div> | ||
124 | <div class="modal-body"> | ||
![]() |
3.88 | 125 | #createAddress($theClass 1) |
![]() |
3.78 | 126 | #set($lastChild = "") |
127 | #foreach($propertyName in $classProperties.keySet()) | ||
![]() |
3.110 | 128 | #set($value = "") |
![]() |
3.78 | 129 | #set($item = $classProperties["$propertyName"]) |
![]() |
3.179 | 130 | #if(!$item.containsKey("disabled") || $item["disabled"] == 0) |
![]() |
3.174 | 131 | #if(!$item.extraAttributes) |
132 | #set($item.extraAttributes = {}) | ||
133 | #end | ||
![]() |
3.170 | 134 | #set($translatedProperties = {}) |
![]() |
3.187 | 135 | #set($checkBool = ["false","true"]) |
![]() |
3.202 | 136 | #set($hasClassObj = !$item.containsKey("classless") && $theDocObj.getProperty($propertyName)) |
![]() |
3.188 | 137 | #if($item.type == "checkbox" || $item.type == "radio") |
![]() |
3.192 | 138 | #if($hasClassObj) |
![]() |
3.189 | 139 | #set($item.extraAttributes["data-checked"] = "$checkBool[$theDocObj.getProperty($propertyName).value]") |
![]() |
3.188 | 140 | #else |
141 | #if(!$item.extraAttributes.containsKey("data-checked")) | ||
142 | #set($item.extraAttributes["data-checked"] = "$checkBool[0]") | ||
143 | #end | ||
144 | #end | ||
![]() |
3.189 | 145 | #set($value = "1") |
![]() |
3.188 | 146 | #else |
![]() |
3.192 | 147 | #if($hasClassObj) |
![]() |
3.188 | 148 | #if($theDocObj.getProperty($propertyName).value) |
149 | #set($value = $theDocObj.getProperty($propertyName).value) | ||
150 | #end | ||
151 | #end | ||
152 | #end | ||
![]() |
3.199 | 153 | #if($item.type != "checkbox" && $item.type != "radio" && (!$item.containsKey("disabled") || $item["disabled"] == 0)) |
![]() |
3.166 | 154 | #set($translatedProperties = { |
155 | 'aria_label': 'data-aria-label', | ||
![]() |
3.173 | 156 | 'placeholder': 'placeholder' |
![]() |
3.166 | 157 | }) |
158 | #end | ||
159 | #set($translatedProperties['label'] = 'label') | ||
![]() |
3.184 | 160 | #if($item['help-block'] == 1) |
![]() |
3.183 | 161 | #set($translatedProperties['help_block'] = 'help-block') |
162 | #end | ||
![]() |
3.176 | 163 | #foreach($key in $translatedProperties.keySet()) |
164 | #set($item.extraAttributes["$translatedProperties[$key]"] = $services.localization.render("homeopaths.classproperty.${propertyName}.${key}")) | ||
![]() |
3.166 | 165 | #end |
![]() |
3.78 | 166 | #if($item.containsKey("classless")) |
167 | #set($newElem = { | ||
168 | "id" : "$propertyName", | ||
![]() |
3.100 | 169 | "type" : $item.type, |
![]() |
3.78 | 170 | "required" : "false", |
171 | "label" : "$label", | ||
172 | "value" : "$value" | ||
173 | }) | ||
174 | #else | ||
175 | #set($newElem = { | ||
176 | "id" : "$propertyName", | ||
![]() |
3.100 | 177 | "type" : $item.type, |
![]() |
3.78 | 178 | "required" : "false", |
179 | "label" : "$label", | ||
180 | "data-create-xobj" : "true", | ||
181 | "data-xobj-classname" : $theClass, | ||
182 | "data-xobj-fieldname" : "$propertyName", | ||
183 | "value" : "$value" | ||
184 | }) | ||
185 | #end | ||
![]() |
3.102 | 186 | #if($item.extraAttributes.keySet().size() > 0) |
187 | #foreach($attr in $item.extraAttributes.keySet()) | ||
188 | #set($discard = $newElem.put("$attr", $item.extraAttributes[$attr])) | ||
![]() |
3.78 | 189 | #end |
190 | #end | ||
![]() |
3.102 | 191 | #if($item.opener) |
![]() |
3.78 | 192 | #set($discard = $newElem.put("data-opener", "true")) |
193 | #end | ||
![]() |
3.102 | 194 | #if($item.parent) |
![]() |
3.78 | 195 | #set($lastChild = "$key") |
196 | #elseif($lastChild != "") | ||
197 | #set($lastChild = "") | ||
198 | #createExpandEnd() | ||
199 | #end | ||
200 | #createFormElement($newElem) | ||
![]() |
3.102 | 201 | #if($item.opener) |
![]() |
3.78 | 202 | #createExpandStart($newElem $value) |
203 | #end | ||
![]() |
3.61 | 204 | #end |
205 | #end | ||
![]() |
1.1 | 206 | </div> |
207 | <div class="modal-footer"> | ||
208 | <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
![]() |
3.78 | 209 | #createSubmit($submit) |
![]() |
1.1 | 210 | </div> |
211 | #createFormEnd($form_end) | ||
212 | </div> | ||
213 | </div> | ||
214 | </div> | ||
215 | #end | ||
![]() |
3.206 | 216 | #elseif($xcontext.action == 'edit' && ($request.get('editor') == 'inline' || $request.get('section'))) |
![]() |
3.229 | 217 | <p>This page can not be edited in inline mode.</p> |
![]() |
3.207 | 218 | <ul> |
![]() |
3.215 | 219 | <li>[[Edit this page in full edit mode>>path:$doc.getURL('edit','editor=wysiwyg')]], or</li> |
![]() |
3.207 | 220 | <li>[[View this page>>$doc.fullName]]</li> |
221 | </ul> | ||
![]() |
1.1 | 222 | #end |
![]() |
3.88 | 223 | #macro(createAddress $className $withLabel) |
![]() |
3.55 | 224 | #set($docObj = $doc.getObject($className)) |
![]() |
3.52 | 225 | #set($addressArray = ['pmStreet','pmHousenumber','pmPostcode','pmCity','pmState','pmCounty','pmCountry']) |
226 | #set($x = {}) | ||
227 | #foreach($datapart in $addressArray) | ||
![]() |
3.55 | 228 | #if($docObj.getProperty($datapart)) |
229 | #set($datapart4Publish = $docObj.getProperty($datapart).value) | ||
![]() |
3.52 | 230 | #if($datapart == 'pmCountry') |
231 | #set($datapart4Publish = $datapart4Publish.toUpperCase()) | ||
232 | #end | ||
233 | #set($discard = $x.put("$datapart", $datapart4Publish)) | ||
234 | #end | ||
235 | #end | ||
![]() |
3.91 | 236 | <div class="formElement"> |
![]() |
3.89 | 237 | #if($withLabel) |
![]() |
3.244 | 238 | <label>$services.localization.render("homeopaths.classproperty.pmAddress.label")</label> |
![]() |
3.89 | 239 | #end |
![]() |
3.88 | 240 | <address> |
241 | $doc.getTitle()<br /> | ||
242 | $x['pmStreet'] $x['pmHousenumber']<br /> | ||
243 | $x['pmPostcode'] $x['pmCity']<br /> | ||
244 | $x['pmCounty'] $x['pmState']<br /> | ||
245 | $x['pmCountry'] | ||
246 | </address> | ||
![]() |
3.91 | 247 | </div> |
![]() |
3.52 | 248 | #end |
![]() |
1.1 | 249 | {{/html}} |
250 | {{/velocity}} |