Wiki source code of homeopathsSheet
Version 1.98 by Jip-jan Alunkel on March 08, 15:24
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
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'})) | ||
![]() |
1.5 | 8 | #set($theDoc = $xwiki.getDocument("${doc.fullName}").getTranslatedDocument()) |
![]() |
1.1 | 9 | #set($isInline = $xcontext.action == 'edit' && $request.get('editor') == 'inline') |
![]() |
1.60 | 10 | #set($theClass = "homeopaths.Code.homeopathsClass") |
![]() |
1.5 | 11 | ## Create object (important for sheet binding, do not remove) |
![]() |
1.60 | 12 | #set($theDocObj = $doc.getObject($theClass, true)) |
![]() |
1.7 | 13 | #set($hasRight = !$isGuest && ($theDocObj.getProperty('user').value == $context.getUser() || $hasAdmin)) |
![]() |
1.5 | 14 | $theDoc.getContent() |
![]() |
1.4 | 15 | {{html wiki="true" clean="false"}} |
![]() |
1.7 | 16 | #if(!$isGuest) |
![]() |
1.4 | 17 | <script> |
18 | var pagemakerOffspring = "disable"; | ||
19 | </script> | ||
![]() |
1.7 | 20 | #end |
21 | #if($hasRight) | ||
![]() |
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> | ||
![]() |
1.7 | 28 | #end |
![]() |
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> | ||
![]() |
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 = [ | ||
![]() |
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'}}, | ||
![]() |
1.70 | 45 | {'certification': {'type': 'checkbox', 'opener': 1}}, |
![]() |
1.82 | 46 | {'certificationFrom': {'type': 'text', 'parent': 'certification'}} |
![]() |
1.70 | 47 | ]) |
![]() |
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 | *# | ||
![]() |
1.85 | 82 | #set($lastChild = "") |
![]() |
1.70 | 83 | #foreach($property in $classProperties) |
![]() |
1.84 | 84 | #foreach($item in $property.keySet()) |
85 | #set($key = $item) | ||
86 | #end | ||
![]() |
1.79 | 87 | #foreach($item in $property.values()) |
![]() |
1.81 | 88 | #set($propertyType = $item.type) |
89 | #set($propertyOpener = $item.opener) | ||
90 | #set($propertyParent = $item.parent) | ||
![]() |
1.85 | 91 | #set($extraAttributes = $item.extraAttributes) |
![]() |
1.74 | 92 | #end |
![]() |
1.85 | 93 | #set($label = $services.localization.render("homeopaths.classproperty.${key}")) |
94 | |||
95 | #if($theDocObj.getProperty($key)) | ||
![]() |
1.97 | 96 | |
97 | #if($value) | ||
98 | #set($value = $theDocObj.getProperty($key).value) | ||
99 | #else | ||
![]() |
1.94 | 100 | #set($value = "1") |
101 | #end | ||
![]() |
1.98 | 102 | $key : $value<br /> |
![]() |
1.85 | 103 | #set($newElem = { |
104 | "id" : "$key", | ||
![]() |
1.86 | 105 | "type" : $propertyType, |
![]() |
1.85 | 106 | "required" : "false", |
107 | "label" : "$label", | ||
108 | "data-create-xobj" : "true", | ||
109 | "data-xobj-classname" : $theClass, | ||
110 | "data-xobj-fieldname" : "$key", | ||
111 | "value" : "$value" | ||
112 | }) | ||
113 | #if($extraAttributes) | ||
114 | #set($attrMap = $extraAttributes) | ||
115 | #foreach($attr in $attrMap.keySet()) | ||
116 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
117 | #end | ||
118 | #end | ||
119 | #if($propertyOpener) | ||
120 | #set($discard = $newElem.put("data-opener", "true")) | ||
121 | #end | ||
122 | #if($propertyParent) | ||
123 | #set($lastChild = $key) | ||
124 | #elseif($lastChild != "") | ||
![]() |
1.91 | 125 | ## #createExpandEnd() |
![]() |
1.85 | 126 | #end |
![]() |
1.91 | 127 | ## #createFormElement($newElem) |
![]() |
1.85 | 128 | #if($propertyOpener) |
![]() |
1.91 | 129 | ## #createExpandStart($newElem $newElem["value"]) |
![]() |
1.85 | 130 | #end |
![]() |
1.96 | 131 | ##$theDocObj.getProperty("certification").value <br /> |
![]() |
1.85 | 132 | #end |
133 | |||
![]() |
1.70 | 134 | #* |
![]() |
1.31 | 135 | #if($theDocObj.getProperty($property)) |
![]() |
1.17 | 136 | <p class="property"> |
![]() |
1.31 | 137 | #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout. |
138 | #if($property == "pmStreet") ## Difference with added housenumber because of the streetaddress layout. | ||
![]() |
1.17 | 139 | <span class="property-name">$services.localization.render("homeopaths.classproperty.address")</span> <span class="property-value">$doc.display($property) $doc.display("pmHousenumber")</span> |
![]() |
1.31 | 140 | #else |
![]() |
1.17 | 141 | <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span> |
![]() |
1.31 | 142 | #end |
143 | </p> | ||
![]() |
1.16 | 144 | #end |
![]() |
1.13 | 145 | #end |
![]() |
1.70 | 146 | *# |
147 | |||
![]() |
1.12 | 148 | #end |
![]() |
1.11 | 149 | |
![]() |
1.1 | 150 | #set($submit = { |
151 | "id" : "edit_details", | ||
152 | "button-text" : "Save changes", | ||
153 | "clean": "true", | ||
154 | "help-block" : "" | ||
155 | }) | ||
156 | #set($form_end = { | ||
157 | "use_captcha": "false" | ||
158 | }) | ||
159 | <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
160 | <div class="modal-dialog modal-dialog-centered" role="document"> | ||
161 | <div class="modal-content"> | ||
162 | #createFormStart($form_start) | ||
163 | <div class="modal-header"> | ||
164 | <h3 class="modal-title">Details</h3> | ||
165 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
166 | <span aria-hidden="true">×</span> | ||
167 | </button> | ||
168 | </div> | ||
169 | <div class="modal-body"> | ||
![]() |
1.23 | 170 | #foreach($obj in $thisObj) |
![]() |
1.63 | 171 | #createFormElement($obj) |
![]() |
1.23 | 172 | #end |
![]() |
1.1 | 173 | </div> |
174 | <div class="modal-footer"> | ||
175 | <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
176 | #createSubmit($submit) | ||
177 | </div> | ||
178 | #createFormEnd($form_end) | ||
179 | </div> | ||
180 | </div> | ||
181 | </div> | ||
182 | #end | ||
![]() |
1.7 | 183 | #else |
184 | This page can not be viewed in inline mode. | ||
![]() |
1.1 | 185 | #end |
![]() |
1.60 | 186 | |
![]() |
1.85 | 187 | #macro(createElementObject $properties) |
![]() |
1.60 | 188 | #foreach($item in $properties.keySet()) |
189 | #set($label = $services.localization.render("homeopaths.classproperty.${item}")) | ||
190 | #if($theDocObj.getProperty($item)) | ||
191 | #set($value = $theDocObj.getProperty($item).value) | ||
192 | #set($newElem = { | ||
193 | "id" : "$item", | ||
194 | "type" : $classProperties[$item].type, | ||
195 | "required" : "false", | ||
196 | "label" : "$label", | ||
197 | "data-create-xobj" : "true", | ||
198 | "data-xobj-classname" : $theClass, | ||
199 | "data-xobj-fieldname" : "$item", | ||
200 | "value" : "$value" | ||
201 | }) | ||
202 | #if($classProperties[$item].opener == 1) | ||
203 | #set($discard = $newElem.put("data-opener", "true")) | ||
204 | #end | ||
205 | #if($classProperties[$item].extraAttributes) | ||
206 | #set($attrMap = $classProperties[$item].extraAttributes) | ||
207 | #foreach($attr in $attrMap.keySet()) | ||
208 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
209 | #end | ||
210 | #end | ||
211 | #set($thisObj["$item"] = $newElem) | ||
212 | #end | ||
213 | #end | ||
214 | #end | ||
215 | |||
![]() |
1.1 | 216 | {{/html}} |
217 | {{/velocity}} |