Wiki source code of homeopathsSheet
Version 1.129 by Jip-jan Alunkel on March 08, 18:27
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'}}, |
![]() |
1.125 | 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.'}}}, |
![]() |
1.124 | 39 | {'pmStreet': {'type': 'text'}}, |
![]() |
1.115 | 40 | {'pmHousenumber': {'type': 'text'}}, |
![]() |
1.82 | 41 | {'pmPostcode': {'type': 'text'}}, |
42 | {'pmCity': {'type': 'text'}}, | ||
![]() |
1.115 | 43 | {'pmCounty': {'type': 'text'}}, |
![]() |
1.82 | 44 | {'pmState': {'type': 'text'}}, |
45 | {'pmCountry': {'type': 'text'}}, | ||
![]() |
1.70 | 46 | {'certification': {'type': 'checkbox', 'opener': 1}}, |
![]() |
1.82 | 47 | {'certificationFrom': {'type': 'text', 'parent': 'certification'}} |
![]() |
1.70 | 48 | ]) |
![]() |
1.90 | 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 | }) | ||
![]() |
1.109 | 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"> | ||
![]() |
1.85 | 86 | #set($lastChild = "") |
![]() |
1.70 | 87 | #foreach($property in $classProperties) |
![]() |
1.84 | 88 | #foreach($item in $property.keySet()) |
89 | #set($key = $item) | ||
90 | #end | ||
![]() |
1.79 | 91 | #foreach($item in $property.values()) |
![]() |
1.81 | 92 | #set($propertyType = $item.type) |
93 | #set($propertyOpener = $item.opener) | ||
94 | #set($propertyParent = $item.parent) | ||
![]() |
1.85 | 95 | #set($extraAttributes = $item.extraAttributes) |
![]() |
1.74 | 96 | #end |
![]() |
1.85 | 97 | #set($label = $services.localization.render("homeopaths.classproperty.${key}")) |
98 | #if($theDocObj.getProperty($key)) | ||
![]() |
1.102 | 99 | #set($value = $theDocObj.getProperty($key).value) |
![]() |
1.107 | 100 | #if(!$value) |
![]() |
1.118 | 101 | #set($value = "1") |
![]() |
1.94 | 102 | #end |
![]() |
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 | }) | ||
![]() |
1.129 | 113 | #if($extraAttributes.keySet().size()) |
![]() |
1.85 | 114 | #set($attrMap = $extraAttributes) |
115 | #foreach($attr in $attrMap.keySet()) | ||
116 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
117 | #end | ||
![]() |
1.128 | 118 | $newElem |
![]() |
1.85 | 119 | #end |
120 | #if($propertyOpener) | ||
121 | #set($discard = $newElem.put("data-opener", "true")) | ||
122 | #end | ||
123 | #if($propertyParent) | ||
![]() |
1.114 | 124 | #set($lastChild = "$key") |
![]() |
1.85 | 125 | #elseif($lastChild != "") |
![]() |
1.110 | 126 | #set($lastChild = "") |
![]() |
1.116 | 127 | #createExpandEnd() |
![]() |
1.85 | 128 | #end |
![]() |
1.109 | 129 | #createFormElement($newElem) |
![]() |
1.85 | 130 | #if($propertyOpener) |
![]() |
1.116 | 131 | #createExpandStart($newElem $newElem["value"]) |
![]() |
1.85 | 132 | #end |
133 | #end | ||
![]() |
1.12 | 134 | #end |
![]() |
1.1 | 135 | </div> |
136 | <div class="modal-footer"> | ||
137 | <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
138 | #createSubmit($submit) | ||
139 | </div> | ||
140 | #createFormEnd($form_end) | ||
141 | </div> | ||
142 | </div> | ||
143 | </div> | ||
144 | #end | ||
![]() |
1.7 | 145 | #else |
146 | This page can not be viewed in inline mode. | ||
![]() |
1.1 | 147 | #end |
![]() |
1.60 | 148 | |
![]() |
1.120 | 149 | #macro(createElementObjects $properties) |
![]() |
1.60 | 150 | #foreach($item in $properties.keySet()) |
151 | #set($label = $services.localization.render("homeopaths.classproperty.${item}")) | ||
152 | #if($theDocObj.getProperty($item)) | ||
153 | #set($value = $theDocObj.getProperty($item).value) | ||
154 | #set($newElem = { | ||
155 | "id" : "$item", | ||
156 | "type" : $classProperties[$item].type, | ||
157 | "required" : "false", | ||
158 | "label" : "$label", | ||
159 | "data-create-xobj" : "true", | ||
160 | "data-xobj-classname" : $theClass, | ||
161 | "data-xobj-fieldname" : "$item", | ||
162 | "value" : "$value" | ||
163 | }) | ||
164 | #if($classProperties[$item].opener == 1) | ||
165 | #set($discard = $newElem.put("data-opener", "true")) | ||
166 | #end | ||
167 | #if($classProperties[$item].extraAttributes) | ||
168 | #set($attrMap = $classProperties[$item].extraAttributes) | ||
169 | #foreach($attr in $attrMap.keySet()) | ||
170 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
171 | #end | ||
172 | #end | ||
173 | #set($thisObj["$item"] = $newElem) | ||
174 | #end | ||
175 | #end | ||
176 | #end | ||
177 | |||
![]() |
1.1 | 178 | {{/html}} |
179 | {{/velocity}} |