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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
erp5
Commits
211b58f5
Commit
211b58f5
authored
Dec 27, 2019
by
Tatuya Kamada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formulator: Add gadget_url_js field into TextWidget to customise renderjs gadget
parent
21cd9c2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
product/Formulator/Widget.py
product/Formulator/Widget.py
+21
-5
No files found.
product/Formulator/Widget.py
View file @
211b58f5
...
@@ -118,6 +118,13 @@ class Widget:
...
@@ -118,6 +118,13 @@ class Widget:
default
=
""
,
default
=
""
,
required
=
0
)
required
=
0
)
gadget_url_js
=
fields
.
StringField
(
'gadget_url_js'
,
title
=
'Gadget javascript URL'
,
description
=
(
"A url specifying the customised gadget javascript in renderjs_ui."
),
default
=
""
,
required
=
0
)
def
render
(
self
,
field
,
key
,
value
,
REQUEST
):
def
render
(
self
,
field
,
key
,
value
,
REQUEST
):
"""Renders this widget as HTML using property values in field.
"""Renders this widget as HTML using property values in field.
"""
"""
...
@@ -131,6 +138,10 @@ class Widget:
...
@@ -131,6 +138,10 @@ class Widget:
except
KeyError
:
except
KeyError
:
# In case extra is not defined as in DateTimeWidget
# In case extra is not defined as in DateTimeWidget
extra
=
''
extra
=
''
try
:
gadget_url_js
=
field
.
get_value
(
'gadget_url_js'
)
except
KeyError
:
gadget_url_js
=
''
result
=
''
result
=
''
# We must adapt the rendering to the type of the value
# We must adapt the rendering to the type of the value
# in order to get the correct type back
# in order to get the correct type back
...
@@ -140,13 +151,15 @@ class Widget:
...
@@ -140,13 +151,15 @@ class Widget:
type
=
"hidden"
,
type
=
"hidden"
,
name
=
"%s:list"
%
key
,
name
=
"%s:list"
%
key
,
value
=
v
,
value
=
v
,
extra
=
extra
)
extra
=
extra
,
gadget_url_js
=
gadget_url_js
)
else
:
else
:
result
=
render_element
(
"input"
,
result
=
render_element
(
"input"
,
type
=
"hidden"
,
type
=
"hidden"
,
name
=
key
,
name
=
key
,
value
=
value
,
value
=
value
,
extra
=
extra
)
extra
=
extra
,
gadget_url_js
=
gadget_url_js
)
return
result
return
result
def
render_view
(
self
,
field
,
value
,
REQUEST
=
None
,
render_prefix
=
None
):
def
render_view
(
self
,
field
,
value
,
REQUEST
=
None
,
render_prefix
=
None
):
...
@@ -333,7 +346,8 @@ class TextWidget(Widget):
...
@@ -333,7 +346,8 @@ class TextWidget(Widget):
"""Text widget
"""Text widget
"""
"""
property_names
=
Widget
.
property_names
+
\
property_names
=
Widget
.
property_names
+
\
[
'display_width'
,
'display_maxwidth'
,
'input_type'
,
'extra'
]
[
'display_width'
,
'display_maxwidth'
,
'input_type'
,
'extra'
,
'gadget_url_js'
]
default
=
fields
.
StringField
(
'default'
,
default
=
fields
.
StringField
(
'default'
,
title
=
'Default'
,
title
=
'Default'
,
...
@@ -382,7 +396,8 @@ class TextWidget(Widget):
...
@@ -382,7 +396,8 @@ class TextWidget(Widget):
value
=
value
,
value
=
value
,
size
=
field
.
get_value
(
'display_width'
),
size
=
field
.
get_value
(
'display_width'
),
maxlength
=
display_maxwidth
,
maxlength
=
display_maxwidth
,
extra
=
field
.
get_value
(
'extra'
))
extra
=
field
.
get_value
(
'extra'
),
gadget_url_js
=
field
.
get_value
(
'gadget_url_js'
))
else
:
else
:
return
render_element
(
"input"
,
return
render_element
(
"input"
,
type
=
input_type
,
type
=
input_type
,
...
@@ -390,7 +405,8 @@ class TextWidget(Widget):
...
@@ -390,7 +405,8 @@ class TextWidget(Widget):
css_class
=
field
.
get_value
(
'css_class'
),
css_class
=
field
.
get_value
(
'css_class'
),
value
=
value
,
value
=
value
,
size
=
field
.
get_value
(
'display_width'
),
size
=
field
.
get_value
(
'display_width'
),
extra
=
field
.
get_value
(
'extra'
))
extra
=
field
.
get_value
(
'extra'
),
gadget_url_js
=
field
.
get_value
(
'gadget_url_js'
))
def
render_view
(
self
,
field
,
value
,
REQUEST
=
None
,
render_prefix
=
None
):
def
render_view
(
self
,
field
,
value
,
REQUEST
=
None
,
render_prefix
=
None
):
"""Render text as non-editable.
"""Render text as non-editable.
...
...
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