Wiki source code of homeopathsSheet

Version 1.101 by Jip-jan Alunkel on March 08, 15:30

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))
Jip-jan Alunkel 1.97 96 #if($value)
97 #set($value = $theDocObj.getProperty($key).value)
98 #else
Jip-jan Alunkel 1.94 99 #set($value = "1")
100 #end
Jip-jan Alunkel 1.100 101 $value.isEmpty()
Jip-jan Alunkel 1.101 102 !$value
Jip-jan Alunkel 1.98 103 $key : $value<br />
Jip-jan Alunkel 1.85 104 #set($newElem = {
105 "id" : "$key",
Jip-jan Alunkel 1.86 106 "type" : $propertyType,
Jip-jan Alunkel 1.85 107 "required" : "false",
108 "label" : "$label",
109 "data-create-xobj" : "true",
110 "data-xobj-classname" : $theClass,
111 "data-xobj-fieldname" : "$key",
112 "value" : "$value"
113 })
114 #if($extraAttributes)
115 #set($attrMap = $extraAttributes)
116 #foreach($attr in $attrMap.keySet())
117 #set($discard = $newElem.put("$attr", $attrMap[$attr]))
118 #end
119 #end
120 #if($propertyOpener)
121 #set($discard = $newElem.put("data-opener", "true"))
122 #end
123 #if($propertyParent)
124 #set($lastChild = $key)
125 #elseif($lastChild != "")
Jip-jan Alunkel 1.91 126 ## #createExpandEnd()
Jip-jan Alunkel 1.85 127 #end
Jip-jan Alunkel 1.91 128 ## #createFormElement($newElem)
Jip-jan Alunkel 1.85 129 #if($propertyOpener)
Jip-jan Alunkel 1.91 130 ## #createExpandStart($newElem $newElem["value"])
Jip-jan Alunkel 1.85 131 #end
Jip-jan Alunkel 1.96 132 ##$theDocObj.getProperty("certification").value <br />
Jip-jan Alunkel 1.85 133 #end
134
Jip-jan Alunkel 1.70 135 #*
Jip-jan Alunkel 1.31 136 #if($theDocObj.getProperty($property))
Jip-jan Alunkel 1.17 137 <p class="property">
Jip-jan Alunkel 1.31 138 #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout.
139 #if($property == "pmStreet") ## Difference with added housenumber because of the streetaddress layout.
Jip-jan Alunkel 1.17 140 <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 141 #else
Jip-jan Alunkel 1.17 142 <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span>
Jip-jan Alunkel 1.31 143 #end
144 </p>
Jip-jan Alunkel 1.16 145 #end
Jip-jan Alunkel 1.13 146 #end
Jip-jan Alunkel 1.70 147 *#
148
Jip-jan Alunkel 1.12 149 #end
Jip-jan Alunkel 1.11 150
Jip-jan Alunkel 1.1 151 #set($submit = {
152 "id" : "edit_details",
153 "button-text" : "Save changes",
154 "clean": "true",
155 "help-block" : ""
156 })
157 #set($form_end = {
158 "use_captcha": "false"
159 })
160 <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
161 <div class="modal-dialog modal-dialog-centered" role="document">
162 <div class="modal-content">
163 #createFormStart($form_start)
164 <div class="modal-header">
165 <h3 class="modal-title">Details</h3>
166 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
167 <span aria-hidden="true">&times;</span>
168 </button>
169 </div>
170 <div class="modal-body">
Jip-jan Alunkel 1.23 171 #foreach($obj in $thisObj)
Jip-jan Alunkel 1.63 172 #createFormElement($obj)
Jip-jan Alunkel 1.23 173 #end
Jip-jan Alunkel 1.1 174 </div>
175 <div class="modal-footer">
176 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
177 #createSubmit($submit)
178 </div>
179 #createFormEnd($form_end)
180 </div>
181 </div>
182 </div>
183 #end
Jip-jan Alunkel 1.7 184 #else
185 This page can not be viewed in inline mode.
Jip-jan Alunkel 1.1 186 #end
Jip-jan Alunkel 1.60 187
Jip-jan Alunkel 1.85 188 #macro(createElementObject $properties)
Jip-jan Alunkel 1.60 189 #foreach($item in $properties.keySet())
190 #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
191 #if($theDocObj.getProperty($item))
192 #set($value = $theDocObj.getProperty($item).value)
193 #set($newElem = {
194 "id" : "$item",
195 "type" : $classProperties[$item].type,
196 "required" : "false",
197 "label" : "$label",
198 "data-create-xobj" : "true",
199 "data-xobj-classname" : $theClass,
200 "data-xobj-fieldname" : "$item",
201 "value" : "$value"
202 })
203 #if($classProperties[$item].opener == 1)
204 #set($discard = $newElem.put("data-opener", "true"))
205 #end
206 #if($classProperties[$item].extraAttributes)
207 #set($attrMap = $classProperties[$item].extraAttributes)
208 #foreach($attr in $attrMap.keySet())
209 #set($discard = $newElem.put("$attr", $attrMap[$attr]))
210 #end
211 #end
212 #set($thisObj["$item"] = $newElem)
213 #end
214 #end
215 #end
216
Jip-jan Alunkel 1.1 217 {{/html}}
218 {{/velocity}}