Wiki source code of homeopathsSheet
Version 3.19 by Jip-jan Alunkel on March 09, 00:59
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.2 | 35 | ## The classProperties Map has to be in the order of how you want the form elements to appear in the form. |
![]() |
3.10 | 36 | #set($classProperties = { |
37 | '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.19 | 38 | 'editAddress': {'type': 'checkbox', 'opener': 1}, |
39 | 'pmAddress': {'type': 'address', 'parent': 'editAddress', 'extraAttributes': {"aria-label": "Input and select the address of your practice", "placeholder": "$services.localization.render('homeopaths.multiword.address.placeholder')", "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.10 | 40 | 'pmStreet': {'type': 'text'}, |
41 | 'pmHousenumber': {'type': 'text'}, | ||
42 | 'pmPostcode': {'type': 'text'}, | ||
43 | 'pmCity': {'type': 'text'}, | ||
44 | 'pmCounty': {'type': 'text'}, | ||
45 | 'pmState': {'type': 'text'}, | ||
46 | 'pmCountry': {'type': 'text'}, | ||
47 | 'certification': {'type': 'checkbox', 'opener': 1}, | ||
48 | 'certificationFrom': {'type': 'text', 'parent': 'certification'} | ||
49 | }) | ||
50 | #foreach($property in $classProperties.keySet()) | ||
51 | #if($theDocObj.getProperty($property)) | ||
![]() |
2.1 | 52 | <p class="property"> |
![]() |
3.10 | 53 | #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout. |
54 | #if($property == "pmStreet") | ||
55 | <span class="property-name">$services.localization.render("homeopaths.classproperty.address")</span> <span class="property-value">$doc.display($property) $doc.display("pmHousenumber")</span> | ||
56 | #elseif($property == "practiceName") ## Difference, should receive the title from the page. | ||
![]() |
3.4 | 57 | <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.getTitle()</span> |
![]() |
3.10 | 58 | #else ## Normal situation. |
![]() |
2.1 | 59 | <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span> |
![]() |
3.10 | 60 | #end |
61 | </p> | ||
62 | #end | ||
63 | #end | ||
![]() |
2.1 | 64 | #end |
![]() |
1.90 | 65 | |
66 | #if($hasRight) | ||
67 | <p class="buttons text-align-right"> | ||
68 | <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow"> | ||
69 | <span class="btn-label">Edit details</span> | ||
70 | </a> | ||
71 | </p> | ||
72 | #end | ||
73 | </div> | ||
![]() |
3.1 | 74 | #if($hasRight) |
![]() |
1.90 | 75 | #set($form_start = { |
76 | "id": "homeopaths_form", | ||
77 | "product": "homeopath details", | ||
78 | "method": "post", | ||
79 | "url": "", | ||
80 | "use_captcha": "false" | ||
81 | }) | ||
![]() |
1.109 | 82 | #set($submit = { |
83 | "id" : "edit_details", | ||
84 | "button-text" : "Save changes", | ||
85 | "clean": "true", | ||
86 | "help-block" : "" | ||
87 | }) | ||
88 | #set($form_end = { | ||
89 | "use_captcha": "false" | ||
90 | }) | ||
91 | <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
92 | <div class="modal-dialog modal-dialog-centered" role="document"> | ||
93 | <div class="modal-content"> | ||
94 | #createFormStart($form_start) | ||
95 | <div class="modal-header"> | ||
96 | <h3 class="modal-title">Details</h3> | ||
97 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
98 | <span aria-hidden="true">×</span> | ||
99 | </button> | ||
100 | </div> | ||
101 | <div class="modal-body"> | ||
![]() |
3.10 | 102 | <fieldset class="fieldset"> |
103 | <address> | ||
![]() |
3.18 | 104 | $doc.getTitle()<br /> |
![]() |
3.14 | 105 | #set($addressArray = ['pmStreet','pmHousenumber','pmPostcode','pmCity','pmState','pmCounty','pmCountry']) |
106 | #set($x = {}) | ||
107 | #foreach($datapart in $addressArray) | ||
108 | #if($theDocObj.getProperty($datapart)) | ||
109 | #set($datapart4Publish = $theDocObj.getProperty($datapart).value) | ||
110 | #if($datapart == 'pmCountry') | ||
111 | #set($datapart4Publish = $datapart4Publish.toUpperCase()) | ||
112 | #end | ||
113 | #set($discard = $x.put("$datapart", $datapart4Publish)) | ||
114 | #end | ||
115 | #end | ||
![]() |
3.16 | 116 | $x['pmStreet'] $x['pmHousenumber']<br /> |
117 | $x['pmPostcode'] $x['pmCity']<br /> | ||
118 | $x['pmCounty'] $x['pmState']<br /> | ||
119 | $x['pmCountry'] | ||
![]() |
3.10 | 120 | </address> |
121 | </fieldset> | ||
![]() |
3.2 | 122 | #set($lastChild = "") |
123 | #foreach($propertyName in $classProperties.keySet()) | ||
124 | #set($item = $classProperties["$propertyName"]) | ||
![]() |
3.10 | 125 | #if($item.containsKey("disabled")) |
126 | #else | ||
127 | #set($propertyType = $item.type) | ||
128 | #set($propertyOpener = $item.opener) | ||
129 | #set($propertyParent = $item.parent) | ||
130 | #set($extraAttributes = $item.extraAttributes) | ||
131 | #set($label = $services.localization.render("homeopaths.classproperty.${propertyName}")) | ||
132 | #if($theDocObj.getProperty($propertyName) || $propertyType == "address") | ||
133 | #set($value = $theDocObj.getProperty($propertyName).value) | ||
134 | #if($propertyType == "checkbox" || $propertyType == "radio") | ||
135 | #set($value = "1") | ||
![]() |
3.2 | 136 | #end |
![]() |
3.10 | 137 | #if(!$value) |
138 | #set($value = "") | ||
139 | #end | ||
140 | #set($newElem = { | ||
141 | "id" : "$propertyName", | ||
142 | "type" : $propertyType, | ||
143 | "required" : "false", | ||
144 | "label" : "$label", | ||
145 | "data-create-xobj" : "true", | ||
146 | "data-xobj-classname" : $theClass, | ||
147 | "data-xobj-fieldname" : "$propertyName", | ||
148 | "value" : "$value" | ||
149 | }) | ||
150 | #if($extraAttributes.keySet().size() > 0) | ||
151 | #set($attrMap = $extraAttributes) | ||
152 | #foreach($attr in $attrMap.keySet()) | ||
153 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
154 | #end | ||
155 | #end | ||
156 | #if($propertyOpener) | ||
157 | #set($discard = $newElem.put("data-opener", "true")) | ||
158 | #end | ||
159 | #if($propertyParent) | ||
160 | #set($lastChild = "$key") | ||
161 | #elseif($lastChild != "") | ||
162 | #set($lastChild = "") | ||
163 | #createExpandEnd() | ||
164 | #end | ||
165 | #createFormElement($newElem) | ||
166 | #if($propertyOpener) | ||
167 | #createExpandStart($newElem $value) | ||
168 | #end | ||
![]() |
3.2 | 169 | #end |
170 | #end | ||
171 | #end | ||
![]() |
1.1 | 172 | </div> |
173 | <div class="modal-footer"> | ||
174 | <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
175 | #createSubmit($submit) | ||
176 | </div> | ||
177 | #createFormEnd($form_end) | ||
178 | </div> | ||
179 | </div> | ||
180 | </div> | ||
181 | #end | ||
![]() |
1.7 | 182 | #else |
183 | This page can not be viewed in inline mode. | ||
![]() |
1.1 | 184 | #end |
![]() |
3.2 | 185 | |
186 | #macro(createElementObjects $properties) | ||
187 | #foreach($item in $properties.keySet()) | ||
188 | #set($label = $services.localization.render("homeopaths.classproperty.${item}")) | ||
189 | #if($theDocObj.getProperty($item)) | ||
190 | #set($value = $theDocObj.getProperty($item).value) | ||
191 | #set($newElem = { | ||
192 | "id" : "$item", | ||
193 | "type" : $classProperties[$item].type, | ||
194 | "required" : "false", | ||
195 | "label" : "$label", | ||
196 | "data-create-xobj" : "true", | ||
197 | "data-xobj-classname" : $theClass, | ||
198 | "data-xobj-fieldname" : "$item", | ||
199 | "value" : "$value" | ||
200 | }) | ||
201 | #if($classProperties[$item].opener == 1) | ||
202 | #set($discard = $newElem.put("data-opener", "true")) | ||
203 | #end | ||
204 | #if($classProperties[$item].extraAttributes) | ||
205 | #set($attrMap = $classProperties[$item].extraAttributes) | ||
206 | #foreach($attr in $attrMap.keySet()) | ||
207 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
208 | #end | ||
209 | #end | ||
210 | #set($thisObj["$item"] = $newElem) | ||
211 | #end | ||
212 | #end | ||
213 | #end | ||
214 | |||
![]() |
1.1 | 215 | {{/html}} |
216 | {{/velocity}} |