Changes for page homeopathsSheet

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

From version 1.62
edited by Jip-jan Alunkel
on March 08, 00:53
Change comment: There is no comment for this version
To version 1.59
edited by Jip-jan Alunkel
on March 07, 23:40
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -7,9 +7,8 @@
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"}}
... ... @@ -33,16 +33,16 @@
33 33  <div id="${spaceTitle}" class="box sheet_properties">
34 34   <h2>Details</h2>
35 35  #set($classProperties = {
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'}
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'}
46 46  })
47 47  #foreach($property in $classProperties.keySet())
48 48   #if($theDocObj.getProperty($property))
... ... @@ -79,6 +79,7 @@
79 79   #foreach($item in $classProperties.keySet())
80 80   #if($classProperties[$item].parent)
81 81   #set($parentID = $classProperties[$item].parent)
81 +##$children[$parentID]
82 82   #if(!$children[$parentID])
83 83   #set($discard = $children.put("$parentID", {}))
84 84   #end
... ... @@ -85,7 +85,56 @@
85 85   #set($discard = $children["$parentID"].put($item, $classProperties[$item]))
86 86   #end
87 87   #end
88 - #createElementObjects($classProperties)
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 + })
89 89   #set($submit = {
90 90   "id" : "edit_details",
91 91   "button-text" : "Save changes",
... ... @@ -107,11 +107,10 @@
107 107   </div>
108 108   <div class="modal-body">
109 109   #foreach($obj in $thisObj)
110 - $obj
111 -## #createFormElement($obj)
159 + #createFormElement($obj)
112 112   #end
113 -## #createFormElement($practiceName)
114 -## #createFormElement($city)
161 + #createFormElement($practiceName)
162 + #createFormElement($city)
115 115   </div>
116 116   <div class="modal-footer">
117 117   <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
... ... @@ -125,35 +125,5 @@
125 125  #else
126 126   This page can not be viewed in inline mode.
127 127  #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 -
158 158  {{/html}}
159 159  {{/velocity}}