Wiki source code of homeopathsSheet

Version 1.96 by Jip-jan Alunkel on March 08, 15:21

Hide last authors
Jip-jan Alunkel 1.1 1 {{include reference="assets.pagemaker.macros"/}}
2
3 {{velocity}}
4 #set($discard = $services.localization.use('document', 'homeopaths.Code.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'}))
Jip-jan Alunkel 1.5 8 #set($theDoc = $xwiki.getDocument("${doc.fullName}").getTranslatedDocument())
Jip-jan Alunkel 1.1 9 #set($isInline = $xcontext.action == 'edit' && $request.get('editor') == 'inline')
Jip-jan Alunkel 1.60 10 #set($theClass = "homeopaths.Code.homeopathsClass")
Jip-jan Alunkel 1.5 11 ## Create object (important for sheet binding, do not remove)
Jip-jan Alunkel 1.60 12 #set($theDocObj = $doc.getObject($theClass, true))
Jip-jan Alunkel 1.7 13 #set($hasRight = !$isGuest && ($theDocObj.getProperty('user').value == $context.getUser() || $hasAdmin))
Jip-jan Alunkel 1.5 14 $theDoc.getContent()
Jip-jan Alunkel 1.4 15 {{html wiki="true" clean="false"}}
Jip-jan Alunkel 1.7 16 #if(!$isGuest)
Jip-jan Alunkel 1.4 17 <script>
18 var pagemakerOffspring = "disable";
19 </script>
Jip-jan Alunkel 1.7 20 #end
21 #if($hasRight)
Jip-jan Alunkel 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>
25 <span class="btn-label">Edit contents</span>
26 </a>
27 </p>
Jip-jan Alunkel 1.7 28 #end
Jip-jan Alunkel 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>
Jip-jan Alunkel 1.70 35 ## The classProperties Map has to be in the order of how you want the form elements to appear in the form.
36 #set($classProperties = [
Jip-jan Alunkel 1.82 37 {'practiceName': {'type': 'text'}},
38 {'pmStreet': {'type': 'text'}},
39 {'pmHousenumber': {'type': 'text', 'parent': 'certification'}},
40 {'pmPostcode': {'type': 'text'}},
41 {'pmCity': {'type': 'text'}},
42 {'pmCounty': {'type': 'text', 'parent': 'certification'}},
43 {'pmState': {'type': 'text'}},
44 {'pmCountry': {'type': 'text'}},
Jip-jan Alunkel 1.70 45 {'certification': {'type': 'checkbox', 'opener': 1}},
Jip-jan Alunkel 1.82 46 {'certificationFrom': {'type': 'text', 'parent': 'certification'}}
Jip-jan Alunkel 1.70 47 ])
Jip-jan Alunkel 1.90 48
49 #if($hasRight)
50 <p class="buttons text-align-right">
51 <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow">
52 <span class="btn-label">Edit details</span>
53 </a>
54 </p>
55 #end
56 </div>
57 #if($hasRight)
58 #set($form_start = {
59 "id": "homeopaths_form",
60 "product": "homeopath details",
61 "method": "post",
62 "url": "",
63 "use_captcha": "false"
64 })
65 #* #set($thisObj = {})
66 #set($children = {})
67 #set($nonChildren = {})
68 #foreach($item in $classProperties.keySet())
69 #if($classProperties[$item].opener == 1)
70 #set($parentID = $classProperties[$item].parent)
71 #if(!$children[$parentID])
72 #set($discard = $children.put("$parentID", {}))
73 #end
74 #set($discard = $children["$parentID"].put($item, $classProperties[$item]))
75 #elseif($classProperties[$item].parent)## ???? Ws fout
76 #else
77 #set($discard = $nonChildren.put($item, $classProperties[$item]))
78 #end
79 #end
80 ## #createElementObjects($nonChildren)
81 *#
Jip-jan Alunkel 1.85 82 #set($lastChild = "")
Jip-jan Alunkel 1.70 83 #foreach($property in $classProperties)
Jip-jan Alunkel 1.84 84 #foreach($item in $property.keySet())
85 #set($key = $item)
86 #end
Jip-jan Alunkel 1.79 87 #foreach($item in $property.values())
Jip-jan Alunkel 1.81 88 #set($propertyType = $item.type)
89 #set($propertyOpener = $item.opener)
90 #set($propertyParent = $item.parent)
Jip-jan Alunkel 1.85 91 #set($extraAttributes = $item.extraAttributes)
Jip-jan Alunkel 1.74 92 #end
Jip-jan Alunkel 1.85 93 #set($label = $services.localization.render("homeopaths.classproperty.${key}"))
94
95 #if($theDocObj.getProperty($key))
96 #set($value = $theDocObj.getProperty($key).value)
Jip-jan Alunkel 1.96 97 $value
Jip-jan Alunkel 1.94 98 #if(!$value)
99 #set($value = "1")
100 #end
Jip-jan Alunkel 1.85 101 #set($newElem = {
102 "id" : "$key",
Jip-jan Alunkel 1.86 103 "type" : $propertyType,
Jip-jan Alunkel 1.85 104 "required" : "false",
105 "label" : "$label",
106 "data-create-xobj" : "true",
107 "data-xobj-classname" : $theClass,
108 "data-xobj-fieldname" : "$key",
109 "value" : "$value"
110 })
111 #if($extraAttributes)
112 #set($attrMap = $extraAttributes)
113 #foreach($attr in $attrMap.keySet())
114 #set($discard = $newElem.put("$attr", $attrMap[$attr]))
115 #end
116 #end
117 #if($propertyOpener)
118 #set($discard = $newElem.put("data-opener", "true"))
119 #end
120 #if($propertyParent)
121 #set($lastChild = $key)
122 #elseif($lastChild != "")
Jip-jan Alunkel 1.91 123 ## #createExpandEnd()
Jip-jan Alunkel 1.85 124 #end
Jip-jan Alunkel 1.91 125 ## #createFormElement($newElem)
Jip-jan Alunkel 1.85 126 #if($propertyOpener)
Jip-jan Alunkel 1.91 127 ## #createExpandStart($newElem $newElem["value"])
Jip-jan Alunkel 1.85 128 #end
Jip-jan Alunkel 1.96 129 ##$theDocObj.getProperty("certification").value <br />
Jip-jan Alunkel 1.85 130 #end
131
Jip-jan Alunkel 1.70 132 #*
Jip-jan Alunkel 1.31 133 #if($theDocObj.getProperty($property))
Jip-jan Alunkel 1.17 134 <p class="property">
Jip-jan Alunkel 1.31 135 #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout.
136 #if($property == "pmStreet") ## Difference with added housenumber because of the streetaddress layout.
Jip-jan Alunkel 1.17 137 <span class="property-name">$services.localization.render("homeopaths.classproperty.address")</span> <span class="property-value">$doc.display($property) $doc.display("pmHousenumber")</span>
Jip-jan Alunkel 1.31 138 #else
Jip-jan Alunkel 1.17 139 <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span>
Jip-jan Alunkel 1.31 140 #end
141 </p>
Jip-jan Alunkel 1.16 142 #end
Jip-jan Alunkel 1.13 143 #end
Jip-jan Alunkel 1.70 144 *#
145
Jip-jan Alunkel 1.12 146 #end
Jip-jan Alunkel 1.11 147
Jip-jan Alunkel 1.1 148 #set($submit = {
149 "id" : "edit_details",
150 "button-text" : "Save changes",
151 "clean": "true",
152 "help-block" : ""
153 })
154 #set($form_end = {
155 "use_captcha": "false"
156 })
157 <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
158 <div class="modal-dialog modal-dialog-centered" role="document">
159 <div class="modal-content">
160 #createFormStart($form_start)
161 <div class="modal-header">
162 <h3 class="modal-title">Details</h3>
163 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
164 <span aria-hidden="true">&times;</span>
165 </button>
166 </div>
167 <div class="modal-body">
Jip-jan Alunkel 1.23 168 #foreach($obj in $thisObj)
Jip-jan Alunkel 1.63 169 #createFormElement($obj)
Jip-jan Alunkel 1.23 170 #end
Jip-jan Alunkel 1.1 171 </div>
172 <div class="modal-footer">
173 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
174 #createSubmit($submit)
175 </div>
176 #createFormEnd($form_end)
177 </div>
178 </div>
179 </div>
180 #end
Jip-jan Alunkel 1.7 181 #else
182 This page can not be viewed in inline mode.
Jip-jan Alunkel 1.1 183 #end
Jip-jan Alunkel 1.60 184
Jip-jan Alunkel 1.85 185 #macro(createElementObject $properties)
Jip-jan Alunkel 1.60 186 #foreach($item in $properties.keySet())
187 #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
188 #if($theDocObj.getProperty($item))
189 #set($value = $theDocObj.getProperty($item).value)
190 #set($newElem = {
191 "id" : "$item",
192 "type" : $classProperties[$item].type,
193 "required" : "false",
194 "label" : "$label",
195 "data-create-xobj" : "true",
196 "data-xobj-classname" : $theClass,
197 "data-xobj-fieldname" : "$item",
198 "value" : "$value"
199 })
200 #if($classProperties[$item].opener == 1)
201 #set($discard = $newElem.put("data-opener", "true"))
202 #end
203 #if($classProperties[$item].extraAttributes)
204 #set($attrMap = $classProperties[$item].extraAttributes)
205 #foreach($attr in $attrMap.keySet())
206 #set($discard = $newElem.put("$attr", $attrMap[$attr]))
207 #end
208 #end
209 #set($thisObj["$item"] = $newElem)
210 #end
211 #end
212 #end
213
Jip-jan Alunkel 1.1 214 {{/html}}
215 {{/velocity}}