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 @@ ...@@ -65,6 +65,12 @@
<td>test</td> <td>test</td>
</tr> </tr>
<tr>
<td>verifyValue</td>
<td>//div[@class="file_gadget"]/input</td>
<td>test</td>
</tr>
<tr> <tr>
<td>clickAndWait</td> <td>clickAndWait</td>
<td>//button[@title='Save']</td> <td>//button[@title='Save']</td>
......
...@@ -2,10 +2,19 @@ ...@@ -2,10 +2,19 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="GadgetField" module="Products.ERP5Form.GadgetField"/> <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>gadget_url</string>
</list>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_description</string> </value> <value> <string>my_description</string> </value>
...@@ -13,7 +22,12 @@ ...@@ -13,7 +22,12 @@
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
<value> <value>
<dictionary/> <dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value> </value>
</item> </item>
<item> <item>
...@@ -21,43 +35,15 @@ ...@@ -21,43 +35,15 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>alternate_name</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>target</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>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -68,39 +54,11 @@ ...@@ -68,39 +54,11 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>alternate_name</string> </key> <key> <string>field_id</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>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>display_width</string> </key> <key> <string>form_id</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>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
...@@ -110,15 +68,7 @@ ...@@ -110,15 +68,7 @@
</value> </value>
</item> </item>
<item> <item>
<key> <string>hidden</string> </key> <key> <string>target</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>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -129,52 +79,16 @@ ...@@ -129,52 +79,16 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>alternate_name</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value> <value> <string>my_gadget_field</string> </value>
</item> </item>
<item> <item>
<key> <string>css_class</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string>Base_viewFieldLibrary</string> </value>
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value> <value> <string>Click to edit the target</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>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
</item> </item>
<item> <item>
<key> <string>extra</string> </key> <key> <string>extra</string> </key>
<value> <string></string> </value> <value> <string>class="file_gadget"</string> </value>
</item> </item>
<item> <item>
<key> <string>gadget_url</string> </key> <key> <string>gadget_url</string> </key>
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
.declareService(function () { .declareService(function () {
var g = this, var g = this,
i, i,
list_gadget = document.getElementsByClassName("gadget"), list_gadget = document.querySelectorAll("[data-gadget-url]"),
all_gadget, all_gadget,
list = [], list = [],
gadget_attributes = [], gadget_attributes = [],
......
...@@ -29,16 +29,15 @@ class GadgetWidget(Widget.TextWidget): ...@@ -29,16 +29,15 @@ class GadgetWidget(Widget.TextWidget):
return self.render_view(field, value, REQUEST, render_prefix, key) return self.render_view(field, value, REQUEST, render_prefix, key)
def render_view(self, field, value, REQUEST=None, render_prefix=None, key=None): def render_view(self, field, value, REQUEST=None, render_prefix=None, key=None):
kw = {} kw = {
kw['data-gadget-url'] = field.get_value('gadget_url') 'data-gadget-sandbox': field.get_value('js_sandbox'),
kw['data-gadget-scope'] = field.id 'data-gadget-scope': field.id,
if key is not None: 'data-gadget-url': field.get_value('gadget_url'),
kw['data-gadget-editable'] = key 'data-gadget-value': value,
kw['class'] = "gadget" }
kw['data-gadget-value'] = value if key is not None:
kw['data-gadget-sandbox'] = field.get_value('js_sandbox') kw['data-gadget-editable'] = key
return Widget.render_element("div", return Widget.render_element("div", extra=field.get_value('extra'), **kw)
**kw)
def get_javascript_list(self, field, REQUEST=None): 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