Commit 8cbb0b1a authored by Julien Muchembled's avatar Julien Muchembled

gadget: add support for extra attributes and drop useless 'gadget' class

Now 'extra' can be used to set a custom class on the gadget element.
Note that 'css_class' property has a different purpose: it sets a class
on the grand-parent div.
parent 80c30ea0
......@@ -65,6 +65,12 @@
<td>test</td>
</tr>
<tr>
<td>verifyValue</td>
<td>//div[@class="file_gadget"]/input</td>
<td>test</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@title='Save']</td>
......
......@@ -2,10 +2,19 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="GadgetField" module="Products.ERP5Form.GadgetField"/>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>gadget_url</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_description</string> </value>
......@@ -13,7 +22,12 @@
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary/>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
......@@ -21,43 +35,15 @@
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
......@@ -68,39 +54,11 @@
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
......@@ -110,15 +68,7 @@
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
......@@ -129,52 +79,16 @@
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
<key> <string>field_id</string> </key>
<value> <string>my_gadget_field</string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -170,7 +170,7 @@
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
<value> <string>class="file_gadget"</string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
......
......@@ -49,7 +49,7 @@
.declareService(function () {
var g = this,
i,
list_gadget = document.getElementsByClassName("gadget"),
list_gadget = document.querySelectorAll("[data-gadget-url]"),
all_gadget,
list = [],
gadget_attributes = [],
......
......@@ -29,16 +29,15 @@ class GadgetWidget(Widget.TextWidget):
return self.render_view(field, value, REQUEST, render_prefix, key)
def render_view(self, field, value, REQUEST=None, render_prefix=None, key=None):
kw = {}
kw['data-gadget-url'] = field.get_value('gadget_url')
kw['data-gadget-scope'] = field.id
kw = {
'data-gadget-sandbox': field.get_value('js_sandbox'),
'data-gadget-scope': field.id,
'data-gadget-url': field.get_value('gadget_url'),
'data-gadget-value': value,
}
if key is not None:
kw['data-gadget-editable'] = key
kw['class'] = "gadget"
kw['data-gadget-value'] = value
kw['data-gadget-sandbox'] = field.get_value('js_sandbox')
return Widget.render_element("div",
**kw)
return Widget.render_element("div", extra=field.get_value('extra'), **kw)
def get_javascript_list(self, field, REQUEST=None):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment