Changes for page homeopathsSheet

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

From version 3.10
edited by Jip-jan Alunkel
on March 09, 00:18
Change comment: Rollback to version 1.38
To version 3.1
edited by Jip-jan Alunkel
on March 08, 19:11
Change comment: Rollback to version 1.38

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"}}
... ... @@ -22,7 +22,7 @@
22 22   <p class="buttons text-align-right">
23 23   <a class="btn btn-primary" title="Edit" href="$doc.getURL("edit")?editor=wysiwyg" role="button" rel="nofollow">
24 24   <span class="fa fa-pencil"></span>
25 - <span class="btn-label">Edit content</span>
24 + <span class="btn-label">Edit contents</span>
26 26   </a>
27 27   </p>
28 28  #end
... ... @@ -32,35 +32,31 @@
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', 'extraAttributes': {"disabled": "disabled", "help-block" : 'The name of your practice is the title of this page. If you want to change it, you should edit the content of this page.'}},
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 - #foreach($property in $classProperties.keySet())
50 - #if($theDocObj.getProperty($property))
34 +#set($classProperties = {
35 + 'practiceName': {'type': 'string', 'opener': 0},
36 + 'pmStreet': {'type': 'string', 'opener': 0},
37 + 'pmHousenumber': {'type': 'string', 'opener': 0},
38 + 'pmPostcode': {'type': 'string', 'opener': 0},
39 + 'pmCity': {'type': 'string', 'opener': 0},
40 + 'pmCounty': {'type': 'string', 'opener': 0},
41 + 'pmState': {'type': 'string', 'opener': 0},
42 + 'pmCountry': {'type': 'string', 'opener': 0},
43 + 'certification': {'type': 'bool', 'opener': 1},
44 + 'certificationFrom': {'type': 'string', 'opener': 0, 'parent': 'certification'}
45 +})
46 +#foreach($property in $classProperties.keySet())
47 + #if($theDocObj.getProperty($property))
51 51   <p class="property">
52 - #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout.
53 - #if($property == "pmStreet")
49 + #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout.
50 + #if($property == "pmStreet") ## Difference with added housenumber because of the streetaddress layout.
54 54   <span class="property-name">$services.localization.render("homeopaths.classproperty.address")</span> <span class="property-value">$doc.display($property) $doc.display("pmHousenumber")</span>
55 - #elseif($property == "practiceName") ## Difference, should receive the title from the page.
56 - <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.getTitle()</span>
57 - #else ## Normal situation.
52 + #else
58 58   <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span>
59 - #end
60 - </p>
61 61   #end
55 + </p>
62 62   #end
63 63   #end
58 +#end
64 64  
65 65   #if($hasRight)
66 66   <p class="buttons text-align-right">
... ... @@ -78,6 +78,63 @@
78 78   "url": "",
79 79   "use_captcha": "false"
80 80   })
76 + #set($thisObj = {})
77 + #set($children = {})
78 + #foreach($item in $classProperties.keySet())
79 + #if($classProperties[$item].parent)
80 + #set($discard = $children[$classProperties[$item].parent].add($classProperties[$item]))
81 + #end
82 + #end
83 +$children
84 + #foreach($item in $classProperties.keySet())
85 + #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
86 + #if($theDocObj.getProperty($item))
87 + #set($value = $theDocObj.getProperty($item).value)
88 + #if($classProperties[$item].type == "bool")
89 + #set($newElem = {
90 + "id" : "$item",
91 + "type" : "checkbox",
92 + "required" : "false",
93 + "label" : "$label",
94 + "value" : "$value",
95 + "data-opener" : "true"
96 + })
97 + #else
98 +## #if($classProperties[$item].opener)
99 + #set($newElem = {
100 + "id": "$item",
101 + "type": "text",
102 + "required" : "false",
103 + "label" : "$label",
104 + "data-create-xobj" : "true",
105 + "data-xobj-classname" : "homeopaths.Code.homeopathsClass",
106 + "data-xobj-fieldname" : "$item",
107 + "value": "$value"
108 + })
109 + #end
110 + #set($thisObj["$item"] = $newElem)
111 + #end
112 + #end
113 + #set($practiceName = {
114 + "id": "practiceName",
115 + "type": "text",
116 + "required" : "false",
117 + "label" : "Practice name",
118 + "data-create-xobj" : "true",
119 + "data-xobj-classname" : "homeopaths.Code.homeopathsClass",
120 + "data-xobj-fieldname" : "practiceName",
121 + "value": "$doc.getTitle()"
122 + })
123 + #set($city = {
124 + "id": "city",
125 + "type": "text",
126 + "required" : "false",
127 + "label" : "City",
128 + "data-create-xobj" : "true",
129 + "data-xobj-classname" : "homeopaths.Code.homeopathsClass",
130 + "data-xobj-fieldname" : "pmCity",
131 + "value": "$theDocObj.getProperty('pmCity').value"
132 + })
81 81   #set($submit = {
82 82   "id" : "edit_details",
83 83   "button-text" : "Save changes",
... ... @@ -98,65 +98,11 @@
98 98   </button>
99 99   </div>
100 100   <div class="modal-body">
101 - <fieldset class="fieldset">
102 - <address>
103 -$doc.getTitle()<br />
104 -$classProperties.pmStreet $classProperties.pmHousenumber<br /><br />
105 -$classProperties.pmPostcode $classProperties.pmCity<br />
106 -$classProperties.pmCounty, $classProperties.pmState<br />
107 -$classProperties.pmCountry.toUpperCase()
108 - </address>
109 - </fieldset>
110 -#set($lastChild = "")
111 -#foreach($propertyName in $classProperties.keySet())
112 - #set($item = $classProperties["$propertyName"])
113 - #if($item.containsKey("disabled"))
114 - #else
115 - #set($propertyType = $item.type)
116 - #set($propertyOpener = $item.opener)
117 - #set($propertyParent = $item.parent)
118 - #set($extraAttributes = $item.extraAttributes)
119 - #set($label = $services.localization.render("homeopaths.classproperty.${propertyName}"))
120 - #if($theDocObj.getProperty($propertyName) || $propertyType == "address")
121 - #set($value = $theDocObj.getProperty($propertyName).value)
122 - #if($propertyType == "checkbox" || $propertyType == "radio")
123 - #set($value = "1")
124 - #end
125 - #if(!$value)
126 - #set($value = "")
127 - #end
128 - #set($newElem = {
129 - "id" : "$propertyName",
130 - "type" : $propertyType,
131 - "required" : "false",
132 - "label" : "$label",
133 - "data-create-xobj" : "true",
134 - "data-xobj-classname" : $theClass,
135 - "data-xobj-fieldname" : "$propertyName",
136 - "value" : "$value"
137 - })
138 - #if($extraAttributes.keySet().size() > 0)
139 - #set($attrMap = $extraAttributes)
140 - #foreach($attr in $attrMap.keySet())
141 - #set($discard = $newElem.put("$attr", $attrMap[$attr]))
142 - #end
143 - #end
144 - #if($propertyOpener)
145 - #set($discard = $newElem.put("data-opener", "true"))
146 - #end
147 - #if($propertyParent)
148 - #set($lastChild = "$key")
149 - #elseif($lastChild != "")
150 - #set($lastChild = "")
151 - #createExpandEnd()
152 - #end
153 - #createFormElement($newElem)
154 - #if($propertyOpener)
155 - #createExpandStart($newElem $value)
156 - #end
153 + #foreach($obj in $thisObj)
154 + #createFormElement($obj)
157 157   #end
158 - #end
159 -#end
156 + #createFormElement($practiceName)
157 + #createFormElement($city)
160 160   </div>
161 161   <div class="modal-footer">
162 162   <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
... ... @@ -170,35 +170,5 @@
170 170  #else
171 171   This page can not be viewed in inline mode.
172 172  #end
173 -
174 -#macro(createElementObjects $properties)
175 - #foreach($item in $properties.keySet())
176 - #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
177 - #if($theDocObj.getProperty($item))
178 - #set($value = $theDocObj.getProperty($item).value)
179 - #set($newElem = {
180 - "id" : "$item",
181 - "type" : $classProperties[$item].type,
182 - "required" : "false",
183 - "label" : "$label",
184 - "data-create-xobj" : "true",
185 - "data-xobj-classname" : $theClass,
186 - "data-xobj-fieldname" : "$item",
187 - "value" : "$value"
188 - })
189 - #if($classProperties[$item].opener == 1)
190 - #set($discard = $newElem.put("data-opener", "true"))
191 - #end
192 - #if($classProperties[$item].extraAttributes)
193 - #set($attrMap = $classProperties[$item].extraAttributes)
194 - #foreach($attr in $attrMap.keySet())
195 - #set($discard = $newElem.put("$attr", $attrMap[$attr]))
196 - #end
197 - #end
198 - #set($thisObj["$item"] = $newElem)
199 - #end
200 - #end
201 -#end
202 -
203 203  {{/html}}
204 204  {{/velocity}}