Changes for page homeopathsSheet

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

From version 1.57
edited by Jip-jan Alunkel
on March 07, 23:39
Change comment: There is no comment for this version
To version 1.65
edited by Jip-jan Alunkel
on March 08, 01:06
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -7,8 +7,9 @@
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"}}
... ... @@ -32,16 +32,16 @@
32 32  <div id="${spaceTitle}" class="box sheet_properties">
33 33   <h2>Details</h2>
34 34  #set($classProperties = {
35 - 'practiceName': {'type': 'string', 'opener': 0},
36 - 'pmStreet': {'type': 'string', 'opener': 0},
37 - 'pmHousenumber': {'type': 'string', 'opener': 0, 'parent': 'certification'},
38 - 'pmPostcode': {'type': 'string', 'opener': 0},
39 - 'pmCity': {'type': 'string', 'opener': 0},
40 - 'pmCounty': {'type': 'string', 'opener': 0, 'parent': 'certification'},
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'}
36 + 'practiceName': {'type': 'text', 'opener': 0},
37 + 'pmStreet': {'type': 'text', 'opener': 0},
38 + 'pmHousenumber': {'type': 'text', 'opener': 0, 'parent': 'certification'},
39 + 'pmPostcode': {'type': 'text', 'opener': 0},
40 + 'pmCity': {'type': 'text', 'opener': 0},
41 + 'pmCounty': {'type': 'text', 'opener': 0, 'parent': 'certification'},
42 + 'pmState': {'type': 'text', 'opener': 0},
43 + 'pmCountry': {'type': 'text', 'opener': 0},
44 + 'certification': {'type': 'checkbox', 'opener': 1},
45 + 'certificationFrom': {'type': 'text', 'opener': 0, 'parent': 'certification'}
45 45  })
46 46  #foreach($property in $classProperties.keySet())
47 47   #if($theDocObj.getProperty($property))
... ... @@ -75,66 +75,19 @@
75 75   })
76 76   #set($thisObj = {})
77 77   #set($children = {})
79 +$classProperties
78 78   #foreach($item in $classProperties.keySet())
79 79   #if($classProperties[$item].parent)
80 80   #set($parentID = $classProperties[$item].parent)
81 -$classProperties[$parentID]
82 - #if(!$classProperties[$parentID])
83 + #if(!$children[$parentID])
83 83   #set($discard = $children.put("$parentID", {}))
84 84   #end
85 85   #set($discard = $children["$parentID"].put($item, $classProperties[$item]))
87 +## #set($discard = $classProperties.remove($item))
86 86   #end
87 87   #end
88 -$children
89 - #foreach($item in $classProperties.keySet())
90 - #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
91 - #if($theDocObj.getProperty($item))
92 - #set($value = $theDocObj.getProperty($item).value)
93 - #if($classProperties[$item].type == "bool")
94 - #set($newElem = {
95 - "id" : "$item",
96 - "type" : "checkbox",
97 - "required" : "false",
98 - "label" : "$label",
99 - "value" : "$value",
100 - "data-opener" : "true"
101 - })
102 - #else
103 -## #if($classProperties[$item].opener)
104 - #set($newElem = {
105 - "id": "$item",
106 - "type": "text",
107 - "required" : "false",
108 - "label" : "$label",
109 - "data-create-xobj" : "true",
110 - "data-xobj-classname" : "homeopaths.Code.homeopathsClass",
111 - "data-xobj-fieldname" : "$item",
112 - "value": "$value"
113 - })
114 - #end
115 - #set($thisObj["$item"] = $newElem)
116 - #end
117 - #end
118 - #set($practiceName = {
119 - "id": "practiceName",
120 - "type": "text",
121 - "required" : "false",
122 - "label" : "Practice name",
123 - "data-create-xobj" : "true",
124 - "data-xobj-classname" : "homeopaths.Code.homeopathsClass",
125 - "data-xobj-fieldname" : "practiceName",
126 - "value": "$doc.getTitle()"
127 - })
128 - #set($city = {
129 - "id": "city",
130 - "type": "text",
131 - "required" : "false",
132 - "label" : "City",
133 - "data-create-xobj" : "true",
134 - "data-xobj-classname" : "homeopaths.Code.homeopathsClass",
135 - "data-xobj-fieldname" : "pmCity",
136 - "value": "$theDocObj.getProperty('pmCity').value"
137 - })
90 +$classProperties
91 +#createElementObjects($classProperties)
138 138   #set($submit = {
139 139   "id" : "edit_details",
140 140   "button-text" : "Save changes",
... ... @@ -158,8 +158,6 @@
158 158   #foreach($obj in $thisObj)
159 159   #createFormElement($obj)
160 160   #end
161 - #createFormElement($practiceName)
162 - #createFormElement($city)
163 163   </div>
164 164   <div class="modal-footer">
165 165   <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
... ... @@ -173,5 +173,35 @@
173 173  #else
174 174   This page can not be viewed in inline mode.
175 175  #end
128 +
129 +#macro(createElementObjects $properties)
130 + #foreach($item in $properties.keySet())
131 + #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
132 + #if($theDocObj.getProperty($item))
133 + #set($value = $theDocObj.getProperty($item).value)
134 + #set($newElem = {
135 + "id" : "$item",
136 + "type" : $classProperties[$item].type,
137 + "required" : "false",
138 + "label" : "$label",
139 + "data-create-xobj" : "true",
140 + "data-xobj-classname" : $theClass,
141 + "data-xobj-fieldname" : "$item",
142 + "value" : "$value"
143 + })
144 + #if($classProperties[$item].opener == 1)
145 + #set($discard = $newElem.put("data-opener", "true"))
146 + #end
147 + #if($classProperties[$item].extraAttributes)
148 + #set($attrMap = $classProperties[$item].extraAttributes)
149 + #foreach($attr in $attrMap.keySet())
150 + #set($discard = $newElem.put("$attr", $attrMap[$attr]))
151 + #end
152 + #end
153 + #set($thisObj["$item"] = $newElem)
154 + #end
155 + #end
156 +#end
157 +
176 176  {{/html}}
177 177  {{/velocity}}