Changes for page homeopathsSheet

Last modified by Jip-jan Alunkel on March 26, 17:31

From version 1.152
edited by Jip-jan Alunkel
on March 08, 18:56
Change comment: There is no comment for this version
To version 2.1
edited by Jip-jan Alunkel
on March 08, 19:05
Change comment: Rollback to version 1.14

Summary

Details

Page properties
Content
... ... @@ -1,15 +1,14 @@
1 1  {{include reference="assets.pagemaker.macros"/}}
2 2  
3 3  {{velocity}}
4 -#set($discard = $services.localization.use('document', 'assets.global.translations'))
4 +#set($discard = $services.localization.use('document', 'homeopaths.Code.translations'))
5 5  #set($discard = $services.localization.use('document', 'assets.pagemaker.translations'))
6 6  #set($discard = $xwiki.ssx.use('assets.pagemaker.WebHome', {'minify': false}))
7 7  #set($discard = $xwiki.jsx.use('assets.pagemaker.WebHome', {'minify': false, 'language': $context.language, 'myParameter': 'value'}))
8 8  #set($theDoc = $xwiki.getDocument("${doc.fullName}").getTranslatedDocument())
9 9  #set($isInline = $xcontext.action == 'edit' && $request.get('editor') == 'inline')
10 -#set($theClass = "homeopaths.Code.homeopathsClass")
11 11  ## Create object (important for sheet binding, do not remove)
12 -#set($theDocObj = $doc.getObject($theClass, true))
11 +#set($theDocObj = $doc.getObject("homeopaths.Code.homeopathsClass", true))
13 13  #set($hasRight = !$isGuest && ($theDocObj.getProperty('user').value == $context.getUser() || $hasAdmin))
14 14  $theDoc.getContent()
15 15  {{html wiki="true" clean="false"}}
... ... @@ -32,20 +32,25 @@
32 32  #if($xcontext.action == "view")
33 33  <div id="${spaceTitle}" class="box sheet_properties">
34 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 -])
34 +#set($classProperties = ['pmPractice','pmStreet','pmHousenumber','pmPostcode','pmCity','pmCountry','pmState','pmCounty'])
35 +#*
36 +{
37 + 'pmCountry': '$services.localization.render("homeopaths.pmCountry")',
38 + 'pmState': '$services.localization.render("homeopaths.classproperty.pmState")',
39 + 'pmCounty': '$services.localization.render("homeopaths.classproperty.pmCounty")',
40 + 'pmPostcode': '$services.localization.render("homeopaths.classproperty.pmPostcode")',
41 + 'pmCity': '$services.localization.render("homeopaths.classproperty.pmCity")',
42 + 'pmStreet': '$services.localization.render("homeopaths.classproperty.pmStreet")',
43 + 'pmHousenumber': '$services.localization.render("homeopaths.classproperty.pmHousenumber")'
44 +})
45 +*#
46 +#foreach($property in $classProperties)
47 + #if($theDocObj.getProperty($property).value != "")
48 + <p class="property">
49 + <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span>
50 + </p>
51 + #end
52 +#end
49 49  
50 50   #if($hasRight)
51 51   <p class="buttons text-align-right">
... ... @@ -55,7 +55,7 @@
55 55   </p>
56 56   #end
57 57  </div>
58 - #if($hasRight)
62 + #if($hasRight) ## Ook de rechts situatie uitlezen en meenemen.
59 59   #set($form_start = {
60 60   "id": "homeopaths_form",
61 61   "product": "homeopath details",
... ... @@ -63,6 +63,16 @@
63 63   "url": "",
64 64   "use_captcha": "false"
65 65   })
70 + #set($city = {
71 + "id": "city",
72 + "type": "text",
73 + "required" : "false",
74 + "label" : "City",
75 + "data-create-xobj" : "true",
76 + "data-xobj-classname" : "homeopaths.Code.homeopathsClass",
77 + "data-xobj-fieldname" : "pmCity",
78 + "value": "$theDocObj.getProperty('pmCity').value"
79 + })
66 66   #set($submit = {
67 67   "id" : "edit_details",
68 68   "button-text" : "Save changes",
... ... @@ -83,60 +83,7 @@
83 83   </button>
84 84   </div>
85 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 - #if($propertyType == "checkbox" || $propertyType == "radio")
102 - #set($value = "1")
103 -$propertyType - $value
104 - #else
105 - #set($value = "")
106 - #end
107 - #end
108 - #set($newElem = {
109 - "id" : "$key",
110 - "type" : $propertyType,
111 - "required" : "false",
112 - "label" : "$label",
113 - "data-create-xobj" : "true",
114 - "data-xobj-classname" : $theClass,
115 - "data-xobj-fieldname" : "$key",
116 - "value" : "$value"
117 - })
118 - #if($extraAttributes.keySet().size() > 0)
119 - #set($attrMap = $extraAttributes)
120 - #foreach($attr in $attrMap.keySet())
121 - #set($discard = $newElem.put("$attr", $attrMap[$attr]))
122 - #end
123 - #end
124 - #if($propertyOpener)
125 - #set($discard = $newElem.put("data-opener", "true"))
126 - #end
127 - #if($propertyParent)
128 - #set($lastChild = "$key")
129 - #elseif($lastChild != "")
130 - #set($lastChild = "")
131 - #createExpandEnd()
132 - #end
133 - #createFormElement($newElem)
134 - #if($propertyOpener)
135 -##$value
136 - #createExpandStart($newElem $value)
137 - #end
138 - #end
139 -#end
100 + #createFormElement($city)
140 140   </div>
141 141   <div class="modal-footer">
142 142   <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
... ... @@ -150,35 +150,5 @@
150 150  #else
151 151   This page can not be viewed in inline mode.
152 152  #end
153 -
154 -#macro(createElementObjects $properties)
155 - #foreach($item in $properties.keySet())
156 - #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
157 - #if($theDocObj.getProperty($item))
158 - #set($value = $theDocObj.getProperty($item).value)
159 - #set($newElem = {
160 - "id" : "$item",
161 - "type" : $classProperties[$item].type,
162 - "required" : "false",
163 - "label" : "$label",
164 - "data-create-xobj" : "true",
165 - "data-xobj-classname" : $theClass,
166 - "data-xobj-fieldname" : "$item",
167 - "value" : "$value"
168 - })
169 - #if($classProperties[$item].opener == 1)
170 - #set($discard = $newElem.put("data-opener", "true"))
171 - #end
172 - #if($classProperties[$item].extraAttributes)
173 - #set($attrMap = $classProperties[$item].extraAttributes)
174 - #foreach($attr in $attrMap.keySet())
175 - #set($discard = $newElem.put("$attr", $attrMap[$attr]))
176 - #end
177 - #end
178 - #set($thisObj["$item"] = $newElem)
179 - #end
180 - #end
181 -#end
182 -
183 183  {{/html}}
184 184  {{/velocity}}