Изменения документа homeopathsSheet

Редактировал(а) Jip-jan Alunkel марта 26, 17:31

От версии 3.2
отредактировано Jip-jan Alunkel
на марта 08, 20:14
Изменить комментарий: Rollback to version 1.38
К версии 3.1
отредактировано Jip-jan Alunkel
на марта 08, 19:11
Изменить комментарий: Rollback to version 1.38

Сводка

Подробности

Свойства страницы
Содержимое
... ... @@ -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,19 +32,17 @@
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 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'}
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'}
48 48  })
49 49  #foreach($property in $classProperties.keySet())
50 50   #if($theDocObj.getProperty($property))
... ... @@ -76,6 +76,63 @@
76 76   "url": "",
77 77   "use_captcha": "false"
78 78   })
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 + })
79 79   #set($submit = {
80 80   "id" : "edit_details",
81 81   "button-text" : "Save changes",
... ... @@ -96,53 +96,11 @@
96 96   </button>
97 97   </div>
98 98   <div class="modal-body">
99 -#set($lastChild = "")
100 -#foreach($propertyName in $classProperties.keySet())
101 - #set($item = $classProperties["$propertyName"])
102 - #set($propertyType = $item.type)
103 - #set($propertyOpener = $item.opener)
104 - #set($propertyParent = $item.parent)
105 - #set($extraAttributes = $item.extraAttributes)
106 - #set($label = $services.localization.render("homeopaths.classproperty.${propertyName}"))
107 - #if($theDocObj.getProperty($propertyName) || $propertyType == "address")
108 - #set($value = $theDocObj.getProperty($propertyName).value)
109 - #if($propertyType == "checkbox" || $propertyType == "radio")
110 - #set($value = "1")
153 + #foreach($obj in $thisObj)
154 + #createFormElement($obj)
111 111   #end
112 - #if(!$value)
113 - #set($value = "")
114 - #end
115 - #set($newElem = {
116 - "id" : "$propertyName",
117 - "type" : $propertyType,
118 - "required" : "false",
119 - "label" : "$label",
120 - "data-create-xobj" : "true",
121 - "data-xobj-classname" : $theClass,
122 - "data-xobj-fieldname" : "$propertyName",
123 - "value" : "$value"
124 - })
125 - #if($extraAttributes.keySet().size() > 0)
126 - #set($attrMap = $extraAttributes)
127 - #foreach($attr in $attrMap.keySet())
128 - #set($discard = $newElem.put("$attr", $attrMap[$attr]))
129 - #end
130 - #end
131 - #if($propertyOpener)
132 - #set($discard = $newElem.put("data-opener", "true"))
133 - #end
134 - #if($propertyParent)
135 - #set($lastChild = "$key")
136 - #elseif($lastChild != "")
137 - #set($lastChild = "")
138 - #createExpandEnd()
139 - #end
140 - #createFormElement($newElem)
141 - #if($propertyOpener)
142 - #createExpandStart($newElem $value)
143 - #end
144 - #end
145 -#end
156 + #createFormElement($practiceName)
157 + #createFormElement($city)
146 146   </div>
147 147   <div class="modal-footer">
148 148   <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
... ... @@ -156,35 +156,5 @@
156 156  #else
157 157   This page can not be viewed in inline mode.
158 158  #end
159 -
160 -#macro(createElementObjects $properties)
161 - #foreach($item in $properties.keySet())
162 - #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
163 - #if($theDocObj.getProperty($item))
164 - #set($value = $theDocObj.getProperty($item).value)
165 - #set($newElem = {
166 - "id" : "$item",
167 - "type" : $classProperties[$item].type,
168 - "required" : "false",
169 - "label" : "$label",
170 - "data-create-xobj" : "true",
171 - "data-xobj-classname" : $theClass,
172 - "data-xobj-fieldname" : "$item",
173 - "value" : "$value"
174 - })
175 - #if($classProperties[$item].opener == 1)
176 - #set($discard = $newElem.put("data-opener", "true"))
177 - #end
178 - #if($classProperties[$item].extraAttributes)
179 - #set($attrMap = $classProperties[$item].extraAttributes)
180 - #foreach($attr in $attrMap.keySet())
181 - #set($discard = $newElem.put("$attr", $attrMap[$attr]))
182 - #end
183 - #end
184 - #set($thisObj["$item"] = $newElem)
185 - #end
186 - #end
187 -#end
188 -
189 189  {{/html}}
190 190  {{/velocity}}