Wiki source code of homeopathsSheet
Version 1.89 by Jip-jan Alunkel on March 08, 15:12
Show last authors
author | version | line-number | content |
---|---|---|---|
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'})) | ||
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 contents</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 | ## The classProperties Map has to be in the order of how you want the form elements to appear in the form. | ||
36 | #set($classProperties = [ | ||
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'}}, | ||
45 | {'certification': {'type': 'checkbox', 'opener': 1}}, | ||
46 | {'certificationFrom': {'type': 'text', 'parent': 'certification'}} | ||
47 | ]) | ||
48 | #set($lastChild = "") | ||
49 | #foreach($property in $classProperties) | ||
50 | #foreach($item in $property.keySet()) | ||
51 | #set($key = $item) | ||
52 | #end | ||
53 | #foreach($item in $property.values()) | ||
54 | #set($propertyType = $item.type) | ||
55 | #set($propertyOpener = $item.opener) | ||
56 | #set($propertyParent = $item.parent) | ||
57 | #set($extraAttributes = $item.extraAttributes) | ||
58 | #end | ||
59 | #set($label = $services.localization.render("homeopaths.classproperty.${key}")) | ||
60 | |||
61 | #if($theDocObj.getProperty($key)) | ||
62 | #set($value = $theDocObj.getProperty($key).value) | ||
63 | #set($newElem = { | ||
64 | "id" : "$key", | ||
65 | "type" : $propertyType, | ||
66 | "required" : "false", | ||
67 | "label" : "$label", | ||
68 | "data-create-xobj" : "true", | ||
69 | "data-xobj-classname" : $theClass, | ||
70 | "data-xobj-fieldname" : "$key", | ||
71 | "value" : "$value" | ||
72 | }) | ||
73 | #if($extraAttributes) | ||
74 | #set($attrMap = $extraAttributes) | ||
75 | #foreach($attr in $attrMap.keySet()) | ||
76 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
77 | #end | ||
78 | #end | ||
79 | #if($propertyOpener) | ||
80 | #set($discard = $newElem.put("data-opener", "true")) | ||
81 | #end | ||
82 | #if($propertyParent) | ||
83 | #set($lastChild = $key) | ||
84 | #elseif($lastChild != "") | ||
85 | #createExpandEnd() | ||
86 | #end | ||
87 | #createFormElement($newElem) | ||
88 | #if($propertyOpener) | ||
89 | #createExpandStart($newElem $newElem["value"]) | ||
90 | #end | ||
91 | #end | ||
92 | |||
93 | #* | ||
94 | #if($theDocObj.getProperty($property)) | ||
95 | <p class="property"> | ||
96 | #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout. | ||
97 | #if($property == "pmStreet") ## Difference with added housenumber because of the streetaddress layout. | ||
98 | <span class="property-name">$services.localization.render("homeopaths.classproperty.address")</span> <span class="property-value">$doc.display($property) $doc.display("pmHousenumber")</span> | ||
99 | #else | ||
100 | <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span> | ||
101 | #end | ||
102 | </p> | ||
103 | #end | ||
104 | #end | ||
105 | *# | ||
106 | |||
107 | #end | ||
108 | |||
109 | #if($hasRight) | ||
110 | <p class="buttons text-align-right"> | ||
111 | <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow"> | ||
112 | <span class="btn-label">Edit details</span> | ||
113 | </a> | ||
114 | </p> | ||
115 | #end | ||
116 | </div> | ||
117 | #if($hasRight) | ||
118 | #set($form_start = { | ||
119 | "id": "homeopaths_form", | ||
120 | "product": "homeopath details", | ||
121 | "method": "post", | ||
122 | "url": "", | ||
123 | "use_captcha": "false" | ||
124 | }) | ||
125 | #set($thisObj = {}) | ||
126 | #set($children = {}) | ||
127 | #set($nonChildren = {}) | ||
128 | #foreach($item in $classProperties.keySet()) | ||
129 | #if($classProperties[$item].opener == 1) | ||
130 | #set($parentID = $classProperties[$item].parent) | ||
131 | #if(!$children[$parentID]) | ||
132 | #set($discard = $children.put("$parentID", {})) | ||
133 | #end | ||
134 | #set($discard = $children["$parentID"].put($item, $classProperties[$item])) | ||
135 | #elseif($classProperties[$item].parent)## ???? Ws fout | ||
136 | #else | ||
137 | #set($discard = $nonChildren.put($item, $classProperties[$item])) | ||
138 | #end | ||
139 | #end | ||
140 | ## #createElementObjects($nonChildren) | ||
141 | #set($submit = { | ||
142 | "id" : "edit_details", | ||
143 | "button-text" : "Save changes", | ||
144 | "clean": "true", | ||
145 | "help-block" : "" | ||
146 | }) | ||
147 | #set($form_end = { | ||
148 | "use_captcha": "false" | ||
149 | }) | ||
150 | <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
151 | <div class="modal-dialog modal-dialog-centered" role="document"> | ||
152 | <div class="modal-content"> | ||
153 | #createFormStart($form_start) | ||
154 | <div class="modal-header"> | ||
155 | <h3 class="modal-title">Details</h3> | ||
156 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
157 | <span aria-hidden="true">×</span> | ||
158 | </button> | ||
159 | </div> | ||
160 | <div class="modal-body"> | ||
161 | #foreach($obj in $thisObj) | ||
162 | #createFormElement($obj) | ||
163 | #end | ||
164 | </div> | ||
165 | <div class="modal-footer"> | ||
166 | <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
167 | #createSubmit($submit) | ||
168 | </div> | ||
169 | #createFormEnd($form_end) | ||
170 | </div> | ||
171 | </div> | ||
172 | </div> | ||
173 | #end | ||
174 | #else | ||
175 | This page can not be viewed in inline mode. | ||
176 | #end | ||
177 | |||
178 | #macro(createElementObject $properties) | ||
179 | #foreach($item in $properties.keySet()) | ||
180 | #set($label = $services.localization.render("homeopaths.classproperty.${item}")) | ||
181 | #if($theDocObj.getProperty($item)) | ||
182 | #set($value = $theDocObj.getProperty($item).value) | ||
183 | #set($newElem = { | ||
184 | "id" : "$item", | ||
185 | "type" : $classProperties[$item].type, | ||
186 | "required" : "false", | ||
187 | "label" : "$label", | ||
188 | "data-create-xobj" : "true", | ||
189 | "data-xobj-classname" : $theClass, | ||
190 | "data-xobj-fieldname" : "$item", | ||
191 | "value" : "$value" | ||
192 | }) | ||
193 | #if($classProperties[$item].opener == 1) | ||
194 | #set($discard = $newElem.put("data-opener", "true")) | ||
195 | #end | ||
196 | #if($classProperties[$item].extraAttributes) | ||
197 | #set($attrMap = $classProperties[$item].extraAttributes) | ||
198 | #foreach($attr in $attrMap.keySet()) | ||
199 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
200 | #end | ||
201 | #end | ||
202 | #set($thisObj["$item"] = $newElem) | ||
203 | #end | ||
204 | #end | ||
205 | #end | ||
206 | |||
207 | {{/html}} | ||
208 | {{/velocity}} |