Wiki source code of homeopathsSheet
Version 1.75 by Jip-jan Alunkel on March 08, 14:18
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 = [ | ||
37 | {'practiceName': {'type': 'text', 'opener': 0}}, | ||
38 | {'pmStreet': {'type': 'text', 'opener': 0}}, | ||
39 | {'pmHousenumber': {'type': 'text', 'opener': 0, 'parent': 'certification'}}, | ||
40 | {'pmPostcode': {'type': 'text', 'opener': 0}}, | ||
41 | {'pmCity': {'type': 'text', 'opener': 0}}, | ||
42 | {'pmCounty': {'type': 'text', 'opener': 0, 'parent': 'certification'}}, | ||
43 | {'pmState': {'type': 'text', 'opener': 0}}, | ||
44 | {'pmCountry': {'type': 'text', 'opener': 0}}, | ||
45 | {'certification': {'type': 'checkbox', 'opener': 1}}, | ||
46 | {'certificationFrom': {'type': 'text', 'opener': 0, 'parent': 'certification'}} | ||
47 | ]) | ||
48 | #foreach($property in $classProperties) | ||
![]() |
1.74 | 49 | #foreach($item in $property.keySet()) |
50 | $item | ||
51 | #end | ||
![]() |
1.75 | 52 | #set($item = $property.keySet()) |
53 | $item[0] | ||
![]() |
1.70 | 54 | #* |
![]() |
1.31 | 55 | #if($theDocObj.getProperty($property)) |
![]() |
1.17 | 56 | <p class="property"> |
![]() |
1.31 | 57 | #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout. |
58 | #if($property == "pmStreet") ## Difference with added housenumber because of the streetaddress layout. | ||
![]() |
1.17 | 59 | <span class="property-name">$services.localization.render("homeopaths.classproperty.address")</span> <span class="property-value">$doc.display($property) $doc.display("pmHousenumber")</span> |
![]() |
1.31 | 60 | #else |
![]() |
1.17 | 61 | <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span> |
![]() |
1.31 | 62 | #end |
63 | </p> | ||
![]() |
1.16 | 64 | #end |
![]() |
1.13 | 65 | #end |
![]() |
1.70 | 66 | *# |
67 | |||
![]() |
1.12 | 68 | #end |
![]() |
1.11 | 69 | |
![]() |
1.7 | 70 | #if($hasRight) |
![]() |
1.1 | 71 | <p class="buttons text-align-right"> |
72 | <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow"> | ||
73 | <span class="btn-label">Edit details</span> | ||
74 | </a> | ||
75 | </p> | ||
76 | #end | ||
77 | </div> | ||
![]() |
1.23 | 78 | #if($hasRight) |
![]() |
1.1 | 79 | #set($form_start = { |
![]() |
1.5 | 80 | "id": "homeopaths_form", |
81 | "product": "homeopath details", | ||
![]() |
1.1 | 82 | "method": "post", |
83 | "url": "", | ||
84 | "use_captcha": "false" | ||
85 | }) | ||
![]() |
1.23 | 86 | #set($thisObj = {}) |
![]() |
1.32 | 87 | #set($children = {}) |
![]() |
1.68 | 88 | #set($nonChildren = {}) |
![]() |
1.37 | 89 | #foreach($item in $classProperties.keySet()) |
![]() |
1.70 | 90 | #if($classProperties[$item].opener == 1) |
![]() |
1.57 | 91 | #set($parentID = $classProperties[$item].parent) |
![]() |
1.58 | 92 | #if(!$children[$parentID]) |
![]() |
1.55 | 93 | #set($discard = $children.put("$parentID", {})) |
94 | #end | ||
![]() |
1.53 | 95 | #set($discard = $children["$parentID"].put($item, $classProperties[$item])) |
![]() |
1.69 | 96 | #elseif($classProperties[$item].parent)## ???? Ws fout |
![]() |
1.68 | 97 | #else |
98 | #set($discard = $nonChildren.put($item, $classProperties[$item])) | ||
![]() |
1.32 | 99 | #end |
100 | #end | ||
![]() |
1.69 | 101 | #createElementObjects($nonChildren) |
![]() |
1.1 | 102 | #set($submit = { |
103 | "id" : "edit_details", | ||
104 | "button-text" : "Save changes", | ||
105 | "clean": "true", | ||
106 | "help-block" : "" | ||
107 | }) | ||
108 | #set($form_end = { | ||
109 | "use_captcha": "false" | ||
110 | }) | ||
111 | <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
112 | <div class="modal-dialog modal-dialog-centered" role="document"> | ||
113 | <div class="modal-content"> | ||
114 | #createFormStart($form_start) | ||
115 | <div class="modal-header"> | ||
116 | <h3 class="modal-title">Details</h3> | ||
117 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
118 | <span aria-hidden="true">×</span> | ||
119 | </button> | ||
120 | </div> | ||
121 | <div class="modal-body"> | ||
![]() |
1.23 | 122 | #foreach($obj in $thisObj) |
![]() |
1.63 | 123 | #createFormElement($obj) |
![]() |
1.23 | 124 | #end |
![]() |
1.1 | 125 | </div> |
126 | <div class="modal-footer"> | ||
127 | <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> | ||
128 | #createSubmit($submit) | ||
129 | </div> | ||
130 | #createFormEnd($form_end) | ||
131 | </div> | ||
132 | </div> | ||
133 | </div> | ||
134 | #end | ||
![]() |
1.7 | 135 | #else |
136 | This page can not be viewed in inline mode. | ||
![]() |
1.1 | 137 | #end |
![]() |
1.60 | 138 | |
139 | #macro(createElementObjects $properties) | ||
140 | #foreach($item in $properties.keySet()) | ||
141 | #set($label = $services.localization.render("homeopaths.classproperty.${item}")) | ||
142 | #if($theDocObj.getProperty($item)) | ||
143 | #set($value = $theDocObj.getProperty($item).value) | ||
144 | #set($newElem = { | ||
145 | "id" : "$item", | ||
146 | "type" : $classProperties[$item].type, | ||
147 | "required" : "false", | ||
148 | "label" : "$label", | ||
149 | "data-create-xobj" : "true", | ||
150 | "data-xobj-classname" : $theClass, | ||
151 | "data-xobj-fieldname" : "$item", | ||
152 | "value" : "$value" | ||
153 | }) | ||
154 | #if($classProperties[$item].opener == 1) | ||
155 | #set($discard = $newElem.put("data-opener", "true")) | ||
156 | #end | ||
157 | #if($classProperties[$item].extraAttributes) | ||
158 | #set($attrMap = $classProperties[$item].extraAttributes) | ||
159 | #foreach($attr in $attrMap.keySet()) | ||
160 | #set($discard = $newElem.put("$attr", $attrMap[$attr])) | ||
161 | #end | ||
162 | #end | ||
163 | #set($thisObj["$item"] = $newElem) | ||
164 | #end | ||
165 | #end | ||
166 | #end | ||
167 | |||
![]() |
1.1 | 168 | {{/html}} |
169 | {{/velocity}} |