Changes for page homeopathsSheet

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

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

Summary

Details

Page properties
Content
... ... @@ -1,14 +1,15 @@
1 1  {{include reference="assets.pagemaker.macros"/}}
2 2  
3 3  {{velocity}}
4 -#set($discard = $services.localization.use('document', 'homeopaths.Code.translations'))
4 +#set($discard = $services.localization.use('document', 'assets.global.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")
10 10  ## Create object (important for sheet binding, do not remove)
11 -#set($theDocObj = $doc.getObject("homeopaths.Code.homeopathsClass", true))
12 +#set($theDocObj = $doc.getObject($theClass, true))
12 12  #set($hasRight = !$isGuest && ($theDocObj.getProperty('user').value == $context.getUser() || $hasAdmin))
13 13  $theDoc.getContent()
14 14  {{html wiki="true" clean="false"}}
... ... @@ -31,25 +31,20 @@
31 31  #if($xcontext.action == "view")
32 32  <div id="${spaceTitle}" class="box sheet_properties">
33 33   <h2>Details</h2>
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
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 +])
53 53  
54 54   #if($hasRight)
55 55   <p class="buttons text-align-right">
... ... @@ -59,7 +59,7 @@
59 59   </p>
60 60   #end
61 61  </div>
62 - #if($hasRight) ## Ook de rechts situatie uitlezen en meenemen.
58 + #if($hasRight)
63 63   #set($form_start = {
64 64   "id": "homeopaths_form",
65 65   "product": "homeopath details",
... ... @@ -67,16 +67,6 @@
67 67   "url": "",
68 68   "use_captcha": "false"
69 69   })
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 - })
80 80   #set($submit = {
81 81   "id" : "edit_details",
82 82   "button-text" : "Save changes",
... ... @@ -97,7 +97,58 @@
97 97   </button>
98 98   </div>
99 99   <div class="modal-body">
100 - #createFormElement($city)
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($propertyType == "checkbox" || $propertyType == "radio")
101 + #set($value = "1")
102 + #end
103 + #if(!$value)
104 + #set($value = "")
105 + #end
106 + #set($newElem = {
107 + "id" : "$key",
108 + "type" : $propertyType,
109 + "required" : "false",
110 + "label" : "$label",
111 + "data-create-xobj" : "true",
112 + "data-xobj-classname" : $theClass,
113 + "data-xobj-fieldname" : "$key",
114 + "value" : "$value"
115 + })
116 + #if($extraAttributes.keySet().size() > 0)
117 + #set($attrMap = $extraAttributes)
118 + #foreach($attr in $attrMap.keySet())
119 + #set($discard = $newElem.put("$attr", $attrMap[$attr]))
120 + #end
121 + #end
122 + #if($propertyOpener)
123 + #set($discard = $newElem.put("data-opener", "true"))
124 + #end
125 + #if($propertyParent)
126 + #set($lastChild = "$key")
127 + #elseif($lastChild != "")
128 + #set($lastChild = "")
129 + #createExpandEnd()
130 + #end
131 + #createFormElement($newElem)
132 + #if($propertyOpener)
133 +##$value
134 + #createExpandStart($newElem $value)
135 + #end
136 + #end
137 +#end
101 101   </div>
102 102   <div class="modal-footer">
103 103   <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
... ... @@ -111,5 +111,35 @@
111 111  #else
112 112   This page can not be viewed in inline mode.
113 113  #end
151 +
152 +#macro(createElementObjects $properties)
153 + #foreach($item in $properties.keySet())
154 + #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
155 + #if($theDocObj.getProperty($item))
156 + #set($value = $theDocObj.getProperty($item).value)
157 + #set($newElem = {
158 + "id" : "$item",
159 + "type" : $classProperties[$item].type,
160 + "required" : "false",
161 + "label" : "$label",
162 + "data-create-xobj" : "true",
163 + "data-xobj-classname" : $theClass,
164 + "data-xobj-fieldname" : "$item",
165 + "value" : "$value"
166 + })
167 + #if($classProperties[$item].opener == 1)
168 + #set($discard = $newElem.put("data-opener", "true"))
169 + #end
170 + #if($classProperties[$item].extraAttributes)
171 + #set($attrMap = $classProperties[$item].extraAttributes)
172 + #foreach($attr in $attrMap.keySet())
173 + #set($discard = $newElem.put("$attr", $attrMap[$attr]))
174 + #end
175 + #end
176 + #set($thisObj["$item"] = $newElem)
177 + #end
178 + #end
179 +#end
180 +
114 114  {{/html}}
115 115  {{/velocity}}