Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
140
Merge Requests
140
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
631ab1f6
Commit
631ab1f6
authored
Jun 01, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Form: new gadget boolean option to serialize value to JSON
parent
9e55f4aa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.js
...Item/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.js
+7
-0
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.xml
...tem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.xml
+2
-2
product/ERP5Form/GadgetField.py
product/ERP5Form/GadgetField.py
+12
-1
No files found.
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.js
View file @
631ab1f6
...
...
@@ -63,6 +63,13 @@
url
=
list_gadget
[
i
].
getAttribute
(
"
data-gadget-url
"
);
key
=
list_gadget
[
i
].
getAttribute
(
"
data-gadget-editable
"
);
value
=
list_gadget
[
i
].
getAttribute
(
"
data-gadget-value
"
);
if
(
value
===
null
)
try
{
value
=
JSON
.
parse
(
list_gadget
[
i
].
getAttribute
(
"
data-gadget-json
"
));
}
catch
(
e
)
{
console
.
log
(
e
);
/* same remark as below (when render() fails) */
continue
;
}
//renderable
if
(
url
!==
undefined
&&
url
!==
null
)
{
tmp
=
{};
...
...
product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/erp5_gadgetfield.js.xml
View file @
631ab1f6
...
...
@@ -12,7 +12,7 @@
</item>
<item>
<key>
<string>
_EtagSupport__etag
</string>
</key>
<value>
<string>
ts64
799067.07
</string>
</value>
<value>
<string>
ts64
810256.53
</string>
</value>
</item>
<item>
<key>
<string>
__name__
</string>
</key>
...
...
@@ -28,7 +28,7 @@
</item>
<item>
<key>
<string>
size
</string>
</key>
<value>
<int>
7
383
</int>
</value>
<value>
<int>
7
642
</int>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
...
...
product/ERP5Form/GadgetField.py
View file @
631ab1f6
...
...
@@ -4,6 +4,7 @@ from Products.Formulator.DummyField import fields
from
Products.Formulator
import
Validator
from
zLOG
import
LOG
,
ERROR
from
cStringIO
import
StringIO
from
json
import
dumps
class
GadgetWidget
(
Widget
.
Widget
):
"""
...
...
@@ -11,9 +12,16 @@ class GadgetWidget(Widget.Widget):
"""
property_names
=
Widget
.
Widget
.
property_names
+
\
[
'gadget_url'
,
'js_sandbox'
,
'extra'
]
property_names
.
insert
(
property_names
.
index
(
'default'
)
+
1
,
'json_value'
)
default
=
Widget
.
TextWidget
.
default
json_value
=
fields
.
CheckBoxField
(
'json_value'
,
title
=
'JSON Value'
,
description
=
'Serialize value to JSON.'
,
default
=
0
,
required
=
0
)
gadget_url
=
fields
.
StringField
(
'gadget_url'
,
title
=
'Gadget Url'
,
description
=
(
"The url of the html page containing the
\
...
...
@@ -34,8 +42,11 @@ class GadgetWidget(Widget.Widget):
kw
=
{
'data-gadget-sandbox'
:
field
.
get_value
(
'js_sandbox'
),
'data-gadget-url'
:
field
.
get_value
(
'gadget_url'
),
'data-gadget-value'
:
value
,
}
if
field
.
get_value
(
'json_value'
):
kw
[
'data-gadget-json'
]
=
dumps
(
value
)
else
:
kw
[
'data-gadget-value'
]
=
value
if
key
is
not
None
:
kw
[
'data-gadget-editable'
]
=
key
return
Widget
.
render_element
(
"div"
,
extra
=
field
.
get_value
(
'extra'
),
**
kw
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment