Wiki source code of homeopathsSheet
Version 3.42 by Jip-jan Alunkel on March 09, 04:13
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'})) | ||
![]() |
1.5 | 8 | #set($theDoc = $xwiki.getDocument("${doc.fullName}").getTranslatedDocument()) |
![]() |
1.1 | 9 | #set($isInline = $xcontext.action == 'edit' && $request.get('editor') == 'inline') |
![]() |
3.2 | 10 | #set($theClass = "homeopaths.Code.homeopathsClass") |
![]() |
1.5 | 11 | ## Create object (important for sheet binding, do not remove) |
![]() |
3.2 | 12 | #set($theDocObj = $doc.getObject($theClass, true)) |
![]() |
1.7 | 13 | #set($hasRight = !$isGuest && ($theDocObj.getProperty('user').value == $context.getUser() || $hasAdmin)) |
![]() |
1.5 | 14 | $theDoc.getContent() |
![]() |
1.4 | 15 | {{html wiki="true" clean="false"}} |
![]() |
1.7 | 16 | #if(!$isGuest) |
![]() |
1.4 | 17 | <script> |
18 | var pagemakerOffspring = "disable"; | ||
19 | </script> | ||
![]() |
1.7 | 20 | #end |
21 | #if($hasRight) | ||
![]() |
1.1 | 22 | <p class="buttons text-align-right"> |
23 | <a class="btn btn-primary" title="Edit" href="$doc.getURL("edit")?editor=wysiwyg" role="button" rel="nofollow"> | ||
24 | <span class="fa fa-pencil"></span> | ||
![]() |
3.9 | 25 | <span class="btn-label">Edit content</span> |
![]() |
1.1 | 26 | </a> |
27 | </p> | ||
![]() |
1.7 | 28 | #end |
![]() |
1.1 | 29 | #set($spaceReference = $services.model.resolveDocument('', 'default', $doc.documentReference.lastSpaceReference).parent) |
30 | #set($spaceTitle = $spaceReference.getName()) | ||
31 | <div class="clearfix"></div> | ||
32 | #if($xcontext.action == "view") | ||
33 | <div id="${spaceTitle}" class="box sheet_properties"> | ||
34 | <h2>Details</h2> | ||
![]() |
3.34 | 35 | #set($xa = { |
36 | 'pmLatlong': '', | ||
37 | 'pmCountry': '', | ||
38 | 'pmState': '', | ||
39 | 'pmCounty': '', | ||
40 | 'pmPostcode': '', | ||
41 | 'pmCity': '', | ||
42 | 'pmStreet': '', | ||
43 | 'pmHousenumber': '' | ||
44 | }) | ||
45 | #foreach($item in $xa.keySet()) | ||
46 | #if($theDocObj.getProperty("$item")) | ||
![]() |
3.36 | 47 | #set($xa["$item"] = $theDocObj.getProperty("$item").value) |
![]() |
3.34 | 48 | #end |
49 | #end | ||
![]() |
3.38 | 50 | $theDocObj.getProperty("certification").value |
![]() |
3.2 | 51 | ## The classProperties Map has to be in the order of how you want the form elements to appear in the form. |
![]() |
3.40 | 52 | #set($certify = $theDocObj.getProperty("certification").value) |
53 | #set($cert = 0) | ||
![]() |
3.42 | 54 | #set($discard = $cert.parseInt($certify)) |
![]() |
3.41 | 55 | $cert |
![]() |
3.10 | 56 | #set($classProperties = { |
57 | 'practiceName': {'type': 'text', 'extraAttributes': {"disabled": "disabled", "help-block" : 'The name of your practice is the title of this page. If you want to change it, you should edit the content of this page.'}}, | ||
![]() |
3.31 | 58 | 'editAddress': {'type': 'checkbox', 'opener': 1, 'classless': 1, 'checked': 0}, |
![]() |
3.36 | 59 | 'pmAddress': {'type': 'address', 'parent': 'editAddress', 'extraAttributes': {"aria-label": "Input and select the address of your practice", "placeholder": "$services.localization.render('homeopaths.multiword.address.placeholder')", "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", "help-block" : 'Input street and number, then select the address of your practice.'}}, |
![]() |
3.20 | 60 | 'pmStreet': {'type': 'text', 'disabled': 1}, |
61 | 'pmHousenumber': {'type': 'text', 'disabled': 1}, | ||
62 | 'pmPostcode': {'type': 'text', 'disabled': 1}, | ||
63 | 'pmCity': {'type': 'text', 'disabled': 1}, | ||
64 | 'pmCounty': {'type': 'text', 'disabled': 1}, | ||
65 | 'pmState': {'type': 'text', 'disabled': 1}, | ||
66 | 'pmCountry': {'type': 'text', 'disabled': 1}, | ||
![]() |
3.40 | 67 | 'certification': {'type': 'checkbox', 'opener': 1, 'checked': $cert}, |
![]() |
3.10 | 68 | 'certificationFrom': {'type': 'text', 'parent': 'certification'} |
69 | }) | ||
70 | #foreach($property in $classProperties.keySet()) | ||
71 | #if($theDocObj.getProperty($property)) | ||
![]() |
2.1 | 72 | <p class="property"> |
![]() |
3.10 | 73 | #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout. |
74 | #if($property == "pmStreet") | ||
75 | <span class="property-name">$services.localization.render("homeopaths.classproperty.address")</span> <span class="property-value">$doc.display($property) $doc.display("pmHousenumber")</span> | ||
76 | #elseif($property == "practiceName") ## Difference, should receive the title from the page. | ||
![]() |
3.4 | 77 | <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.getTitle()</span> |
![]() |
3.10 | 78 | #else ## Normal situation. |
![]() |
2.1 | 79 | <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span> |
![]() |
3.10 | 80 | #end |
81 | </p> | ||
82 | #end | ||
83 | #end | ||
![]() |
2.1 | 84 | #end |
![]() |
1.90 | 85 | |
86 | #if($hasRight) | ||
87 | <p class="buttons text-align-right"> | ||
88 | <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow"> | ||
89 | <span class="btn-label">Edit details</span> | ||
90 | </a> | ||
91 | </p> | ||
92 | #end | ||
93 | </div> | ||
![]() |
3.1 | 94 | #if($hasRight) |
![]() |
1.90 | 95 | #set($form_start = { |
96 | "id": "homeopaths_form", | ||
97 | "product": "homeopath details", | ||
98 | "method": "post", | ||
99 | "url": "", | ||
100 | "use_captcha": "false" | ||
101 | }) | ||
![]() |
1.109 | 102 | #set($submit = { |
103 | "id" : "edit_details", | ||
104 | "button-text" : "Save changes", | ||
105 | "clean": "true", | ||
106 | "help-block" : "" | ||
107 | }) | ||
108 | #set($form_end = { | ||
109 | "use_captcha": "false" | ||
110 | }) | ||
111 | <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
112 | <div class="modal-dialog modal-dialog-centered" role="document"> | ||
113 | <div class="modal-content"> | ||
114 | #createFormStart($form_start) | ||
115 | <div class="modal-header"> | ||
116 | <h3 class="modal-title">Details</h3> | ||
117 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
118 | <span aria-hidden="true">×</span> | ||
119 | </button> | ||
120 | </div> | ||
121 | <div class="modal-body"> | ||
![]() |
3.10 | 122 | <fieldset class="fieldset"> |
123 | <address> | ||
![]() |
3.18 | 124 | $doc.getTitle()<br /> |
![]() |
3.14 | 125 | #set($addressArray = ['pmStreet','pmHousenumber','pmPostcode','pmCity','pmState','pmCounty','pmCountry']) |
126 | #set($x = {}) | ||
127 | #foreach($datapart in $addressArray) | ||
128 | #if($theDocObj.getProperty($datapart)) | ||
129 | #set($datapart4Publish = $theDocObj.getProperty($datapart).value) | ||
130 | #if($datapart == 'pmCountry') | ||
131 | #set($datapart4Publish = $datapart4Publish.toUpperCase()) | ||
132 | #end | ||
133 | #set($discard = $x.put("$datapart", $datapart4Publish)) | ||
134 | #end | ||
135 | #end | ||
![]() |
3.16 | 136 | $x['pmStreet'] $x['pmHousenumber']<br /> |
137 | $x['pmPostcode'] $x['pmCity']<br /> | ||
138 | $x['pmCounty'] $x['pmState']<br /> | ||
139 | $x['pmCountry'] | ||
![]() |
3.10 | 140 | </address> |
141 | </fieldset> | ||
![]() |
3.2 | 142 | #set($lastChild = "") |
143 | #foreach($propertyName in $classProperties.keySet()) | ||
144 | #set($item = $classProperties["$propertyName"]) | ||
![]() |
3.10 | 145 | #if($item.containsKey("disabled")) |
146 | #else | ||
147 | #set($propertyType = $item.type) | ||
![]() |
3.31 | 148 | #set($propertyChecked = $item.checked) |
![]() |
3.10 | 149 | #set($propertyOpener = $item.opener) |
150 | #set($propertyParent = $item.parent) | ||
151 | #set($extraAttributes = $item.extraAttributes) | ||
152 | #set($label = $services.localization.render("homeopaths.classproperty.${propertyName}")) | ||
![]() |
3.21 | 153 | #if($propertyType == "checkbox" || $propertyType == "radio") |
![]() |
3.33 | 154 | #set($value = "1") |
![]() |
3.22 | 155 | #elseif($theDocObj.getProperty($propertyName) || $propertyType == "address") ## 'address' is not a property in the current class |
![]() |
3.10 | 156 | #set($value = $theDocObj.getProperty($propertyName).value) |
![]() |
3.21 | 157 | #end |
158 | #if(!$value) | ||
159 | #set($value = "") | ||
160 | #end | ||
![]() |
3.25 | 161 | #if($item.containsKey("classless")) |
162 | #set($newElem = { | ||
163 | "id" : "$propertyName", | ||
164 | "type" : $propertyType, | ||
165 | "required" : "false", | ||
166 | "label" : "$label", | ||
167 | "value" : "$value" | ||
168 | }) | ||
169 | #else | ||
170 | #set($newElem = { | ||
171 | "id" : "$propertyName", | ||
172 | "type" : $propertyType, | ||
173 | "required" : "false", | ||
174 | "label" : "$label", | ||
175 | "data-create-xobj" : "true", | ||
176 | "data-xobj-classname" : $theClass, | ||
177 | "data-xobj-fieldname" : "$propertyName", | ||
178 | "value" : "$value" | ||
179 | }) | ||
180 | #end | ||
![]() |
3.21 | 181 | #if($extraAttributes.keySet().size() > 0) |
182 | #set($attrMap = $extraAttributes) | ||
183 | #foreach($attr in $attrMap.keySet()) | ||
184 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
![]() |
3.2 | 185 | #end |
186 | #end | ||
![]() |
3.31 | 187 | #if($propertyChecked) |
![]() |
3.32 | 188 | #set($discard = $newElem.put("data-checked", "false")) |
![]() |
3.31 | 189 | #end |
![]() |
3.21 | 190 | #if($propertyOpener) |
191 | #set($discard = $newElem.put("data-opener", "true")) | ||
192 | #end | ||
193 | #if($propertyParent) | ||
194 | #set($lastChild = "$key") | ||
195 | #elseif($lastChild != "") | ||
196 | #set($lastChild = "") | ||
197 | #createExpandEnd() | ||
198 | #end | ||
199 | #createFormElement($newElem) | ||
200 | #if($propertyOpener) | ||
201 | #createExpandStart($newElem $value) | ||
202 | #end | ||
![]() |
3.2 | 203 | #end |
204 | #end | ||
![]() |
1.1 | 205 | </div> |
206 | <div class="modal-footer"> | ||
207 | <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
208 | #createSubmit($submit) | ||
209 | </div> | ||
210 | #createFormEnd($form_end) | ||
211 | </div> | ||
212 | </div> | ||
213 | </div> | ||
214 | #end | ||
![]() |
1.7 | 215 | #else |
216 | This page can not be viewed in inline mode. | ||
![]() |
1.1 | 217 | #end |
![]() |
3.2 | 218 | |
219 | #macro(createElementObjects $properties) | ||
220 | #foreach($item in $properties.keySet()) | ||
221 | #set($label = $services.localization.render("homeopaths.classproperty.${item}")) | ||
222 | #if($theDocObj.getProperty($item)) | ||
223 | #set($value = $theDocObj.getProperty($item).value) | ||
224 | #set($newElem = { | ||
225 | "id" : "$item", | ||
226 | "type" : $classProperties[$item].type, | ||
227 | "required" : "false", | ||
228 | "label" : "$label", | ||
229 | "data-create-xobj" : "true", | ||
230 | "data-xobj-classname" : $theClass, | ||
231 | "data-xobj-fieldname" : "$item", | ||
232 | "value" : "$value" | ||
233 | }) | ||
234 | #if($classProperties[$item].opener == 1) | ||
235 | #set($discard = $newElem.put("data-opener", "true")) | ||
236 | #end | ||
237 | #if($classProperties[$item].extraAttributes) | ||
238 | #set($attrMap = $classProperties[$item].extraAttributes) | ||
239 | #foreach($attr in $attrMap.keySet()) | ||
240 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
241 | #end | ||
242 | #end | ||
243 | #set($thisObj["$item"] = $newElem) | ||
244 | #end | ||
245 | #end | ||
246 | #end | ||
247 | |||
![]() |
1.1 | 248 | {{/html}} |
249 | {{/velocity}} |