Wiki source code of homeopathsSheet
Version 1.153 by Jip-jan Alunkel on March 08, 18:56
Show last authors
author | version | line-number | content |
---|---|---|---|
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 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 | {'pmAddress': {'type': 'address', 'extraAttributes': {"aria-label": "Input and select the address of your practice", "placeholder": "$services.localization.render('homeopaths.multiword.address.placeholder')", "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.'}}}, | ||
39 | {'pmStreet': {'type': 'text'}}, | ||
40 | {'pmHousenumber': {'type': 'text'}}, | ||
41 | {'pmPostcode': {'type': 'text'}}, | ||
42 | {'pmCity': {'type': 'text'}}, | ||
43 | {'pmCounty': {'type': 'text'}}, | ||
44 | {'pmState': {'type': 'text'}}, | ||
45 | {'pmCountry': {'type': 'text'}}, | ||
46 | {'certification': {'type': 'checkbox', 'opener': 1}}, | ||
47 | {'certificationFrom': {'type': 'text', 'parent': 'certification'}} | ||
48 | ]) | ||
49 | |||
50 | #if($hasRight) | ||
51 | <p class="buttons text-align-right"> | ||
52 | <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow"> | ||
53 | <span class="btn-label">Edit details</span> | ||
54 | </a> | ||
55 | </p> | ||
56 | #end | ||
57 | </div> | ||
58 | #if($hasRight) | ||
59 | #set($form_start = { | ||
60 | "id": "homeopaths_form", | ||
61 | "product": "homeopath details", | ||
62 | "method": "post", | ||
63 | "url": "", | ||
64 | "use_captcha": "false" | ||
65 | }) | ||
66 | #set($submit = { | ||
67 | "id" : "edit_details", | ||
68 | "button-text" : "Save changes", | ||
69 | "clean": "true", | ||
70 | "help-block" : "" | ||
71 | }) | ||
72 | #set($form_end = { | ||
73 | "use_captcha": "false" | ||
74 | }) | ||
75 | <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
76 | <div class="modal-dialog modal-dialog-centered" role="document"> | ||
77 | <div class="modal-content"> | ||
78 | #createFormStart($form_start) | ||
79 | <div class="modal-header"> | ||
80 | <h3 class="modal-title">Details</h3> | ||
81 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
82 | <span aria-hidden="true">×</span> | ||
83 | </button> | ||
84 | </div> | ||
85 | <div class="modal-body"> | ||
86 | #set($lastChild = "") | ||
87 | #foreach($property in $classProperties) | ||
88 | #foreach($item in $property.keySet()) | ||
89 | #set($key = $item) | ||
90 | #end | ||
91 | #foreach($item in $property.values()) | ||
92 | #set($propertyType = $item.type) | ||
93 | #set($propertyOpener = $item.opener) | ||
94 | #set($propertyParent = $item.parent) | ||
95 | #set($extraAttributes = $item.extraAttributes) | ||
96 | #end | ||
97 | #set($label = $services.localization.render("homeopaths.classproperty.${key}")) | ||
98 | #if($theDocObj.getProperty($key) || $propertyType == "address") | ||
99 | #set($value = $theDocObj.getProperty($key).value) | ||
100 | #if(!$value) | ||
101 | $propertyType | ||
102 | #if($propertyType == "checkbox" || $propertyType == "radio") | ||
103 | #set($value = "1") | ||
104 | $propertyType - $value | ||
105 | #else | ||
106 | #set($value = "") | ||
107 | #end | ||
108 | #end | ||
109 | #set($newElem = { | ||
110 | "id" : "$key", | ||
111 | "type" : $propertyType, | ||
112 | "required" : "false", | ||
113 | "label" : "$label", | ||
114 | "data-create-xobj" : "true", | ||
115 | "data-xobj-classname" : $theClass, | ||
116 | "data-xobj-fieldname" : "$key", | ||
117 | "value" : "$value" | ||
118 | }) | ||
119 | #if($extraAttributes.keySet().size() > 0) | ||
120 | #set($attrMap = $extraAttributes) | ||
121 | #foreach($attr in $attrMap.keySet()) | ||
122 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
123 | #end | ||
124 | #end | ||
125 | #if($propertyOpener) | ||
126 | #set($discard = $newElem.put("data-opener", "true")) | ||
127 | #end | ||
128 | #if($propertyParent) | ||
129 | #set($lastChild = "$key") | ||
130 | #elseif($lastChild != "") | ||
131 | #set($lastChild = "") | ||
132 | #createExpandEnd() | ||
133 | #end | ||
134 | #createFormElement($newElem) | ||
135 | #if($propertyOpener) | ||
136 | ##$value | ||
137 | #createExpandStart($newElem $value) | ||
138 | #end | ||
139 | #end | ||
140 | #end | ||
141 | </div> | ||
142 | <div class="modal-footer"> | ||
143 | <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
144 | #createSubmit($submit) | ||
145 | </div> | ||
146 | #createFormEnd($form_end) | ||
147 | </div> | ||
148 | </div> | ||
149 | </div> | ||
150 | #end | ||
151 | #else | ||
152 | This page can not be viewed in inline mode. | ||
153 | #end | ||
154 | |||
155 | #macro(createElementObjects $properties) | ||
156 | #foreach($item in $properties.keySet()) | ||
157 | #set($label = $services.localization.render("homeopaths.classproperty.${item}")) | ||
158 | #if($theDocObj.getProperty($item)) | ||
159 | #set($value = $theDocObj.getProperty($item).value) | ||
160 | #set($newElem = { | ||
161 | "id" : "$item", | ||
162 | "type" : $classProperties[$item].type, | ||
163 | "required" : "false", | ||
164 | "label" : "$label", | ||
165 | "data-create-xobj" : "true", | ||
166 | "data-xobj-classname" : $theClass, | ||
167 | "data-xobj-fieldname" : "$item", | ||
168 | "value" : "$value" | ||
169 | }) | ||
170 | #if($classProperties[$item].opener == 1) | ||
171 | #set($discard = $newElem.put("data-opener", "true")) | ||
172 | #end | ||
173 | #if($classProperties[$item].extraAttributes) | ||
174 | #set($attrMap = $classProperties[$item].extraAttributes) | ||
175 | #foreach($attr in $attrMap.keySet()) | ||
176 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
177 | #end | ||
178 | #end | ||
179 | #set($thisObj["$item"] = $newElem) | ||
180 | #end | ||
181 | #end | ||
182 | #end | ||
183 | |||
184 | {{/html}} | ||
185 | {{/velocity}} |