Wiki source code of homeopathsSheet

Version 3.35 by Jip-jan Alunkel on March 09, 03:55

Show last authors
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 pagemakerOffspring = "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 <div id="${spaceTitle}" class="box sheet_properties">
34 <h2>Details</h2>
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"))
47 #set($xa["$item"]) = $theDocObj.getProperty("$item").value
48 #end
49 #end
50
51 ## The classProperties Map has to be in the order of how you want the form elements to appear in the form.
52 #set($classProperties = {
53 '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.'}},
54 'editAddress': {'type': 'checkbox', 'opener': 1, 'classless': 1, 'checked': 0},
55
56 '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.'}},
57 'pmStreet': {'type': 'text', 'disabled': 1},
58 'pmHousenumber': {'type': 'text', 'disabled': 1},
59 'pmPostcode': {'type': 'text', 'disabled': 1},
60 'pmCity': {'type': 'text', 'disabled': 1},
61 'pmCounty': {'type': 'text', 'disabled': 1},
62 'pmState': {'type': 'text', 'disabled': 1},
63 'pmCountry': {'type': 'text', 'disabled': 1},
64 'certification': {'type': 'checkbox', 'opener': 1},
65 'certificationFrom': {'type': 'text', 'parent': 'certification'}
66 })
67 #foreach($property in $classProperties.keySet())
68 #if($theDocObj.getProperty($property))
69 <p class="property">
70 #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout.
71 #if($property == "pmStreet")
72 <span class="property-name">$services.localization.render("homeopaths.classproperty.address")</span> <span class="property-value">$doc.display($property) $doc.display("pmHousenumber")</span>
73 #elseif($property == "practiceName") ## Difference, should receive the title from the page.
74 <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.getTitle()</span>
75 #else ## Normal situation.
76 <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span>
77 #end
78 </p>
79 #end
80 #end
81 #end
82
83 #if($hasRight)
84 <p class="buttons text-align-right">
85 <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow">
86 <span class="btn-label">Edit details</span>
87 </a>
88 </p>
89 #end
90 </div>
91 #if($hasRight)
92 #set($form_start = {
93 "id": "homeopaths_form",
94 "product": "homeopath details",
95 "method": "post",
96 "url": "",
97 "use_captcha": "false"
98 })
99 #set($submit = {
100 "id" : "edit_details",
101 "button-text" : "Save changes",
102 "clean": "true",
103 "help-block" : ""
104 })
105 #set($form_end = {
106 "use_captcha": "false"
107 })
108 <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
109 <div class="modal-dialog modal-dialog-centered" role="document">
110 <div class="modal-content">
111 #createFormStart($form_start)
112 <div class="modal-header">
113 <h3 class="modal-title">Details</h3>
114 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
115 <span aria-hidden="true">&times;</span>
116 </button>
117 </div>
118 <div class="modal-body">
119 <fieldset class="fieldset">
120 <address>
121 $doc.getTitle()<br />
122 #set($addressArray = ['pmStreet','pmHousenumber','pmPostcode','pmCity','pmState','pmCounty','pmCountry'])
123 #set($x = {})
124 #foreach($datapart in $addressArray)
125 #if($theDocObj.getProperty($datapart))
126 #set($datapart4Publish = $theDocObj.getProperty($datapart).value)
127 #if($datapart == 'pmCountry')
128 #set($datapart4Publish = $datapart4Publish.toUpperCase())
129 #end
130 #set($discard = $x.put("$datapart", $datapart4Publish))
131 #end
132 #end
133 $x['pmStreet'] $x['pmHousenumber']<br />
134 $x['pmPostcode'] $x['pmCity']<br />
135 $x['pmCounty'] $x['pmState']<br />
136 $x['pmCountry']
137 </address>
138 </fieldset>
139 #set($lastChild = "")
140 #foreach($propertyName in $classProperties.keySet())
141 #set($item = $classProperties["$propertyName"])
142 #if($item.containsKey("disabled"))
143 #else
144 #set($propertyType = $item.type)
145 #set($propertyChecked = $item.checked)
146 #set($propertyOpener = $item.opener)
147 #set($propertyParent = $item.parent)
148 #set($extraAttributes = $item.extraAttributes)
149 #set($label = $services.localization.render("homeopaths.classproperty.${propertyName}"))
150 #if($propertyType == "checkbox" || $propertyType == "radio")
151 #set($value = "1")
152 #elseif($theDocObj.getProperty($propertyName) || $propertyType == "address") ## 'address' is not a property in the current class
153 #set($value = $theDocObj.getProperty($propertyName).value)
154 #end
155 #if(!$value)
156 #set($value = "")
157 #end
158 #if($item.containsKey("classless"))
159 #set($newElem = {
160 "id" : "$propertyName",
161 "type" : $propertyType,
162 "required" : "false",
163 "label" : "$label",
164 "value" : "$value"
165 })
166 #else
167 #set($newElem = {
168 "id" : "$propertyName",
169 "type" : $propertyType,
170 "required" : "false",
171 "label" : "$label",
172 "data-create-xobj" : "true",
173 "data-xobj-classname" : $theClass,
174 "data-xobj-fieldname" : "$propertyName",
175 "value" : "$value"
176 })
177 #end
178 #if($extraAttributes.keySet().size() > 0)
179 #set($attrMap = $extraAttributes)
180 #foreach($attr in $attrMap.keySet())
181 #set($discard = $newElem.put("$attr", $attrMap[$attr]))
182 #end
183 #end
184 #if($propertyChecked)
185 #set($discard = $newElem.put("data-checked", "false"))
186 #end
187 #if($propertyOpener)
188 #set($discard = $newElem.put("data-opener", "true"))
189 #end
190 #if($propertyParent)
191 #set($lastChild = "$key")
192 #elseif($lastChild != "")
193 #set($lastChild = "")
194 #createExpandEnd()
195 #end
196 #createFormElement($newElem)
197 #if($propertyOpener)
198 #createExpandStart($newElem $value)
199 #end
200 #end
201 #end
202 </div>
203 <div class="modal-footer">
204 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
205 #createSubmit($submit)
206 </div>
207 #createFormEnd($form_end)
208 </div>
209 </div>
210 </div>
211 #end
212 #else
213 This page can not be viewed in inline mode.
214 #end
215
216 #macro(createElementObjects $properties)
217 #foreach($item in $properties.keySet())
218 #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
219 #if($theDocObj.getProperty($item))
220 #set($value = $theDocObj.getProperty($item).value)
221 #set($newElem = {
222 "id" : "$item",
223 "type" : $classProperties[$item].type,
224 "required" : "false",
225 "label" : "$label",
226 "data-create-xobj" : "true",
227 "data-xobj-classname" : $theClass,
228 "data-xobj-fieldname" : "$item",
229 "value" : "$value"
230 })
231 #if($classProperties[$item].opener == 1)
232 #set($discard = $newElem.put("data-opener", "true"))
233 #end
234 #if($classProperties[$item].extraAttributes)
235 #set($attrMap = $classProperties[$item].extraAttributes)
236 #foreach($attr in $attrMap.keySet())
237 #set($discard = $newElem.put("$attr", $attrMap[$attr]))
238 #end
239 #end
240 #set($thisObj["$item"] = $newElem)
241 #end
242 #end
243 #end
244
245 {{/html}}
246 {{/velocity}}