Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5_fork
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
Eteri
erp5_fork
Commits
a89afa43
Commit
a89afa43
authored
Apr 02, 2014
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formulator: Support disabled items in all ItemWidget subclasses.
parent
2e139aec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
product/Formulator/Widget.py
product/Formulator/Widget.py
+19
-14
No files found.
product/Formulator/Widget.py
View file @
a89afa43
...
...
@@ -775,6 +775,17 @@ class ItemsWidget(Widget):
default
=
""
,
required
=
0
)
@
staticmethod
def
render_element
(
tag
,
**
kw
):
"""
Similar to global render_element, but render None values as disabled
elements.
"""
if
kw
[
'value'
]
is
None
:
kw
.
pop
(
'value'
)
kw
[
'disabled'
]
=
None
return
render_element
(
tag
,
**
kw
)
class
SingleItemsWidget
(
ItemsWidget
):
"""A widget with a number of items that has only a single
selectable item.
...
...
@@ -1119,14 +1130,11 @@ class ListWidget(SingleItemsWidget):
return
"
\
n
"
.
join
([
list_widget
,
input_hidden
])
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
if
value
is
None
:
return
render_element
(
'option'
,
contents
=
text
,
disabled
=
None
,
extra
=
extra_item
)
return
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
return
self
.
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
extra
=
extra_item
)
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
return
self
.
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
selected
=
None
,
extra
=
extra_item
)
ListWidgetInstance
=
ListWidget
()
...
...
@@ -1161,14 +1169,11 @@ class MultiListWidget(MultiItemsWidget):
return
"
\
n
"
.
join
([
multi_list
,
input_hidden
])
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
if
value
is
None
:
return
render_element
(
'option'
,
contents
=
text
,
disabled
=
None
,
extra
=
extra_item
)
return
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
return
self
.
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
extra
=
extra_item
)
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
return
self
.
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
selected
=
None
,
extra
=
extra_item
)
MultiListWidgetInstance
=
MultiListWidget
()
...
...
@@ -1202,7 +1207,7 @@ class RadioWidget(SingleItemsWidget):
return
string
.
join
(
rendered_items
,
"<br />"
)
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'input'
,
return
self
.
render_element
(
'input'
,
type
=
"radio"
,
css_class
=
css_class
,
name
=
key
,
...
...
@@ -1210,7 +1215,7 @@ class RadioWidget(SingleItemsWidget):
extra
=
extra_item
)
+
text
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'input'
,
return
self
.
render_element
(
'input'
,
type
=
"radio"
,
css_class
=
css_class
,
name
=
key
,
...
...
@@ -1247,7 +1252,7 @@ class MultiCheckBoxWidget(MultiItemsWidget):
return
string
.
join
(
rendered_items
,
"<br />"
)
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'input'
,
return
self
.
render_element
(
'input'
,
type
=
"checkbox"
,
css_class
=
css_class
,
name
=
key
,
...
...
@@ -1255,7 +1260,7 @@ class MultiCheckBoxWidget(MultiItemsWidget):
extra
=
extra_item
)
+
text
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'input'
,
return
self
.
render_element
(
'input'
,
type
=
"checkbox"
,
css_class
=
css_class
,
name
=
key
,
...
...
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