Code source wiki de homeopathsSheet

Version 3.60 par Jip-jan Alunkel le mars 09, 16:14

Afficher les derniers auteurs
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 <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 = {
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 ## The classProperties Map has to be in the order of how you want the form elements to appear in the form.
51 #set($certify = $theDocObj.getProperty("certification").value) ## Dit kan beter ergens anders gebeuren
52 #set($cert=$numbertool.toNumber($certify).intValue())
53 #set($classProperties = {
54 'editAddress': {'type': 'checkbox', 'opener': 1, 'classless': 1, 'checked': 0},
55 '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.'}},
56 '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.'}},
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, 'checked': $cert},
65 'certificationFrom': {'type': 'text', 'parent': 'certification'}
66 })
67 #createAddress($theClass)
68 #set($properties = ['certification','certificationFrom'])
69 #foreach($property in $properties)
70 #if($theDocObj.getProperty($property))
71 <p class="property">
72 <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span>
73 </p>
74 #end
75 #end
76 #if($hasRight)
77 <p class="buttons text-align-right">
78 <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow">
79 <span class="btn-label">Edit details</span>
80 </a>
81 </p>
82 #end
83 </div>
84 #if($hasRight)
85 #set($form_start = {
86 "id": "homeopaths_form",
87 "product": "homeopath details",
88 "method": "post",
89 "url": "",
90 "use_captcha": "false"
91 })
92 #set($submit = {
93 "id" : "edit_details",
94 "button-text" : "Save changes",
95 "clean": "true",
96 "help-block" : ""
97 })
98 #set($form_end = {
99 "use_captcha": "false"
100 })
101 <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
102 <div class="modal-dialog modal-dialog-centered" role="document">
103 <div class="modal-content">
104 #createFormStart($form_start)
105 <div class="modal-header">
106 <h3 class="modal-title">Details</h3>
107 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
108 <span aria-hidden="true">&times;</span>
109 </button>
110 </div>
111 <div class="modal-body">
112 <fieldset class="fieldset">
113 #createAddress($theClass)
114 </fieldset>
115 #set($lastChild = "")
116 #foreach($propertyName in $classProperties.keySet())
117 #set($item = $classProperties["$propertyName"])
118 #if($item.containsKey("disabled"))
119 #else
120 #set($propertyType = $item.type)
121 #set($propertyChecked = $item.checked)
122 #set($propertyOpener = $item.opener)
123 #set($propertyParent = $item.parent)
124 #set($extraAttributes = $item.extraAttributes)
125 #set($label = $services.localization.render("homeopaths.classproperty.${propertyName}"))
126 #if($propertyType == "checkbox" || $propertyType == "radio")
127 #set($value = "1")
128 #elseif($theDocObj.getProperty($propertyName) || $propertyType == "address") ## 'address' is not a property in the current class
129 #set($value = $theDocObj.getProperty($propertyName).value)
130 #end
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}}