Wiki-Quellcode von homeopathsSheet
Version 3.77 von Jip-jan Alunkel am März 09, 17:27
Zeige letzte Bearbeiter
author | version | line-number | content |
---|---|---|---|
1 | {{include reference="assets.pagemaker.macros"/}} | ||
2 | |||
3 | {{velocity}} | ||
4 | #set($discard = $services.localization.use('document', 'assets.global.translations')) | ||
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'})) | ||
8 | #set($theDoc = $xwiki.getDocument("${doc.fullName}").getTranslatedDocument()) | ||
9 | #set($isInline = $xcontext.action == 'edit' && $request.get('editor') == 'inline') | ||
10 | #set($theClass = "homeopaths.Code.homeopathsClass") | ||
11 | ## Create object (important for sheet binding, do not remove) | ||
12 | #set($theDocObj = $doc.getObject($theClass, true)) | ||
13 | #set($hasRight = !$isGuest && ($theDocObj.getProperty('user').value == $context.getUser() || $hasAdmin)) | ||
14 | $theDoc.getContent() | ||
15 | {{html wiki="true" clean="false"}} | ||
16 | #if(!$isGuest) | ||
17 | <script> | ||
18 | var pmMenuCreate = "disable"; | ||
19 | </script> | ||
20 | #end | ||
21 | #if($hasRight) | ||
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> | ||
25 | <span class="btn-label">Edit content</span> | ||
26 | </a> | ||
27 | </p> | ||
28 | #end | ||
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 | <h2 class="inline-data-summary">$services.localization.render("homeopaths.inlineDataSummary.sheet_properties")</h2> | ||
34 | <div id="${spaceTitle}" class="sheet_properties inline-data-summary"> | ||
35 | #set($xa = {'pmLatlong': '','pmCountry': '','pmState': '','pmCounty': '','pmPostcode': '','pmCity': '','pmStreet': '','pmHousenumber': ''}) | ||
36 | #foreach($item in $xa.keySet()) | ||
37 | #if($theDocObj.getProperty("$item")) | ||
38 | #set($xa["$item"] = $theDocObj.getProperty("$item").value) | ||
39 | #end | ||
40 | #end | ||
41 | ## The classProperties Map has to be in the order of how you want the form elements to appear in the form. | ||
42 | #set($classProperties = { | ||
43 | 'editAddress': {'type': 'checkbox', 'opener': 1, 'classless': 1, 'checked': 0}, | ||
44 | '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.'}}, | ||
45 | '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.'}}, | ||
46 | 'pmStreet': {'type': 'text', 'disabled': 1}, | ||
47 | 'pmHousenumber': {'type': 'text', 'disabled': 1}, | ||
48 | 'pmPostcode': {'type': 'text', 'disabled': 1}, | ||
49 | 'pmCity': {'type': 'text', 'disabled': 1}, | ||
50 | 'pmCounty': {'type': 'text', 'disabled': 1}, | ||
51 | 'pmState': {'type': 'text', 'disabled': 1}, | ||
52 | 'pmCountry': {'type': 'text', 'disabled': 1}, | ||
53 | 'certification': {'type': 'checkbox', 'opener': 1}, | ||
54 | 'certificationFrom': {'type': 'text', 'parent': 'certification'} | ||
55 | }) | ||
56 | #createAddress($theClass) | ||
57 | #set($properties = ['certification','certificationFrom']) | ||
58 | #foreach($property in $properties) | ||
59 | #if($theDocObj.getProperty($property)) | ||
60 | <p class="property"> | ||
61 | <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span> | ||
62 | </p> | ||
63 | #end | ||
64 | #end | ||
65 | #if($hasRight) | ||
66 | <p class="buttons text-align-right"> | ||
67 | <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow"> | ||
68 | <span class="btn-label">Edit details</span> | ||
69 | </a> | ||
70 | </p> | ||
71 | #end | ||
72 | </div> | ||
73 | #if($hasRight) | ||
74 | #set($form_start = { | ||
75 | "id": "homeopaths_form", | ||
76 | "product": "homeopath details", | ||
77 | "method": "post", | ||
78 | "url": "", | ||
79 | "use_captcha": "false" | ||
80 | }) | ||
81 | #set($submit = { | ||
82 | "id" : "edit_details", | ||
83 | "button-text" : "Save changes", | ||
84 | "clean": "true", | ||
85 | "help-block" : "" | ||
86 | }) | ||
87 | #set($form_end = { | ||
88 | "use_captcha": "false" | ||
89 | }) | ||
90 | <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
91 | <div class="modal-dialog modal-dialog-centered" role="document"> | ||
92 | <div class="modal-content"> | ||
93 | #createFormStart($form_start) | ||
94 | <div class="modal-header"> | ||
95 | <h3 class="modal-title">Details</h3> | ||
96 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
97 | <span aria-hidden="true">×</span> | ||
98 | </button> | ||
99 | </div> | ||
100 | <div class="modal-body"> | ||
101 | <fieldset class="fieldset"> | ||
102 | #createAddress($theClass) | ||
103 | </fieldset> | ||
104 | #set($lastChild = "") | ||
105 | #foreach($propertyName in $classProperties.keySet()) | ||
106 | #set($item = $classProperties["$propertyName"]) | ||
107 | #set($propertyType = $item.type) | ||
108 | #if($item.containsKey("disabled")) | ||
109 | #else | ||
110 | #if($propertyType == "checkbox") | ||
111 | #set($value = "1") | ||
112 | #if($item.containsKey("classless")) | ||
113 | #if(!$item.containsKey("checked")) | ||
114 | #set($item["checked"] = '0') | ||
115 | #end | ||
116 | #else | ||
117 | #set($checkboxPropVal = $theDocObj.getProperty($propertyName).value) | ||
118 | #set($item["checked"] = "$checkboxPropVal") | ||
119 | #end | ||
120 | #end | ||
121 | #if($theDocObj.getProperty($propertyName) || $propertyType == "address") ## 'address' is not a property in the current class | ||
122 | #if($propertyType != "checkbox") | ||
123 | #set($value = $theDocObj.getProperty($propertyName).value) | ||
124 | #end | ||
125 | #end | ||
126 | #set($propertyChecked = $item.checked) | ||
127 | #set($propertyOpener = $item.opener) | ||
128 | #set($propertyParent = $item.parent) | ||
129 | #set($extraAttributes = $item.extraAttributes) | ||
130 | #set($label = $services.localization.render("homeopaths.classproperty.${propertyName}")) | ||
131 | #if(!$value) | ||
132 | #set($value = "") | ||
133 | #end | ||
134 | #if($item.containsKey("classless")) | ||
135 | #set($newElem = { | ||
136 | "id" : "$propertyName", | ||
137 | "type" : $propertyType, | ||
138 | "required" : "false", | ||
139 | "label" : "$label", | ||
140 | "value" : "$value" | ||
141 | }) | ||
142 | #else | ||
143 | #set($newElem = { | ||
144 | "id" : "$propertyName", | ||
145 | "type" : $propertyType, | ||
146 | "required" : "false", | ||
147 | "label" : "$label", | ||
148 | "data-create-xobj" : "true", | ||
149 | "data-xobj-classname" : $theClass, | ||
150 | "data-xobj-fieldname" : "$propertyName", | ||
151 | "value" : "$value" | ||
152 | }) | ||
153 | #end | ||
154 | #if($extraAttributes.keySet().size() > 0) | ||
155 | #set($attrMap = $extraAttributes) | ||
156 | #foreach($attr in $attrMap.keySet()) | ||
157 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
158 | #end | ||
159 | #end | ||
160 | #if($propertyChecked == '1') | ||
161 | #set($discard = $newElem.put("data-checked", "true")) | ||
162 | #else | ||
163 | #set($discard = $newElem.put("data-checked", "false")) | ||
164 | #end | ||
165 | #if($propertyOpener) | ||
166 | #set($discard = $newElem.put("data-opener", "true")) | ||
167 | #end | ||
168 | #if($propertyParent) | ||
169 | #set($lastChild = "$key") | ||
170 | #elseif($lastChild != "") | ||
171 | #set($lastChild = "") | ||
172 | #createExpandEnd() | ||
173 | #end | ||
174 | #createFormElement($newElem) | ||
175 | #if($propertyOpener) | ||
176 | #createExpandStart($newElem $value) | ||
177 | #end | ||
178 | #end | ||
179 | #end | ||
180 | </div> | ||
181 | <div class="modal-footer"> | ||
182 | <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
183 | #createSubmit($submit) | ||
184 | </div> | ||
185 | #createFormEnd($form_end) | ||
186 | </div> | ||
187 | </div> | ||
188 | </div> | ||
189 | #end | ||
190 | #else | ||
191 | <p> | ||
192 | This page can not be viewed in inline mode. | ||
193 | </p> | ||
194 | #end | ||
195 | |||
196 | #macro(createAddress $className) | ||
197 | #set($docObj = $doc.getObject($className)) | ||
198 | <address> | ||
199 | $doc.getTitle()<br /> | ||
200 | #set($addressArray = ['pmStreet','pmHousenumber','pmPostcode','pmCity','pmState','pmCounty','pmCountry']) | ||
201 | #set($x = {}) | ||
202 | #foreach($datapart in $addressArray) | ||
203 | #if($docObj.getProperty($datapart)) | ||
204 | #set($datapart4Publish = $docObj.getProperty($datapart).value) | ||
205 | #if($datapart == 'pmCountry') | ||
206 | #set($datapart4Publish = $datapart4Publish.toUpperCase()) | ||
207 | #end | ||
208 | #set($discard = $x.put("$datapart", $datapart4Publish)) | ||
209 | #end | ||
210 | #end | ||
211 | $x['pmStreet'] $x['pmHousenumber']<br /> | ||
212 | $x['pmPostcode'] $x['pmCity']<br /> | ||
213 | $x['pmCounty'] $x['pmState']<br /> | ||
214 | $x['pmCountry'] | ||
215 | </address> | ||
216 | #end | ||
217 | {{/html}} | ||
218 | {{/velocity}} |